neural network predictions
Some checks failed
s434765-training/pipeline/head There was a failure building this commit

This commit is contained in:
Karolina Oparczyk 2021-04-24 22:23:04 +02:00
parent 4c0566b5e9
commit ba9b25f4c3
2 changed files with 42 additions and 5 deletions

View File

@ -6,7 +6,7 @@ RUN apt install -y python3-pip
RUN apt install -y unzip RUN apt install -y unzip
RUN pip3 install pandas RUN pip3 install pandas
RUN pip3 install kaggle RUN pip3 install kaggle
RUN pip3 install torch RUN pip3 install tensorflow
COPY ./get_data.sh ./ COPY ./get_data.sh ./
COPY get_data.py ./ COPY get_data.py ./
COPY ./neural_network.sh ./ COPY ./neural_network.sh ./

View File

@ -1,8 +1,45 @@
import torch
import pandas as pd import pandas as pd
import torch.nn as nn import numpy as np
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader from tensorflow import keras
device = 'cpu' device = 'cpu'
data = pd.read_csv("data_train", sep=',', error_bad_lines=False).dropna()
X = data.loc[:,data.columns == "2805317"].astype(int)
y = data.loc[:,data.columns == "198909"].astype(int)
def NormalizeData(data):
return (data - np.min(data)) / (np.max(data) - np.min(data))
X = NormalizeData(X)
y = NormalizeData(y)
model = keras.Sequential([
keras.layers.Dense(512,input_dim = X.shape[1],kernel_initializer='normal', activation='relu'),
keras.layers.Dense(512,kernel_initializer='normal', activation='relu'),
keras.layers.Dense(256,kernel_initializer='normal', activation='relu'),
keras.layers.Dense(256,kernel_initializer='normal', activation='relu'),
keras.layers.Dense(128,kernel_initializer='normal', activation='relu'),
keras.layers.Dense(1,kernel_initializer='normal', activation='linear'),
])
model.compile(loss='mean_absolute_error', optimizer='adam', metrics=['mean_absolute_error'])
model.fit(X, y, epochs=30, validation_split = 0.3)
data = pd.read_csv("data_test", sep=',', error_bad_lines=False).dropna()
X_test = data.loc[:,data.columns == "2805317"].astype(int)
y_test = data.loc[:,data.columns == "198909"].astype(int)
X_test = NormalizeData(X_test)
y_test = NormalizeData(y_test)
prediction = model.predict(X_test)
f = open("predictions.txt", "w")
for (pred, test) in zip(prediction, y_test.values):
f.write("predicted: %s expected: %s\n" % (str(pred), str(test)))