diff --git a/evaluation.py b/evaluation.py index a17a806..16f0af9 100644 --- a/evaluation.py +++ b/evaluation.py @@ -4,19 +4,32 @@ from tensorflow import keras import matplotlib.pyplot as plt from keras import backend as K from sklearn.metrics import mean_squared_error - -# model = keras.models.load_model('suicide_model.h5') +from tensorflow.keras import layers +from tensorflow.keras.layers.experimental import preprocessing +import tensorflow as tf train = pd.read_csv('train.csv') test = pd.read_csv('test.csv') validate = pd.read_csv('validate.csv') -print(train) # # podział train set -# X_train = train.loc[:, train.columns != 'suicides_no'] -# y_train = train[['suicides_no']] -# X_test = test.loc[:, train.columns != 'suicides_no'] -# y_test = test[['suicides_no']] +X_train = train.loc[:, train.columns != 'suicides_no'] +y_train = train[['suicides_no']] +X_test = test.loc[:, train.columns != 'suicides_no'] +y_test = test[['suicides_no']] + +normalizer = preprocessing.Normalization() +normalizer.adapt(np.array(X_train)) + +model = tf.keras.Sequential([ + normalizer, + layers.Dense(units=1) +]) + +model.summary() + +model.load_weights('suicide_model.h5') + # predictions = model.predict(X_test) diff --git a/preprocesing.py b/preprocesing.py index 9380f52..dd99f69 100644 --- a/preprocesing.py +++ b/preprocesing.py @@ -27,10 +27,10 @@ train, validate, test = np.split(sc.sample(frac=1, random_state=42), [int(.6*len(sc)), int(.8*len(sc))]) # zapis do plików -train.to_csv('train.csv') -validate.to_csv('validate.csv') -test.to_csv('test.csv') +train.to_csv('train.csv', index=False) +validate.to_csv('validate.csv', index=False) +test.to_csv('test.csv', index=False) -print(train) -print(validate) -print(test) +# print(train) +# print(validate) +# print(test) diff --git a/training.py b/training.py index 8ecbbb1..3b397e2 100644 --- a/training.py +++ b/training.py @@ -70,6 +70,8 @@ history = model.fit( epochs=EPOCHS, validation_split=0.2) +model.save_weights('suicide_model.h5') + test_results = {} test_results['model'] = model.evaluate( @@ -90,5 +92,4 @@ test_predictions = model.predict(X_test).flatten() predictions = model.predict(X_test) pd.DataFrame(predictions).to_csv('results.csv') - -model.save('suicide_model.h5') +model.summary()