Created
April 23, 2020 23:16
-
-
Save SandieIJ/98faad2c7095594d5c885f909095bc05 to your computer and use it in GitHub Desktop.
This file contains hidden or 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": "markdown", | |
"metadata": {}, | |
"source": [ | |
"**RESHAPING AND NORMALIZING THE DATA**\n", | |
"\n", | |
"It is important to normalize your data before running any implementation of PCA to avoid important information about your dataset being dropped and thus reducing the ability of your model to learn better general patterns down the line" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from sklearn.decomposition import PCA\n", | |
"from sklearn.preprocessing import StandardScaler\n", | |
"\n", | |
"image_shape = shape(raw_training_x[0])\n", | |
"\n", | |
"pca_x = np.reshape(raw_training_x, (24000,96))\n", | |
"\n", | |
"scaler = StandardScaler()\n", | |
"scaler.fit(pca_x)\n", | |
"scaled_x = scaler.transform(pca_x)" | |
] | |
} | |
], | |
"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.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment