From 9e20a2d989cbef2f7bf2e86ce5856a56d7c49b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ga=C5=82ka?= Date: Wed, 19 Apr 2023 15:27:00 +0200 Subject: [PATCH] Update 'create-dataset.py' --- create-dataset.py | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/create-dataset.py b/create-dataset.py index 9bc5ca3..ebcc4b5 100644 --- a/create-dataset.py +++ b/create-dataset.py @@ -1,7 +1,35 @@ -text = "Hello world" +import pandas +import os +from sklearn.model_selection import train_test_split + + +CUTOFF = os.environ['CUTOFF'] + +# READ DATA +video_games = pandas.read_csv('Video_Games_Sales_as_at_22_Dec_2016.csv', + engine='python', + encoding='ISO-8859-1', + sep=',') +# DROP NA FIELDS +video_games = video_games.dropna() + +# CUT OFF DATASET TO X LINES +video_games = video_games.sample(CUTOFF) + +X, Y = video_games, video_games + +# 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_dev, X_test, Y_dev, Y_test = train_test_split(X_temp, Y_temp, test_size=0.3, random_state=1) + +X_train.to_csv('X_train.csv', index=False) +X_dev.to_csv('X_dev.csv', index=False) +X_test.to_csv('X_test.csv', index=False) + + + + + + -filename = "file.txt" -with open(filename, "w") as file: - - file.write(text) \ No newline at end of file