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 wget import numpy as np import os url = 'https://git.wmi.amu.edu.pl/s434788/ium_434788/raw/branch/master/winequality-red.csv' wget.download(url, out='winequality-red.csv', bar=None) wine=pd.read_csv('winequality-red.csv') 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() model.add(Dense(32,activation = "relu", input_shape = (x_train.shape[1],))) model.add(Dense(64,activation = "relu")) model.add(Dense(1,activation = "relu")) model.compile(optimizer = "adam", loss = "mean_squared_error") return model model = regression_model() model.fit(x_train, y_train, epochs = 600, verbose = 1) y_pred = model.predict(x_test) y_pred = np.around(y_pred, decimals=0) dirpath = os.getcwd() print("dirpath = ", dirpath, "\n") output_path = os.path.join(dirpath,'output.csv') print(output_path,"\n") pd.DataFrame(y_pred).to_csv(output_path) print(accuracy_score(y_test, y_pred)) print(classification_report(y_test,y_pred))