2021-05-14 21:52:14 +02:00
|
|
|
import csv
|
2021-05-02 22:01:32 +02:00
|
|
|
import pandas as pd
|
2021-05-15 22:30:25 +02:00
|
|
|
import seaborn as sns
|
|
|
|
import sys
|
|
|
|
import tensorflow
|
|
|
|
from tensorflow.keras import layers
|
|
|
|
# from tensorflow.keras.models import load_model
|
2021-05-02 22:01:32 +02:00
|
|
|
|
|
|
|
|
2021-05-15 22:30:25 +02:00
|
|
|
# X_test = pd.read_csv('test.csv')
|
|
|
|
#
|
|
|
|
# Y_test = X_test.pop('stabf')
|
|
|
|
# Y_test = pd.get_dummies(Y_test)
|
|
|
|
#
|
|
|
|
# model = load_model('grid-stability-dense.h5')
|
|
|
|
X_train = pd.read_csv('train.csv')
|
2021-05-02 22:01:32 +02:00
|
|
|
X_test = pd.read_csv('test.csv')
|
2021-05-15 22:30:25 +02:00
|
|
|
X_valid = pd.read_csv('valid.csv')
|
|
|
|
|
|
|
|
Y_train = X_train.pop('stabf')
|
|
|
|
Y_train = pd.get_dummies(Y_train)
|
2021-05-02 22:01:32 +02:00
|
|
|
|
2021-05-14 21:52:14 +02:00
|
|
|
Y_test = X_test.pop('stabf')
|
|
|
|
Y_test = pd.get_dummies(Y_test)
|
2021-05-02 22:01:32 +02:00
|
|
|
|
2021-05-15 22:30:25 +02:00
|
|
|
Y_valid = X_valid.pop('stabf')
|
|
|
|
Y_valid = pd.get_dummies(Y_valid)
|
|
|
|
|
|
|
|
model = tensorflow.keras.Sequential([
|
|
|
|
layers.Input(shape=(12,)),
|
|
|
|
layers.Dense(32),
|
|
|
|
layers.Dense(16),
|
|
|
|
layers.Dense(2, activation='softmax')
|
|
|
|
])
|
|
|
|
|
|
|
|
model.compile(
|
|
|
|
loss=tensorflow.keras.losses.BinaryCrossentropy(),
|
2021-05-15 22:45:51 +02:00
|
|
|
optimizer=tensorflow.keras.optimizers.Adam(),
|
2021-05-15 22:30:25 +02:00
|
|
|
metrics=[tensorflow.keras.metrics.BinaryAccuracy()])
|
|
|
|
|
|
|
|
history = model.fit(X_train, Y_train, epochs=2, validation_data=(X_valid, Y_valid))
|
2021-05-14 21:52:14 +02:00
|
|
|
results = model.evaluate(X_test, Y_test, batch_size=64)
|
2021-05-02 22:01:32 +02:00
|
|
|
|
2021-05-14 21:52:14 +02:00
|
|
|
with open('eval.csv', 'a', newline='') as fp:
|
|
|
|
wr = csv.writer(fp, dialect='excel')
|
|
|
|
wr.writerow(results)
|
2021-05-02 22:01:32 +02:00
|
|
|
|
2021-05-15 22:30:25 +02:00
|
|
|
sns.set_theme(style="darkgrid")
|
|
|
|
df = pd.read_csv('eval.csv')
|
|
|
|
sns.lineplot(x='build', y='score', data=df.iloc[1])
|