39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
|
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)
|