Skip to content

Instantly share code, notes, and snippets.

@QuantumDamage QuantumDamage/027-2.ipynb
Last active Jan 26, 2019

Embed
What would you like to do?
Silhouette Coefficient - czy dobrze pogrupowałem obserwacje?
{
"cells": [
{
"metadata": {
"scrolled": true,
"trusted": true
},
"cell_type": "code",
"source": "import pandas as pd\n\nznaczki = pd.read_excel(\"../input/wykaz-zt-polski.xls\", skiprows = 4)\n\nznaczki.rename(columns={\"GPS\":\"lat\", \"Unnamed: 5\":\"lon\"}, inplace=True)\n\nznaczki[\"lat\"] = znaczki[\"lat\"].astype(float)\nznaczki[\"lon\"] = znaczki[\"lon\"].astype(float)",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "from sklearn.cluster import KMeans\n\nn_clusters = 12\n\nkmeans = KMeans(n_clusters = n_clusters, random_state = 42)\n\ncoordinates = znaczki[[\"lat\", \"lon\"]]\n\nkmeans.fit(coordinates)\n\nznaczki[\"grupa\"] = kmeans.labels_\n\nznaczki.head()",
"execution_count": 2,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 2,
"data": {
"text/plain": " LP. Numer znaczka Nazwa znaczka \\\n0 1 No. 001 Rysy – najwyższy szczyt polskich Tatr \n1 2 No. 002 Schronisko \"Murowaniec\" na Hali Gąsienicowej \n2 3 No. 003 Babia Góra – najwyższy szczyt Beskidu Żywieckiego \n3 4 No. 004 Schronisko Morskie Oko \n4 5 No. 005 Schronisko Głodówka \n\n Województwo lat lon grupa \n0 małopolskie 49.179628 20.087987 1 \n1 małopolskie 49.244167 20.007222 1 \n2 małopolskie 49.573055 19.529444 4 \n3 małopolskie 49.201378 20.071276 1 \n4 małopolskie 49.302124 20.116664 1 ",
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>LP.</th>\n <th>Numer znaczka</th>\n <th>Nazwa znaczka</th>\n <th>Województwo</th>\n <th>lat</th>\n <th>lon</th>\n <th>grupa</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>1</td>\n <td>No. 001</td>\n <td>Rysy – najwyższy szczyt polskich Tatr</td>\n <td>małopolskie</td>\n <td>49.179628</td>\n <td>20.087987</td>\n <td>1</td>\n </tr>\n <tr>\n <th>1</th>\n <td>2</td>\n <td>No. 002</td>\n <td>Schronisko \"Murowaniec\" na Hali Gąsienicowej</td>\n <td>małopolskie</td>\n <td>49.244167</td>\n <td>20.007222</td>\n <td>1</td>\n </tr>\n <tr>\n <th>2</th>\n <td>3</td>\n <td>No. 003</td>\n <td>Babia Góra – najwyższy szczyt Beskidu Żywieckiego</td>\n <td>małopolskie</td>\n <td>49.573055</td>\n <td>19.529444</td>\n <td>4</td>\n </tr>\n <tr>\n <th>3</th>\n <td>4</td>\n <td>No. 004</td>\n <td>Schronisko Morskie Oko</td>\n <td>małopolskie</td>\n <td>49.201378</td>\n <td>20.071276</td>\n <td>1</td>\n </tr>\n <tr>\n <th>4</th>\n <td>5</td>\n <td>No. 005</td>\n <td>Schronisko Głodówka</td>\n <td>małopolskie</td>\n <td>49.302124</td>\n <td>20.116664</td>\n <td>1</td>\n </tr>\n </tbody>\n</table>\n</div>"
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "# kod 1\nfrom sklearn.metrics import silhouette_score\nsilhouette_score(X = coordinates, labels = znaczki[\"grupa\"])",
"execution_count": 13,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 13,
"data": {
"text/plain": "0.450639136417191"
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "# kod 2 \nsilhouette_averages = []\nfor ilosc_grup in range(2,len(znaczki)):\n n_clusters = ilosc_grup\n kmeans = KMeans(n_clusters = n_clusters, \n random_state = 42)\n kmeans.fit(coordinates)\n znaczki[\"grupa\"] = kmeans.labels_\n sil_sco = silhouette_score(X = coordinates, \n labels = znaczki[\"grupa\"])\n silhouette_averages.append(sil_sco)\n if ilosc_grup % 10 == 0:\n print(ilosc_grup,sil_sco)",
"execution_count": 50,
"outputs": [
{
"output_type": "stream",
"text": "10 0.4414132828753228\n20 0.44058327835141947\n30 0.4538771864033944\n40 0.47266042687421567\n50 0.48266687262597\n60 0.4993816232672794\n70 0.5044715377903637\n80 0.5077644072529796\n90 0.5158986440745873\n100 0.5297141020047416\n110 0.5277911607622169\n120 0.5454616249331111\n130 0.539129063779735\n140 0.5536761609291103\n150 0.5580628610213431\n160 0.5645657410311796\n170 0.5701974656932992\n180 0.5783162478358502\n190 0.5709873719579736\n200 0.5723340580127944\n210 0.5766784328328961\n220 0.5881459330910309\n230 0.588837942380066\n240 0.5931334811769141\n250 0.5893427059136105\n260 0.6036059401757289\n270 0.6092348723358586\n280 0.6026894911310365\n290 0.6037853342406011\n300 0.6009959823794525\n310 0.6009650894849635\n320 0.6012345395044343\n330 0.5988163799662259\n340 0.5868131570508178\n350 0.5866953958788685\n360 0.5867281618603429\n370 0.5822697667110571\n380 0.5641549249693714\n390 0.5620795793047825\n400 0.5609647765412068\n410 0.5608638526819211\n420 0.5542612675262899\n430 0.5411053873626841\n440 0.5343564438353051\n450 0.5303899402437036\n460 0.5204653891791396\n470 0.5056420751205427\n480 0.4909855319320274\n490 0.4770085241649209\n500 0.46007987045913934\n510 0.44916528309074744\n520 0.4358432673463338\n530 0.4152421037169779\n540 0.4001538236102473\n550 0.38452943342565277\n560 0.35991073669130375\n570 0.3451362652901065\n580 0.3280827062777076\n590 0.30820250629854945\n600 0.2911908081623258\n610 0.27462817041815657\n620 0.2506229676946552\n630 0.22270819074984513\n640 0.2081454624564019\n650 0.18855651774295545\n660 0.1687476603764477\n670 0.14983495012192982\n680 0.13617200110919506\n690 0.12143601425977638\n700 0.10196364174718407\n710 0.0852391034384813\n720 0.06595986704659981\n730 0.0435861415409139\n740 0.02090973189214212\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import pylab",
"execution_count": 51,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "pylab.plot(range(2,len(silhouette_averages)+2),silhouette_averages, )",
"execution_count": 52,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 52,
"data": {
"text/plain": "[<matplotlib.lines.Line2D at 0x7f35e748d438>]"
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 432x288 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xd8VFX6x/HPM5MeQgIktCSQAKGEDqFIE6WIoLh21MUGdhbbb1csuOquu5ZVd11dEV0bFkQFZUVBigUUCKETaoAAoYYeSkg7vz9mEiYhkCFMcmcmz/v14pW5d07uPMnAlzPn3nuOGGNQSinlX2xWF6CUUsrzNNyVUsoPabgrpZQf0nBXSik/pOGulFJ+SMNdKaX8kIa7Ukr5IQ13pZTyQxruSinlhwKseuHo6GiTkJBg1csrpZRPWrp06X5jTExF7SwL94SEBNLS0qx6eaWU8kkiss2ddjoso5RSfkjDXSml/JCGu1JK+SENd6WU8kMa7kop5Yc03JVSyg9puCullB/ScFdVavbavcxbv9fqMpSqcdwKdxEZIiIbRCRDRMadpc0NIrJWRNJF5FPPlql8UerWg9z1URp3fpDGoFd/5t35Wyr8nh0HT/DIlBXk5hdWQ4VK+S+paIFsEbEDG4FBQBawBLjJGLPWpU0SMAW41BhzSETqG2P2neu4KSkpRu9Q9V/frNjJH79YRV5hEf1bxfDThuyS5z66szu7Dp/k6i6xTF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hbje6xetD/PE90DMVx5cdm4EkL6/gM2A3k4/gffBSOsdW5wCbn17rOtgK86ax5NZBSDfX1wfERcRWwwvlnqJfV2AFY7qxxDfC0c38zIBXIwPHRONi5P8S5neF8vlk1v+f9OX21jNfU6KxlpfNPevG/C296r52v2wlIc77fXwN1vLDGMOAAEOmyz6tqPJ8/eoeqUkr5IV8allFKKeUmDXellPJDGu5KKeWHNNyVUsoPabgrpZQf0nBXSik/pOGulFJ+SMNdKaX80P8DzQpRTe1GOnYAAAAASUVORK5CYII=\n"
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import operator\nmin_index, min_value = min(enumerate(silhouette_averages), key=operator.itemgetter(1))\nmax_index, max_value = max(enumerate(silhouette_averages), key=operator.itemgetter(1))\nprint(min_index+2, min_value)\nprint(max_index+2, max_value)",
"execution_count": 53,
"outputs": [
{
"output_type": "stream",
"text": "746 0.0053475935828877\n266 0.6116557772535383\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "len(znaczki)",
"execution_count": 54,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 54,
"data": {
"text/plain": "748"
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"_draft": {
"nbviewer_url": "https://gist.github.com/c25d0683b1af98cb201ae478f604cc1e"
},
"gist": {
"id": "c25d0683b1af98cb201ae478f604cc1e",
"data": {
"description": "Silhouette Coefficient - czy dobrze pogrupowałem obserwacje?",
"public": true
}
},
"kernelspec": {
"name": "conda-env-jakbadacdane.pl-py",
"display_name": "Python [conda env:jakbadacdane.pl]",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.6.7",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.