import pandas as pd import numpy as np from tensorflow import keras data = pd.read_csv("data_train", sep=',', error_bad_lines=False).dropna() X = data.loc[:,data.columns == "2805317"].astype(int) y = data.loc[:,data.columns == "198909"].astype(int) def NormalizeData(data): return (data - np.min(data)) / (np.max(data) - np.min(data)) X = NormalizeData(X) y = NormalizeData(y) model = keras.Sequential([ keras.layers.Dense(32,input_dim = X.shape[1], activation='relu'), keras.layers.Dense(64, activation='relu'), keras.layers.Dense(1,activation='relu'), ]) model.compile(loss='mean_absolute_error', optimizer='adam', metrics=['mean_absolute_error']) model.fit(X, y, epochs=15, validation_split = 0.3) data = pd.read_csv("data_test", sep=',', error_bad_lines=False).dropna() X_test = data.loc[:,data.columns == "2805317"].astype(int) y_test = data.loc[:,data.columns == "198909"].astype(int) X_test = NormalizeData(X_test) y_test = NormalizeData(y_test) prediction = model.predict(X_test) f = open("predictions.txt", "w") for (pred, test) in zip(prediction, y_test.values): f.write("predicted: %s expected: %s\n" % (str(pred), str(test)))