57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
import pandas as pd
|
|
import tensorflow as tf
|
|
from keras.models import Sequential
|
|
from keras.layers import Dense
|
|
from keras import utils
|
|
import os
|
|
|
|
EPOCHS = int(os.environ['EPOCHS'])
|
|
if EPOCHS <= 0:
|
|
EPOCHS = 1000
|
|
|
|
X_train = pd.read_csv('./X_train.csv',
|
|
engine = 'python',
|
|
encoding = 'ISO-8859-1',
|
|
sep=',')
|
|
|
|
X_val = pd.read_csv('./X_val.csv',
|
|
engine = 'python',
|
|
encoding = 'ISO-8859-1',
|
|
sep=',')
|
|
|
|
Y_train = pd.read_csv('./Y_train.csv',
|
|
engine = 'python',
|
|
encoding = 'ISO-8859-1',
|
|
sep=',')
|
|
|
|
Y_val = pd.read_csv('./Y_val.csv',
|
|
engine = 'python',
|
|
encoding = 'ISO-8859-1',
|
|
sep=',')
|
|
|
|
|
|
Y_train = utils.to_categorical(Y_train)
|
|
Y_val = utils.to_categorical(Y_val)
|
|
|
|
model = Sequential(
|
|
[
|
|
Dense(100, input_dim=X_train.shape[1], activation='relu'),
|
|
Dense(70, activation='relu'),
|
|
Dense(50, activation='relu'),
|
|
Dense(4, activation='softmax')
|
|
], name = "Players_model"
|
|
)
|
|
|
|
model.compile(
|
|
loss=tf.keras.losses.CategoricalCrossentropy(),
|
|
optimizer=tf.keras.optimizers.Adam(),
|
|
validation_data = (X_val, Y_val),
|
|
metrics=['accuracy'])
|
|
|
|
model.fit(
|
|
X_train,Y_train,
|
|
epochs = EPOCHS,
|
|
validation_data=(X_val, Y_val)
|
|
)
|
|
|
|
model.save('model') |