diff --git a/JenkinsfileDatasetStats b/JenkinsfileDatasetStats index f5a440b..e86ee27 100644 --- a/JenkinsfileDatasetStats +++ b/JenkinsfileDatasetStats @@ -29,6 +29,11 @@ pipeline { copyArtifacts projectName: 'z487183-create-dataset' sh './prepare-stats.sh' archiveArtifacts 'stats.txt' + sh 'python3 property_model.py' + sh 'python3 predict_values.py' + archiveArtifacts 'test_predictions.csv' + archiveArtifacts 'train_predictions.csv' + archiveArtifacts 'dev_predictions.csv' } } } diff --git a/Lab4.dockerfile b/Lab4.dockerfile index 68da029..214a2a6 100644 --- a/Lab4.dockerfile +++ b/Lab4.dockerfile @@ -5,6 +5,8 @@ RUN apt-get install -y python3 python3-pip unzip RUN pip install pandas RUN pip install scikit-learn RUN pip install kaggle +RUN pip install keras +RUN pip install tensorflow ARG DEBIAN_FRONTEND=noninteractive diff --git a/predict_values.py b/predict_values.py new file mode 100644 index 0000000..29e015a --- /dev/null +++ b/predict_values.py @@ -0,0 +1,38 @@ +import pandas as pd +from tensorflow import keras +import csv + +model = keras.models.load_model('model.h5') +X_test = pd.read_csv('X_test.csv').values +X_train = pd.read_csv('X_train.csv').values +X_val = pd.read_csv('X_val.csv').values + +with open('test_predictions.csv', "a") as file: + writer = csv.writer(file) + predictions = model.predict(X_test) + writer.writerow(['PredictedPriceAboveMedian']) + for pred in predictions: + result = [0] + if pred[0] > 0.5: + result = [1] + writer.writerow(result) + +with open('train_predictions.csv', "a") as file: + writer = csv.writer(file) + predictions = model.predict(X_train) + writer.writerow(['PredictedPriceAboveMedian']) + for pred in predictions: + result = [0] + if pred[0] > 0.5: + result = [1] + writer.writerow(result) + +with open('dev_predictions.csv', "a") as file: + writer = csv.writer(file) + predictions = model.predict(X_val) + writer.writerow(['PredictedPriceAboveMedian']) + for pred in predictions: + result = [0] + if pred[0] > 0.5: + result = [1] + writer.writerow(result)