.
All checks were successful
s434784-training/pipeline/head This commit looks good
s434784-evaluation/pipeline/head This commit looks good

This commit is contained in:
Maciej Sobkowiak 2021-05-16 22:53:52 +02:00
parent b965a730c5
commit ba432415fb
3 changed files with 29 additions and 15 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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()