mirror of
https://github.com/fenago/data-science.git
synced 2026-05-05 00:51:50 +00:00
84 lines
1.7 KiB
Plaintext
84 lines
1.7 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"colab": {},
|
|
"colab_type": "code",
|
|
"id": "ddnAIuG-JCEj"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from sklearn import neighbors\n",
|
|
"\n",
|
|
"# initialize with default hyperparameters\n",
|
|
"knn = neighbors.KNeighborsClassifier()\n",
|
|
"\n",
|
|
"# examine the defaults\n",
|
|
"print(knn.get_params())"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"colab": {},
|
|
"colab_type": "code",
|
|
"id": "XjJF6G_iJgqu"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# initialize with k = 15 and all other hyperparameters as default \n",
|
|
"knn = neighbors.KNeighborsClassifier(n_neighbors=15)\n",
|
|
"\n",
|
|
"# examine\n",
|
|
"print(knn.get_params())"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"colab": {},
|
|
"colab_type": "code",
|
|
"id": "0aOROMLXJ1dP"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# initialize with k = 15, weights = distance and all other hyperparameters as default \n",
|
|
"knn = neighbors.KNeighborsClassifier(n_neighbors=15, weights='distance')\n",
|
|
"\n",
|
|
"# examine\n",
|
|
"print(knn.get_params())"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"colab": {
|
|
"collapsed_sections": [],
|
|
"name": "setting_hyperparameters.ipynb",
|
|
"provenance": []
|
|
},
|
|
"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.8.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 1
|
|
}
|