primer clase de aprendizaje maquina

parent 031f56b7
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"\n", "\n",
"# 7. Machine Learning con scikit-learn\n", "# 7. Machine Learning con scikit-learn\n",
"\n", "\n",
"Scikit-learn es probablemente la librería más útil para Machine Learning en Python, es de código abierto y es reutilizable en varios contextos, fomentando el uso académico y comercial. Proporciona una gama de algoritmos de aprendizaje supervisados y no supervisados en Python.\n" "Scikit-learn es probablemente la biblioteca más útil para Machine Learning en Python, es de código abierto y es reutilizable en varios contextos, fomentando el uso académico y comercial. Proporciona una gama de algoritmos de aprendizaje supervisados y no supervisados en Python.\n"
] ]
}, },
{ {
...@@ -90,13 +90,16 @@ ...@@ -90,13 +90,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 48, "execution_count": 5,
"metadata": {}, "metadata": {
"scrolled": true
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"<class 'sklearn.utils.Bunch'>\n",
"[[ 0. 0. 5. ... 0. 0. 0.]\n", "[[ 0. 0. 5. ... 0. 0. 0.]\n",
" [ 0. 0. 0. ... 10. 0. 0.]\n", " [ 0. 0. 0. ... 10. 0. 0.]\n",
" [ 0. 0. 0. ... 16. 9. 0.]\n", " [ 0. 0. 0. ... 16. 9. 0.]\n",
...@@ -104,7 +107,12 @@ ...@@ -104,7 +107,12 @@
" [ 0. 0. 1. ... 6. 0. 0.]\n", " [ 0. 0. 1. ... 6. 0. 0.]\n",
" [ 0. 0. 2. ... 12. 0. 0.]\n", " [ 0. 0. 2. ... 12. 0. 0.]\n",
" [ 0. 0. 10. ... 12. 1. 0.]]\n", " [ 0. 0. 10. ... 12. 1. 0.]]\n",
"[0 1 2 ... 8 9 8]\n" "[0 1 2 ... 8 9 8]\n",
"[ 0. 0. 0. 0. 14. 13. 1. 0. 0. 0. 0. 5. 16. 16. 2. 0. 0. 0.\n",
" 0. 14. 16. 12. 0. 0. 0. 1. 10. 16. 16. 12. 0. 0. 0. 3. 12. 14.\n",
" 16. 9. 0. 0. 0. 0. 0. 5. 16. 15. 0. 0. 0. 0. 0. 4. 16. 14.\n",
" 0. 0. 0. 0. 0. 1. 13. 16. 1. 0.]\n",
"1\n"
] ]
} }
], ],
...@@ -113,8 +121,13 @@ ...@@ -113,8 +121,13 @@
"\n", "\n",
"digits = datasets.load_digits()\n", "digits = datasets.load_digits()\n",
"\n", "\n",
"print(type(digits))\n",
"\n",
"print(digits.data)\n", "print(digits.data)\n",
"print(digits.target)" "print(digits.target)\n",
"\n",
"print(digits.data[11])\n",
"print(digits.target[11])"
] ]
}, },
{ {
...@@ -128,29 +141,53 @@ ...@@ -128,29 +141,53 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 49, "execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[ 0., 0., 5., 13., 9., 1., 0., 0.],\n", "array([[ 0., 0., 0., 0., 14., 13., 1., 0.],\n",
" [ 0., 0., 13., 15., 10., 15., 5., 0.],\n", " [ 0., 0., 0., 5., 16., 16., 2., 0.],\n",
" [ 0., 3., 15., 2., 0., 11., 8., 0.],\n", " [ 0., 0., 0., 14., 16., 12., 0., 0.],\n",
" [ 0., 4., 12., 0., 0., 8., 8., 0.],\n", " [ 0., 1., 10., 16., 16., 12., 0., 0.],\n",
" [ 0., 5., 8., 0., 0., 9., 8., 0.],\n", " [ 0., 3., 12., 14., 16., 9., 0., 0.],\n",
" [ 0., 4., 11., 0., 1., 12., 7., 0.],\n", " [ 0., 0., 0., 5., 16., 15., 0., 0.],\n",
" [ 0., 2., 14., 5., 10., 12., 0., 0.],\n", " [ 0., 0., 0., 4., 16., 14., 0., 0.],\n",
" [ 0., 0., 6., 13., 10., 0., 0., 0.]])" " [ 0., 0., 0., 1., 13., 16., 1., 0.]])"
] ]
}, },
"execution_count": 49, "execution_count": 16,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"digits.images[0]" "digits.images[11]"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0., 0., 0., 0., 14., 13., 1., 0., 0., 0., 0., 5., 16.,\n",
" 16., 2., 0., 0., 0., 0., 14., 16., 12., 0., 0., 0., 1.,\n",
" 10., 16., 16., 12., 0., 0., 0., 3., 12., 14., 16., 9., 0.,\n",
" 0., 0., 0., 0., 5., 16., 15., 0., 0., 0., 0., 0., 4.,\n",
" 16., 14., 0., 0., 0., 0., 0., 1., 13., 16., 1., 0.])"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"digits.data[11]\n"
] ]
}, },
{ {
...@@ -172,7 +209,7 @@ ...@@ -172,7 +209,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 60, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -183,7 +220,7 @@ ...@@ -183,7 +220,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 53, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -195,7 +232,7 @@ ...@@ -195,7 +232,7 @@
" tol=0.001, verbose=False)" " tol=0.001, verbose=False)"
] ]
}, },
"execution_count": 53, "execution_count": 8,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -206,16 +243,16 @@ ...@@ -206,16 +243,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 54, "execution_count": 22,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([8])" "array([1])"
] ]
}, },
"execution_count": 54, "execution_count": 22,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -230,12 +267,24 @@ ...@@ -230,12 +267,24 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 55, "execution_count": 29,
"metadata": {}, "metadata": {
"scrolled": true
},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAS8AAAEyCAYAAACrlladAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAADeNJREFUeJzt3f+r5QWdx/Hnq6tRWTsDehFxxOsPIURQysUlDFuVQrcwf9gfFIomFmZ/qHDYhaj9ZfEfqPaHJRj8NkuWlCVEtH2BvLXBZl3NtnRsMbmLI9UcCVH7YUV77w9zZMfZO/d8bnPP+Zx3PR9wmXvuPZzz4jo+53O+3HNSVUhSN68be4Ak/TGMl6SWjJekloyXpJaMl6SWjJekloyXpJaMl6SWjJekls6Zx4VecMEFtba2No+Lbmlra2vsCQC88MILY08A4Pzzzx97AgAXXnjh2BMAWFlZGXvC0tja2uLZZ5/NkPPOJV5ra2tsbm7O46JbOnjw4NgTANjY2Bh7ArA8P4/Dhw+PPQGA/fv3jz1haayvrw8+rzcbJbVkvCS1ZLwktWS8JLVkvCS1ZLwktWS8JLVkvCS1ZLwktWS8JLVkvCS1ZLwktTQoXkluSPLLJE8m+dS8R0nSLDPjlWQF+BfgRuBtwK1J3jbvYZK0kyFHXlcBT1bVU1X1EnAf8MH5zpKknQ2J18XA06ecPj792mskOZRkM8nmZDLZq32StK09u8O+qo5U1XpVra+uru7VxUrStobE6xngklNOH5h+TZJGMyRePwHemuSyJK8HbgG+Pt9ZkrSzma9hX1UvJ/k48G1gBbirqh6b+zJJ2sGgN+Coqm8C35zzFkkazGfYS2rJeElqyXhJasl4SWrJeElqyXhJasl4SWrJeElqyXhJasl4SWrJeElqadDvNna1tbU19gQAjh49OvYEAC699NKxJwCw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5hR1XVi9OT504/RvlXL8kB4P3AHWNc/zJJsg+4BrgToKpeGjNcU9cDv5p3uGD54nUx8PQpp48zwv+syyjJGnAF8NBI17+S5FHgBPDdqhplB/A54JPAH0a6/lcV8J0kDyc5NNKGy4AJcPf0ZvQd0/dYHdMtLOjNqZctXtpGkjcDXwUOV9XzY2yoqleq6p3AAeCqJAu/OZ3kA8CJqnp40de9jXdX1ZXAjcDHpnc1LNo5wJXA56vqCuD3wCj3EwNMb7beBHxlEde3bPF6BrjklNMHpl/7szW9j+mrwL1VNfo7lk9vljwI3DDC1V8N3DS9v+k+4LokXxhhB1X1zPTPE8ADnLzLY9GOA8dPOQq+n5MxG8uNwCNV9dtFXNmyxesnwFuTXDat+C3A10feNJrpHeV3Aseq6jMj7lhNsn/6+Rs5+YDKE4veUVWfrqoDVbXGyb8b36uqDy16R5Lzpg+gML2Z9j5g4Y9MV9VvgKeTXD790vXAQh/MOc2tLOgmI5w87FwaVfVyko8D3wZWgLuq6rFF70jyJeCvgAuSHAf+qaruXPQOTh5pfBj4+fT+JoB/rKpvLnjHRcDR6SNJrwO+XFWjPU1hCVwIPHDy3xbOAb5YVd8aacsngHun/9g/BXx0jBHTiL8X+LuFXecyPVVCkoZatpuNkjSI8ZLUkvGS1JLxktSS8ZLUkvGS1JLxktTS/wIMszZGNDz8mQAAAABJRU5ErkJggg==\n", "text/plain": [
"array([1])"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAS8AAAEyCAYAAACrlladAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAADg1JREFUeJzt3f+L5IV9x/HXyz1PV3PNgQ5BXOmKRCEIURkswSBVMWgjpj/0B4UEGgrXH5KgtBBMf6n5B4L9o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S3pk7YvHFX8Fkk/6nhTZ0Z3lN8j6VCSb3W4o2d79+jzRW08oPLirHck+UaSpSTL2vi38dMkX5z1Dttnjx5A0ehm2uckzfyR6SS/k/S67UtGX7pO0kwfzDnJrZrRTUZp47BzbiQ5Yfurkn4saUHSvUmen/UO2w9I+ktJ59o+Iumfk9wz6x3aONL4kqRnR/c3SdI/JXl0xjvOk3Tf6JGk0yR9P0lnT1OYA5+Q9MjGzxbtkPS9JI91tOVrku4f/bB/RdKXuxgxivj1kv5+Ztc5T0+VAICm5u1mIwA0QrwAlES8AJREvACURLwAlES8AJREvACU9L+nG0Jqc6MFTgAAAABJRU5ErkJggg==\n",
"text/plain": [ "text/plain": [
"<Figure size 360x360 with 1 Axes>" "<Figure size 360x360 with 1 Axes>"
] ]
...@@ -254,15 +303,37 @@ ...@@ -254,15 +303,37 @@
"#Display the first digit\n", "#Display the first digit\n",
"plt.figure(1, figsize=(5, 5))\n", "plt.figure(1, figsize=(5, 5))\n",
"plt.imshow(digits.images[-1], cmap=plt.cm.gray_r, interpolation='nearest')\n", "plt.imshow(digits.images[-1], cmap=plt.cm.gray_r, interpolation='nearest')\n",
"plt.show()" "\n",
"gato = np.array([[ 0., 3., 0., 0., 6., 13., 1., 5., 10., 0., 0., 5., 16.,\n",
" 16., 2., 40., 0., 0., 80., 14., 16., 12., 0., 0., 0., 1.,\n",
" 10., 16., 16., 12., 0., 0., 0., 3., 0., 14., 16., 9., 0.,\n",
" 0., 0., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 4.,\n",
" 16., 14., 0., 0., 0., 0., 0., 1., 5., 1., 1., 0.]]).reshape(8,8)\n",
"\n",
"plt.imshow( gato ,cmap=plt.cm.gray_r, interpolation='nearest')\n",
"\n",
"clf.predict(gato.reshape(1,8*8))"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": [] {
"data": {
"text/plain": [
"8"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"digits.target[-1]"
]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment