Last active
June 17, 2020 03:38
-
-
Save derkzomer/e589fb629b77a710fb3325e9de997596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"(26638, 9)\n", | |
"(6661, 9)\n" | |
] | |
} | |
], | |
"source": [ | |
"# We want 80% of the data to be used for training, and 20% for testing\n", | |
"n_train_rows = int(dataset.shape[0]*.8)-1\n", | |
"\n", | |
"# Split into train and test sets but keep all 9 columns\n", | |
"train = dataset.iloc[:n_train_rows, :]\n", | |
"test = dataset.iloc[n_train_rows:, :]\n", | |
"\n", | |
"# The total rows of the two datasets should equal the total amount of rows in your CSV\n", | |
"print(train.shape)\n", | |
"print(test.shape)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Normalise features\n", | |
"sc = MinMaxScaler(feature_range = (0, 1))\n", | |
"training_set_scaled = sc.fit_transform(train.values)\n", | |
"test_set_scaled = sc.fit_transform(test.values)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment