Poprawki do zajęć 3,4 i 5
This commit is contained in:
parent
33d62c375c
commit
b40e075716
@ -1,2 +1,2 @@
|
||||
#Uruchomienie skryptu i wyświetlenie 10 pierwszych wierszy wyjściowej tabeli
|
||||
python3 Zadanie_5_Docker.py
|
||||
python3 Zadanie_05_Docker.py
|
@ -20,9 +20,8 @@ RUN pip3 install --user sacred
|
||||
WORKDIR /app
|
||||
|
||||
# Skopiujmy nasz skrypt do katalogu /app w kontenerze
|
||||
COPY ./test.sh ./
|
||||
COPY ./Python_file.py ./
|
||||
COPY ./Zadanie_5_Docker.py ./
|
||||
COPY ./Docker_todo.sh ./
|
||||
COPY ./Zadanie_05_Docker.py ./
|
||||
|
||||
# Domyślne polecenie, które zostanie uruchomione w kontenerze po jego starcie
|
||||
CMD ./test.sh
|
||||
CMD ./Docker_todo.sh
|
@ -1,31 +0,0 @@
|
||||
import wget
|
||||
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)
|
||||
|
||||
import pandas as pd
|
||||
wine=pd.read_csv('winequality-red.csv')
|
||||
wine
|
||||
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
wine_train, wine_test = train_test_split(wine, test_size=360,train_size=959, random_state=1)
|
||||
|
||||
wine_test["quality"].value_counts()
|
||||
|
||||
wine_train["quality"].value_counts()
|
||||
|
||||
wine
|
||||
|
||||
wine["quality"].value_counts()
|
||||
|
||||
wine.describe(include='all')
|
||||
|
||||
wine["quality"]=((wine["quality"]-wine["quality"].min())/(wine["quality"].max()-wine["quality"].min()))*20
|
||||
|
||||
wine["quality"].value_counts()
|
||||
|
||||
wine.isnull().sum()
|
||||
|
||||
wine.dropna(inplace=True)
|
||||
|
||||
print(wine)
|
@ -1,49 +1,54 @@
|
||||
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
|
||||
|
||||
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[:5]
|
||||
|
||||
y_pred = np.around(y_pred, decimals=0)
|
||||
|
||||
y_pred[:5]
|
||||
|
||||
pd.DataFrame(y_pred).to_csv("preds.csv")
|
||||
|
||||
print(accuracy_score(y_test, y_pred))
|
||||
|
||||
print(classification_report(y_test,y_pred))
|
||||
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))
|
@ -1,47 +0,0 @@
|
||||
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
|
||||
|
||||
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[:5]
|
||||
|
||||
y_pred = np.around(y_pred, decimals=0)
|
||||
|
||||
y_pred[:5]
|
||||
|
||||
print(accuracy_score(y_test, y_pred))
|
||||
|
||||
print(classification_report(y_test,y_pred))
|
@ -1,28 +0,0 @@
|
||||
# Nasz obraz będzie dzidziczył z obrazu Ubuntu w wersji latest
|
||||
FROM ubuntu:latest
|
||||
|
||||
# Instalujemy niezbędne zależności. Zwróć uwagę na flagę "-y" (assume yes)
|
||||
RUN apt update && apt install -y git
|
||||
RUN apt install -y python3-pip
|
||||
RUN apt install -y curl
|
||||
RUN pip3 install --user wget
|
||||
RUN pip3 install --user kaggle
|
||||
RUN pip3 install --user seaborn
|
||||
RUN pip3 install --user sklearn
|
||||
RUN pip3 install --user pandas
|
||||
RUN pip3 install --user numpy
|
||||
RUN pip3 install --user matplotlib
|
||||
RUN pip3 install --user tensorflow
|
||||
RUN pip3 install --user sacred
|
||||
|
||||
|
||||
# Stwórzmy w kontenerze (jeśli nie istnieje) katalog /app i przejdźmy do niego (wszystkie kolejne polecenia RUN, CMD, ENTRYPOINT, COPY i ADD będą w nim wykonywane)
|
||||
WORKDIR /app
|
||||
|
||||
# Skopiujmy nasz skrypt do katalogu /app w kontenerze
|
||||
COPY ./test.sh ./
|
||||
COPY ./Python_file.py ./
|
||||
COPY ./Zadanie_5_Docker.py ./
|
||||
|
||||
# Domyślne polecenie, które zostanie uruchomione w kontenerze po jego starcie
|
||||
CMD ./test.sh
|
@ -1,31 +0,0 @@
|
||||
import wget
|
||||
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)
|
||||
|
||||
import pandas as pd
|
||||
wine=pd.read_csv('winequality-red.csv')
|
||||
wine
|
||||
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
wine_train, wine_test = train_test_split(wine, test_size=360,train_size=959, random_state=1)
|
||||
|
||||
wine_test["quality"].value_counts()
|
||||
|
||||
wine_train["quality"].value_counts()
|
||||
|
||||
wine
|
||||
|
||||
wine["quality"].value_counts()
|
||||
|
||||
wine.describe(include='all')
|
||||
|
||||
wine["quality"]=((wine["quality"]-wine["quality"].min())/(wine["quality"].max()-wine["quality"].min()))*20
|
||||
|
||||
wine["quality"].value_counts()
|
||||
|
||||
wine.isnull().sum()
|
||||
|
||||
wine.dropna(inplace=True)
|
||||
|
||||
print(wine)
|
Loading…
Reference in New Issue
Block a user