Update 'create-dataset.py'
This commit is contained in:
parent
55ff7334b4
commit
6a313cc874
@ -1,6 +1,10 @@
|
|||||||
import pandas
|
import pandas
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from keras.applications.densenet import layers
|
||||||
|
|
||||||
from sklearn.model_selection import train_test_split
|
from sklearn.model_selection import train_test_split
|
||||||
|
import tensorflow
|
||||||
|
|
||||||
|
|
||||||
CUTOFF = int(os.environ['CUTOFF'])
|
CUTOFF = int(os.environ['CUTOFF'])
|
||||||
@ -10,13 +14,16 @@ video_games = pandas.read_csv('./ium_z434686/Video_Games_Sales_as_at_22_Dec_2016
|
|||||||
engine='python',
|
engine='python',
|
||||||
encoding='ISO-8859-1',
|
encoding='ISO-8859-1',
|
||||||
sep=',')
|
sep=',')
|
||||||
|
|
||||||
# DROP NA FIELDS
|
# DROP NA FIELDS
|
||||||
video_games = video_games.dropna()
|
video_games = video_games.dropna()
|
||||||
|
video_games = video_games.drop(video_games.columns[[0, 1, 3, 4, 13, 14, 15]], axis=1)
|
||||||
|
|
||||||
# CUT OFF DATASET TO X LINES
|
# CUT OFF DATASET TO X LINES
|
||||||
video_games = video_games.sample(CUTOFF)
|
video_games = video_games.sample(CUTOFF)
|
||||||
|
|
||||||
X, Y = video_games, video_games
|
X = video_games.copy()
|
||||||
|
Y = pandas.DataFrame(video_games.pop('User_Score'))
|
||||||
|
|
||||||
# SPLIT BETWEEN DEV, TRAINS, AND TEST
|
# SPLIT BETWEEN DEV, TRAINS, AND TEST
|
||||||
X_train, X_temp, Y_train, Y_temp = train_test_split(X, Y, test_size=0.3, random_state=1)
|
X_train, X_temp, Y_train, Y_temp = train_test_split(X, Y, test_size=0.3, random_state=1)
|
||||||
@ -25,3 +32,31 @@ X_dev, X_test, Y_dev, Y_test = train_test_split(X_temp, Y_temp, test_size=0.3, r
|
|||||||
X_train.to_csv('X_train.csv', index=False)
|
X_train.to_csv('X_train.csv', index=False)
|
||||||
X_dev.to_csv('X_dev.csv', index=False)
|
X_dev.to_csv('X_dev.csv', index=False)
|
||||||
X_test.to_csv('X_test.csv', index=False)
|
X_test.to_csv('X_test.csv', index=False)
|
||||||
|
Y_test.to_csv('Y_test.csv', index=False)
|
||||||
|
Y_train.to_csv('Y_train.csv', index=False)
|
||||||
|
Y_dev.to_csv('Y_dev.csv', index=False)
|
||||||
|
|
||||||
|
train_data_x = pandas.read_csv('./X_train.csv')
|
||||||
|
|
||||||
|
|
||||||
|
train_data_x = pandas.read_csv('./X_train.csv')
|
||||||
|
|
||||||
|
|
||||||
|
games_all = train_data_x.copy()
|
||||||
|
games_predict = train_data_x.pop('User_Score')
|
||||||
|
normalize = layers.Normalization()
|
||||||
|
normalize.adapt(games_all)
|
||||||
|
|
||||||
|
norm_games_model = tensorflow.keras.Sequential([
|
||||||
|
normalize,
|
||||||
|
layers.Dense(64),
|
||||||
|
layers.Dense(1)
|
||||||
|
])
|
||||||
|
|
||||||
|
norm_games_model.compile(
|
||||||
|
loss=tensorflow.keras.losses.MeanSquaredError(),
|
||||||
|
optimizer=tensorflow.keras.optimizers.Adam())
|
||||||
|
|
||||||
|
norm_games_model.fit(games_all, games_predict, epochs=500)
|
||||||
|
|
||||||
|
norm_games_model.save('test')
|
||||||
|
Loading…
Reference in New Issue
Block a user