From f5a2673e0783b03e43842e1f172c462b2b54471b Mon Sep 17 00:00:00 2001 From: Kacper Dudzic Date: Sun, 24 Apr 2022 22:51:54 +0200 Subject: [PATCH] lab5 fix --- Jenkinsfile | 9 ++++++++- simple_regression.py | 21 ++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 08a308c..205083b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,13 @@ pipeline { agent { dockerfile true } + parameters { + string( + defaultValue: '100', + description: 'Example training parameter', + name: 'EPOCHS_NUM' + ) + } stages { stage('Stage 1') { steps { @@ -10,7 +17,7 @@ pipeline { sh 'python3 process_dataset.py' echo 'Dataset processed' echo 'Conducting simple regression model test' - sh 'python3 simple_regression.py' + sh 'python3 simple_regression.py $EPOCHS_NUM' echo 'Model predictions saved' sh 'head lego_linreg_results.csv' } diff --git a/simple_regression.py b/simple_regression.py index b45d523..a5824e5 100644 --- a/simple_regression.py +++ b/simple_regression.py @@ -44,18 +44,11 @@ history = model.fit( validation_split=0.2 ) -# Prosta ewaluacja -test_results = {'model': model.evaluate( - test_piece_counts, - test_prices, verbose=0) -} - -# Wykonanie wielu predykcji -x = tf.linspace(100, 7000, 6901) -y = model.predict(x) +# Wykonanie predykcji na danych ze zbioru testujÄ…cego +y_pred = model.predict(test_piece_counts) # Zapis predykcji do pliku -results = pd.DataFrame({"input_piece_count": x.numpy().tolist(), "predicted_price": [a[0] for a in y.tolist()]}) +results = pd.DataFrame({"test_set_piece_count": test_piece_counts.numpy().tolist(), "predicted_price": [a[0] for a in y_pred.tolist()]}) results.to_csv(r'lego_reg_results.csv', index=False, header=True) # Zapis modelu do pliku @@ -63,6 +56,12 @@ model.save('lego_reg_model') # Opcjonalne statystyki, wykresy ''' +# Prosta ewaluacja +test_results = {'model': model.evaluate( + test_piece_counts, + test_prices, verbose=0) +} + print(test_results) hist = pd.DataFrame(history.history) @@ -70,7 +69,7 @@ hist['epoch'] = history.epoch print(hist.tail()) plt.scatter(train_piece_counts, train_prices, label='Data') -plt.plot(x, y, color='k', label='Predictions') +plt.plot(x, y_pred, color='k', label='Predictions') plt.xlabel('pieces') plt.ylabel('price') plt.legend()