из numpy import loadtxt из keras.models import Sequential из keras.layers import Dense из matplotlib import pyplot
from sklearn.preprocessing import MinMaxScaler
# load the dataset
dataset = loadtxt('train.csv', delimiter=',')
scaler = MinMaxScaler(feature_range=(0, 1))
scaler.fit(dataset)
normalized = scaler.transform(dataset)
for row in normalized:
# split into input (X) and output (y) variables
X = row[0:13]
y = row[13]
# define the keras model
model = Sequential()
model.add(Dense(12, input_dim=13, activation='relu'))
model.add(Dense(16, activation='relu'))
model.add(Dense(20, activation='relu'))
model.add(Dense(16, activation='relu'))
model.add(Dense(1, activation='relu'))
# compile the keras model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['mse', 'mae', 'mape'])
history =model.fit(X, y, epochs=20,batch_size=1 , verbose=2)
pyplot.plot(history.history['mse'])
pyplot.plot(history.history['mae'])
pyplot.plot(history.history['mape'])
pyplot.show()