Usted está aquí: Inicio Ingeniería Informática Machine Learning I displayDigits.html


Acciones de Documento
  • Vista de contenidos
  • Marcadores (bookmarks)
  • Exportación de LTI
Autor: Ricardo Aler

Notebook for displaying and selecting SEMEION digits

In [ ]:
import matplotlib.pyplot as plt
import numpy as np
import os
In [2]:
instances = np.load("semeion_bin.npy")
In [3]:
def getDigits(label):
    """ Get all the instances for a particular label. Label 1 corresponds to digit '0', label 2 to digit '1', etc. """

# Apply function getDigits to list [1, 2, ..., 9] in order to get a list with 10 elements.
# Each element is another list that contains all instances with a particular label
# e.g. numbers[0] contains all zero instances
numbers = map(getDigits, range(1,10))
In [4]:
%matplotlib inline

# Let's plot four zeroes
# numbers[0][3] would access the fourth instance of digit '0'
# range [:-1] means get all attributes from 0 to 256
# equivalently: [:257]
for i in range(4):
In [5]:
%matplotlib inline

# Let's plot four eithts
for i in range(4):
In [6]:
%matplotlib inline

# Let's plot four threes
for i in range(4):
In [7]:
# Let's put together all instances of digits '0' and '8'
zeros_and_eights = np.vstack((numbers[0], numbers[8]))
In [8]:
# And save them to a numpy binary file"semeion_zeros_and_eights", zeros_and_eights)
In [ ]:
Reutilizar Curso
Descargar este curso
OCW-UC3M user survey