ium_434788/Zadanie_06_training.py

36 lines
1.0 KiB
Python
Raw Normal View History

2021-05-13 19:18:15 +02:00
from tensorflow.keras.models import Sequential, load_model
from tensorflow.keras.layers import Dense
from sklearn.metrics import accuracy_score, classification_report
import pandas as pd
from sklearn.model_selection import train_test_split
import numpy as np
2021-05-15 15:04:56 +02:00
import sys
2021-05-13 19:18:15 +02:00
2021-05-14 19:47:01 +02:00
wine=pd.read_csv('train.csv')
2021-05-13 19:18:15 +02:00
wine
y = wine.quality
y.head()
x = wine.drop(['quality'], axis= 1)
x.head()
x=((x-x.min())/(x.max()-x.min())) #Normalizacja
x_train, x_test, y_train, y_test = train_test_split(x,y , test_size=0.2,train_size=0.8, random_state=21)
def regression_model():
model = Sequential()
2021-05-15 15:04:56 +02:00
model.add(Dense(4,activation = "relu", input_shape = (x_train.shape[1],)))
model.add(Dense(8,activation = "relu"))
model.add(Dense(8,activation = "relu"))
2021-05-13 19:18:15 +02:00
model.add(Dense(1,activation = "relu"))
model.compile(optimizer = "adam", loss = "mean_squared_error")
return model
model = regression_model()
2021-05-15 15:08:39 +02:00
model.fit(x_train, y_train, batch_size=int(sys.argv[1]), epochs = int(sys.argv[1])) #verbose = 1
2021-05-13 19:18:15 +02:00
model.save('wine_model')