Modelo ML Reconocimiento Digitos
Enviado por bery • 13 de Octubre de 2023 • Tarea • 8.765 Palabras (36 Páginas) • 198 Visitas
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.core.display import HTML\n",
"HTML(\"\\n\".join(open('mioti_style.css', 'r').readlines()))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"mioti.png\" style=\"height: 100px\">\n",
"<center style=\"color:#888\">Módulo Data Science in IoT<br/>Asignatura Machine Learning</center>\n",
"# Challenge S2: Reconocimiento de dígitos"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Objetivo\n",
"\n",
"Implementar un reconocedor de dígitos manuscritos."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Configuración del entorno"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\")\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from sklearn.metrics import confusion_matrix"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"## Carga de datos\n",
"\n",
"En esta ocasión vamos a utilizar una dataset denominado 'digits' que contiene imágenes de números manuscritos.\n",
"\n",
"Este dataset está disponible dentro de los datasets de `sklearn` y podemos cargarlo en memoria de la siguiente manera:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.datasets import load_digits\n",
"digits = load_digits()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'data': array([[ 0., 0., 5., ..., 0., 0., 0.],\n",
" [ 0., 0., 0., ..., 10., 0., 0.],\n",
" [ 0., 0., 0., ..., 16., 9., 0.],\n",
" ...,\n",
" [ 0., 0., 1., ..., 6., 0., 0.],\n",
" [ 0., 0., 2., ..., 12., 0., 0.],\n",
" [ 0., 0., 10., ..., 12., 1., 0.]]), 'target': array([0, 1, 2, ..., 8, 9, 8]), 'target_names': array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), 'images': array([[[ 0., 0., 5., ..., 1., 0., 0.],\n",
" [ 0., 0., 13., ..., 15., 5., 0.],\n",
" [ 0., 3., 15., ..., 11., 8., 0.],\n",
...