mirror of
https://github.com/ArthurDanjou/ml_exercises.git
synced 2026-01-14 12:14:38 +01:00
update versions
This commit is contained in:
@@ -223,15 +223,14 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# lambdas = eigenvalues\n",
|
||||
"print(kpca.lambdas_[:10])\n",
|
||||
"print(kpca.eigenvalues_[:10])\n",
|
||||
"# check how much \"information\" we would keep if we were to reduce the dimensionality to 20\n",
|
||||
"# (this is not 100% accurate, since we only computed the first 100 kPCA components, i.e.,\n",
|
||||
"# normally lambda_ should contain all eigenvalues - but this should be close enough)\n",
|
||||
"print(\"Percentage of variance retained with 20 components:\", 100*(sum(kpca.lambdas_[:20])/sum(kpca.lambdas_)))\n",
|
||||
"# normally kpca.eigenvalues_ should contain all eigenvalues - but this should be close enough)\n",
|
||||
"print(\"Percentage of variance retained with 20 components:\", 100*(sum(kpca.eigenvalues_[:20])/sum(kpca.eigenvalues_)))\n",
|
||||
"# plot eigenvalue spectrum\n",
|
||||
"plt.figure()\n",
|
||||
"plt.plot(range(1, len(kpca.lambdas_)+1), kpca.lambdas_)\n",
|
||||
"plt.plot(range(1, len(kpca.eigenvalues_)+1), kpca.eigenvalues_)\n",
|
||||
"plt.xlabel(\"PCs\")\n",
|
||||
"plt.ylabel(\"Eigenvalue\");\n",
|
||||
"# observe how the first value is extremely large"
|
||||
@@ -359,7 +358,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -373,7 +372,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.5"
|
||||
"version": "3.10.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user