Para ejecutar comandos de consola anteponer ! al comando, ejemplo "!ls"
Lista de comandos útiles:
Comando | Descripción |
---|---|
ls | lista directorios |
cd | cambia de directorio |
mkdir | crea un directorio |
cp | copia archivos |
rm | borra archivos y directorio (-r) |
less | ver archivos de texto con buscador |
head | ver encabezado de archivo de texto |
tail | ver cola de archivo de texto |
grep | buscar y filtrar con patrones en archivos de texto |
wc | cuenta líneas (y caracteres, etc) |
!ls
'Clase 1.ipynb' Demo.ipynb pokemon-images.zip README.md datasets pokemon-images pokemon-images.zip.1
Lenguaje interpretado con tipado dinámico, no hace falta declarar variables.
a = 1
En python la tabulación es importante:
if a==1:
print('a vale 1')
File "<ipython-input-3-0a8f996dde68>", line 2 print('a vale 1') ^ IndentationError: expected an indented block
if a==1:
print('a vale 1')
a vale 1
Las listas son muy práctica
lista = [1, 1, 2, 3, 5, 8]
print( "La lista tiene {} elementos".format(len(lista)) )
for numero in lista:
print(numero)
La lista tiene 6 elementos 1 1 2 3 5 8
print(type(lista))
print(type('hola'))
print(type(459865))
print()
print('Métodos de list',dir(lista))
print()
print('Métodos de string',dir('hola'))
<class 'list'> <class 'str'> <class 'int'> Métodos de list ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] Métodos de string ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
También hay un sistema de ayuda similar a R
?print
Para instalar paquetes utilizamos el comando de consola pip
!pip install seaborn
Para importar paquetes import. Se puede renombrar un paquete con as.
import seaborn as sns
sns
<module 'seaborn' from '/home/miles/.local/lib/python3.6/site-packages/seaborn/__init__.py'>
Numpy permite trabajar con vectores y matrices y realizar operaciones matemáticas. Funciona mucho mas rápido que las listas que vienen con python y es la base de todas las librerías de machine learning.
import numpy as np
# vector con 10 ceros
x = np.zeros(10)
display(x)
# vector con 5 unos
x = np.ones(5)
display(x)
# vector con rango de numeros entre 40 y 55 (no inclusive)
x = np.arange(40,55)
display(x)
# vector con 10 números equiespaciados entre 0 y 1
x = np.linspace(0,1,10)
display(x)
# vector aleatorio de 10 números entre 0 y 1
x = np.random.rand(10)
display(x)
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
array([1., 1., 1., 1., 1.])
array([40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54])
array([0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444, 0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ])
array([0.68684688, 0.20081978, 0.32017554, 0.42152803, 0.970249 , 0.94710546, 0.85051042, 0.36613208, 0.13358646, 0.50912163])
# operaciones entre vectores y números
x = np.arange(10)
display(x, x*10)
print()
# operaciones entre vectores
x = np.ones(10)
y = np.random.rand(10)
display(x,y,x + y)
print()
# aplicar funciones a vectores
x = np.linspace(0,1,10) #
y = np.sin(2*np.pi*x)
display(x,y)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90])
array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])
array([0.24673258, 0.42880556, 0.19525307, 0.77018979, 0.55701506, 0.73437819, 0.74690896, 0.59552292, 0.29233442, 0.65643889])
array([1.24673258, 1.42880556, 1.19525307, 1.77018979, 1.55701506, 1.73437819, 1.74690896, 1.59552292, 1.29233442, 1.65643889])
array([0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444, 0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ])
array([ 0.00000000e+00, 6.42787610e-01, 9.84807753e-01, 8.66025404e-01, 3.42020143e-01, -3.42020143e-01, -8.66025404e-01, -9.84807753e-01, -6.42787610e-01, -2.44929360e-16])
Hay varias formas de acceder a los elementos de un arreglo y también para asignarle valores
x = np.random.randint(0,9,(3,3))
display(x)
# seleccionado elemento en la fila 2 y la columna 3
display(x[1,2])
# seleccionando la fila 0 y todas las columnas
display(x[0,:])
# seleccionando la columna 0 y todas las columnas
display(x[:,0])
# seleccionando con lista de índices
display(x[[0,2],[2,1]])
# seleccionando con mascaras booleanas
display(x>4,x[x>4])
array([[8, 8, 1], [8, 2, 7], [6, 1, 0]])
7
array([8, 8, 1])
array([8, 8, 6])
array([1, 1])
array([[ True, True, False], [ True, False, True], [ True, False, False]])
array([8, 8, 8, 7, 6])
Lo mismos casos valen para asignar valores
x = np.zeros((3,3))
display(x)
# asignando un valor en la fila 2 y la columna 3
x[1,2] = 1
display(x)
# asignando un valor a todos los elementos de la fila 0
x[0,:] = 2
display(x)
# asignando un valor a todos los elementos de la columna 0
x[:,0] = 3
display(x)
# asignando con lista de índices
x[[0,2],[2,1]] = 4
display(x)
# asignando con mascaras booleanas
x[x==4] = 5
display(x)
array([[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]])
array([[0., 0., 0.], [0., 0., 1.], [0., 0., 0.]])
array([[2., 2., 2.], [0., 0., 1.], [0., 0., 0.]])
array([[3., 2., 2.], [3., 0., 1.], [3., 0., 0.]])
array([[3., 2., 4.], [3., 0., 1.], [3., 4., 0.]])
array([[3., 2., 5.], [3., 0., 1.], [3., 5., 0.]])
Matplotlib permite realizar gráficos a partir de vectores y matrices.
%matplotlib inline
import matplotlib.pyplot as plt
plt.figure()
plt.imshow(np.random.rand(10,10));
plt.colorbar()
plt.figure()
x = np.linspace(0,1,50)
y = np.sin(2*np.pi*x)
plt.plot(x,y);
Para eso vamos a usar la librería pandas
Si lo están usando desde el colab, primero descomentar y hacer esto:
!mkdir datasets
!wget -q https://gitlab.com/i3a/datasets/raw/master/datasets/pokemon.csv -O datasets/pokemon.csv
mkdir: cannot create directory ‘datasets’: File exists
import pandas as pd
df = pd.read_csv("datasets/pokemon.csv")
df
# | Name | Type 1 | Type 2 | Total | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 318 | 45 | 49 | 49 | 65 | 65 | 45 | 1 | False |
1 | 2 | Ivysaur | Grass | Poison | 405 | 60 | 62 | 63 | 80 | 80 | 60 | 1 | False |
2 | 3 | Venusaur | Grass | Poison | 525 | 80 | 82 | 83 | 100 | 100 | 80 | 1 | False |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 625 | 80 | 100 | 123 | 122 | 120 | 80 | 1 | False |
4 | 4 | Charmander | Fire | NaN | 309 | 39 | 52 | 43 | 60 | 50 | 65 | 1 | False |
5 | 5 | Charmeleon | Fire | NaN | 405 | 58 | 64 | 58 | 80 | 65 | 80 | 1 | False |
6 | 6 | Charizard | Fire | Flying | 534 | 78 | 84 | 78 | 109 | 85 | 100 | 1 | False |
7 | 6 | CharizardMega Charizard X | Fire | Dragon | 634 | 78 | 130 | 111 | 130 | 85 | 100 | 1 | False |
8 | 6 | CharizardMega Charizard Y | Fire | Flying | 634 | 78 | 104 | 78 | 159 | 115 | 100 | 1 | False |
9 | 7 | Squirtle | Water | NaN | 314 | 44 | 48 | 65 | 50 | 64 | 43 | 1 | False |
10 | 8 | Wartortle | Water | NaN | 405 | 59 | 63 | 80 | 65 | 80 | 58 | 1 | False |
11 | 9 | Blastoise | Water | NaN | 530 | 79 | 83 | 100 | 85 | 105 | 78 | 1 | False |
12 | 9 | BlastoiseMega Blastoise | Water | NaN | 630 | 79 | 103 | 120 | 135 | 115 | 78 | 1 | False |
13 | 10 | Caterpie | Bug | NaN | 195 | 45 | 30 | 35 | 20 | 20 | 45 | 1 | False |
14 | 11 | Metapod | Bug | NaN | 205 | 50 | 20 | 55 | 25 | 25 | 30 | 1 | False |
15 | 12 | Butterfree | Bug | Flying | 395 | 60 | 45 | 50 | 90 | 80 | 70 | 1 | False |
16 | 13 | Weedle | Bug | Poison | 195 | 40 | 35 | 30 | 20 | 20 | 50 | 1 | False |
17 | 14 | Kakuna | Bug | Poison | 205 | 45 | 25 | 50 | 25 | 25 | 35 | 1 | False |
18 | 15 | Beedrill | Bug | Poison | 395 | 65 | 90 | 40 | 45 | 80 | 75 | 1 | False |
19 | 15 | BeedrillMega Beedrill | Bug | Poison | 495 | 65 | 150 | 40 | 15 | 80 | 145 | 1 | False |
20 | 16 | Pidgey | Normal | Flying | 251 | 40 | 45 | 40 | 35 | 35 | 56 | 1 | False |
21 | 17 | Pidgeotto | Normal | Flying | 349 | 63 | 60 | 55 | 50 | 50 | 71 | 1 | False |
22 | 18 | Pidgeot | Normal | Flying | 479 | 83 | 80 | 75 | 70 | 70 | 101 | 1 | False |
23 | 18 | PidgeotMega Pidgeot | Normal | Flying | 579 | 83 | 80 | 80 | 135 | 80 | 121 | 1 | False |
24 | 19 | Rattata | Normal | NaN | 253 | 30 | 56 | 35 | 25 | 35 | 72 | 1 | False |
25 | 20 | Raticate | Normal | NaN | 413 | 55 | 81 | 60 | 50 | 70 | 97 | 1 | False |
26 | 21 | Spearow | Normal | Flying | 262 | 40 | 60 | 30 | 31 | 31 | 70 | 1 | False |
27 | 22 | Fearow | Normal | Flying | 442 | 65 | 90 | 65 | 61 | 61 | 100 | 1 | False |
28 | 23 | Ekans | Poison | NaN | 288 | 35 | 60 | 44 | 40 | 54 | 55 | 1 | False |
29 | 24 | Arbok | Poison | NaN | 438 | 60 | 85 | 69 | 65 | 79 | 80 | 1 | False |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
770 | 700 | Sylveon | Fairy | NaN | 525 | 95 | 65 | 65 | 110 | 130 | 60 | 6 | False |
771 | 701 | Hawlucha | Fighting | Flying | 500 | 78 | 92 | 75 | 74 | 63 | 118 | 6 | False |
772 | 702 | Dedenne | Electric | Fairy | 431 | 67 | 58 | 57 | 81 | 67 | 101 | 6 | False |
773 | 703 | Carbink | Rock | Fairy | 500 | 50 | 50 | 150 | 50 | 150 | 50 | 6 | False |
774 | 704 | Goomy | Dragon | NaN | 300 | 45 | 50 | 35 | 55 | 75 | 40 | 6 | False |
775 | 705 | Sliggoo | Dragon | NaN | 452 | 68 | 75 | 53 | 83 | 113 | 60 | 6 | False |
776 | 706 | Goodra | Dragon | NaN | 600 | 90 | 100 | 70 | 110 | 150 | 80 | 6 | False |
777 | 707 | Klefki | Steel | Fairy | 470 | 57 | 80 | 91 | 80 | 87 | 75 | 6 | False |
778 | 708 | Phantump | Ghost | Grass | 309 | 43 | 70 | 48 | 50 | 60 | 38 | 6 | False |
779 | 709 | Trevenant | Ghost | Grass | 474 | 85 | 110 | 76 | 65 | 82 | 56 | 6 | False |
780 | 710 | PumpkabooAverage Size | Ghost | Grass | 335 | 49 | 66 | 70 | 44 | 55 | 51 | 6 | False |
781 | 710 | PumpkabooSmall Size | Ghost | Grass | 335 | 44 | 66 | 70 | 44 | 55 | 56 | 6 | False |
782 | 710 | PumpkabooLarge Size | Ghost | Grass | 335 | 54 | 66 | 70 | 44 | 55 | 46 | 6 | False |
783 | 710 | PumpkabooSuper Size | Ghost | Grass | 335 | 59 | 66 | 70 | 44 | 55 | 41 | 6 | False |
784 | 711 | GourgeistAverage Size | Ghost | Grass | 494 | 65 | 90 | 122 | 58 | 75 | 84 | 6 | False |
785 | 711 | GourgeistSmall Size | Ghost | Grass | 494 | 55 | 85 | 122 | 58 | 75 | 99 | 6 | False |
786 | 711 | GourgeistLarge Size | Ghost | Grass | 494 | 75 | 95 | 122 | 58 | 75 | 69 | 6 | False |
787 | 711 | GourgeistSuper Size | Ghost | Grass | 494 | 85 | 100 | 122 | 58 | 75 | 54 | 6 | False |
788 | 712 | Bergmite | Ice | NaN | 304 | 55 | 69 | 85 | 32 | 35 | 28 | 6 | False |
789 | 713 | Avalugg | Ice | NaN | 514 | 95 | 117 | 184 | 44 | 46 | 28 | 6 | False |
790 | 714 | Noibat | Flying | Dragon | 245 | 40 | 30 | 35 | 45 | 40 | 55 | 6 | False |
791 | 715 | Noivern | Flying | Dragon | 535 | 85 | 70 | 80 | 97 | 80 | 123 | 6 | False |
792 | 716 | Xerneas | Fairy | NaN | 680 | 126 | 131 | 95 | 131 | 98 | 99 | 6 | True |
793 | 717 | Yveltal | Dark | Flying | 680 | 126 | 131 | 95 | 131 | 98 | 99 | 6 | True |
794 | 718 | Zygarde50% Forme | Dragon | Ground | 600 | 108 | 100 | 121 | 81 | 95 | 95 | 6 | True |
795 | 719 | Diancie | Rock | Fairy | 600 | 50 | 100 | 150 | 100 | 150 | 50 | 6 | True |
796 | 719 | DiancieMega Diancie | Rock | Fairy | 700 | 50 | 160 | 110 | 160 | 110 | 110 | 6 | True |
797 | 720 | HoopaHoopa Confined | Psychic | Ghost | 600 | 80 | 110 | 60 | 150 | 130 | 70 | 6 | True |
798 | 720 | HoopaHoopa Unbound | Psychic | Dark | 680 | 80 | 160 | 60 | 170 | 130 | 80 | 6 | True |
799 | 721 | Volcanion | Fire | Water | 600 | 80 | 110 | 120 | 130 | 90 | 70 | 6 | True |
800 rows × 13 columns
# Las dimensiones de mi dataframe
display(df.shape)
# Qué columnas tengo
display(df.columns)
# Si quiero ver sólo una columna (los primeros 5)
display(df.Name[0:5]) # o también df["Name"]
# Si queremos acceder a los datos por posición en el dataframe usamos "loc"
display(df.loc[0:2])
display(df.loc[0])
(800, 13)
Index(['#', 'Name', 'Type 1', 'Type 2', 'Total', 'HP', 'Attack', 'Defense', 'Sp. Atk', 'Sp. Def', 'Speed', 'Generation', 'Legendary'], dtype='object')
0 Bulbasaur 1 Ivysaur 2 Venusaur 3 VenusaurMega Venusaur 4 Charmander Name: Name, dtype: object
# | Name | Type 1 | Type 2 | Total | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 318 | 45 | 49 | 49 | 65 | 65 | 45 | 1 | False |
1 | 2 | Ivysaur | Grass | Poison | 405 | 60 | 62 | 63 | 80 | 80 | 60 | 1 | False |
2 | 3 | Venusaur | Grass | Poison | 525 | 80 | 82 | 83 | 100 | 100 | 80 | 1 | False |
# 1 Name Bulbasaur Type 1 Grass Type 2 Poison Total 318 HP 45 Attack 49 Defense 49 Sp. Atk 65 Sp. Def 65 Speed 45 Generation 1 Legendary False Name: 0, dtype: object
display( df[ df.Name == "Pikachu" ] )
display( df[ (df.Legendary == True) & ( df["Type 1"] == "Ice" ) ] ) #legendario de hielo
display( df[ df.Name.str.contains( "saur" ) ][ ["Name","Attack","Defense"] ] ) #operaciones sobre str y elegir columnas
display( df[ df.Speed.isin([120,130]) ] )
# | Name | Type 1 | Type 2 | Total | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
30 | 25 | Pikachu | Electric | NaN | 320 | 35 | 55 | 40 | 50 | 50 | 90 | 1 | False |
# | Name | Type 1 | Type 2 | Total | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
156 | 144 | Articuno | Ice | Flying | 580 | 90 | 85 | 100 | 95 | 125 | 85 | 1 | True |
415 | 378 | Regice | Ice | NaN | 580 | 80 | 50 | 100 | 100 | 200 | 50 | 3 | True |
Name | Attack | Defense | |
---|---|---|---|
0 | Bulbasaur | 49 | 49 |
1 | Ivysaur | 62 | 63 |
2 | Venusaur | 82 | 83 |
3 | VenusaurMega Venusaur | 100 | 123 |
# | Name | Type 1 | Type 2 | Total | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
56 | 51 | Dugtrio | Ground | NaN | 405 | 35 | 80 | 50 | 50 | 70 | 120 | 1 | False |
70 | 65 | Alakazam | Psychic | NaN | 500 | 55 | 50 | 45 | 135 | 95 | 120 | 1 | False |
102 | 94 | GengarMega Gengar | Ghost | Poison | 600 | 60 | 65 | 80 | 170 | 95 | 130 | 1 | False |
146 | 135 | Jolteon | Electric | NaN | 525 | 65 | 65 | 60 | 110 | 95 | 130 | 1 | False |
153 | 142 | Aerodactyl | Rock | Flying | 515 | 80 | 105 | 65 | 60 | 75 | 130 | 1 | False |
162 | 150 | Mewtwo | Psychic | NaN | 680 | 106 | 110 | 90 | 154 | 90 | 130 | 1 | True |
163 | 150 | MewtwoMega Mewtwo X | Psychic | Fighting | 780 | 106 | 190 | 100 | 154 | 100 | 130 | 1 | True |
183 | 169 | Crobat | Poison | Flying | 535 | 85 | 90 | 80 | 70 | 80 | 130 | 2 | False |
274 | 254 | Sceptile | Grass | NaN | 530 | 70 | 85 | 65 | 105 | 85 | 120 | 3 | False |
409 | 373 | SalamenceMega Salamence | Dragon | Flying | 700 | 95 | 145 | 130 | 120 | 90 | 120 | 3 | False |
552 | 493 | Arceus | Normal | NaN | 720 | 120 | 120 | 120 | 120 | 120 | 120 | 4 | True |
Si lo están usando desde el colab, primero descomentar y hacer esto:
!wget -q https://gitlab.com/i3a/datasets/raw/master/datasets/pokemon-images.zip -O datasets/pokemon-images.zip
!ls datasets
!unzip -o datasets/pokemon-images.zip -d datasets/
Vamos a leer cada archivo de imagen y hacernos una matriz en numpy
from glob import glob
from pathlib import Path
fileList = glob("datasets/pokemon-images/*.png")
imgs = []
img_names = []
for i, f in enumerate(fileList):
img_names.append(Path(f).stem)
img = plt.imread(f)
imgs.append(img)
imgs = np.array(imgs)
imgs.shape
(819, 256, 256, 4)
import random
plt.figure(figsize=(12,12))
for i,k in enumerate(random.sample(range(imgs.shape[0]), 9)):
plt.subplot(3,3,i+1)
plt.imshow(imgs[k])
plt.axis('off')
plt.tight_layout()
!wget -q https://gitlab.com/i3a/datasets/raw/master/datasets/Pokemon-Cries-1st-Generation.zip -O datasets/Pokemon-Cries-1st-Generation.zip
!unzip -o datasets/Pokemon-Cries-1st-Generation.zip -d datasets/
# !pip install librosa
from IPython.display import Audio
import librosa
file_list = glob("datasets/pokemon-sounds/*.wav")
sounds = []
sound_names = []
for i, f in enumerate(file_list):
sound_names.append(Path(f).stem)
snd,sr = librosa.load(f, sr=None)
sounds.append(snd)
sounds = np.array(sounds)
sounds.shape
(165,)
for i,k in enumerate(random.sample(range(sounds.shape[0]), 9)):
display(sound_names[k])
display(Audio(sounds[k],rate = sr))
'145 - Zapdos'
'006 - Charizard'
'066 - Machop'
'049 - Venomoth'
'103 - Exeggutor'
'021 - Spearow'
'127M - Pinsir (Mega)'
'005 - Charmeleon'
'151 - Mew'
df.describe()
# | Total | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | |
---|---|---|---|---|---|---|---|---|---|
count | 800.000000 | 800.00000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.00000 |
mean | 362.813750 | 435.10250 | 69.258750 | 79.001250 | 73.842500 | 72.820000 | 71.902500 | 68.277500 | 3.32375 |
std | 208.343798 | 119.96304 | 25.534669 | 32.457366 | 31.183501 | 32.722294 | 27.828916 | 29.060474 | 1.66129 |
min | 1.000000 | 180.00000 | 1.000000 | 5.000000 | 5.000000 | 10.000000 | 20.000000 | 5.000000 | 1.00000 |
25% | 184.750000 | 330.00000 | 50.000000 | 55.000000 | 50.000000 | 49.750000 | 50.000000 | 45.000000 | 2.00000 |
50% | 364.500000 | 450.00000 | 65.000000 | 75.000000 | 70.000000 | 65.000000 | 70.000000 | 65.000000 | 3.00000 |
75% | 539.250000 | 515.00000 | 80.000000 | 100.000000 | 90.000000 | 95.000000 | 90.000000 | 90.000000 | 5.00000 |
max | 721.000000 | 780.00000 | 255.000000 | 190.000000 | 230.000000 | 194.000000 | 230.000000 | 180.000000 | 6.00000 |
import seaborn as sns
sns.pairplot(df[df.columns[df.dtypes=='int64']])
<seaborn.axisgrid.PairGrid at 0x7f2e1e2e6710>
Histogramas por color
c = ['r','g','b']
for j in range(10):
plt.figure(figsize=(12,4))
plt.subplot(1,2,1)
plt.imshow(imgs[j])
plt.axis('off')
plt.subplot(1,2,2)
for i in range(3):
values, bins = np.histogram(imgs[j,:,:,i].flatten(),20)
plt.semilogy(bins[1:-1], values[1:],color=c[i])
Imagen promedio
m = np.mean(imgs[:,:,:,:3],0)
s = np.std(imgs[:,:,:,:3],0)
plt.figure(figsize=(14,14))
plt.subplot(1,2,1)
plt.imshow(m);
plt.subplot(1,2,2)
plt.imshow(s);
¿Dónde está pikachu?
keyPikachu = str(int(df[ df.Name == "Pikachu" ]["#"]))
imgsIndexes = list(map(lambda x: x[x.rfind("/")+1:-4], fileList ))
plt.imshow( imgs[ imgsIndexes.index(keyPikachu)] )
plt.axis('off')
print('Acá tá!')
Acá tá!