Skip to content

Instantly share code, notes, and snippets.

@SandieIJ
Created April 23, 2020 23:23
Show Gist options
  • Save SandieIJ/1c3e0fade43ed0fdb88618f496c5a41d to your computer and use it in GitHub Desktop.
Save SandieIJ/1c3e0fade43ed0fdb88618f496c5a41d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**IMPLEMENTING PCA**\n",
"\n",
"We will compare two implementations of PCA, one with 95% of the components retained and another version with a specified number of 10 components"
]
},
{
"cell_type": "code",
"execution_count": 269,
"metadata": {},
"outputs": [],
"source": [
"pca = PCA(0.95)\n",
"\n",
"pca_transformed = pca.fit_transform(scaled_x)"
]
},
{
"cell_type": "code",
"execution_count": 376,
"metadata": {},
"outputs": [],
"source": [
"pca2 = PCA(10)\n",
"\n",
"pca_transformed2 = pca2.fit_transform(scaled_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