This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gráfico de correlograma | |
def plot_correlogram(x, lags=None, title=None): | |
lags = min(10, int(len(x)/5)) if lags is None else lags | |
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(14, 8)) | |
x.plot(ax=axes[0][0], title='Time Series') | |
x.rolling(21).mean().plot(ax=axes[0][0], c='k', lw=1) | |
q_p = np.max(q_stat(acf(x, nlags=lags), len(x))[1]) | |
stats = f'Q-Stat: {np.max(q_p):>8.2f}\nADF: {adfuller(x)[1]:>11.2f}' | |
axes[0][0].text(x=.02, y=.85, s=stats, transform=axes[0][0].transAxes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
patrones = [ | |
(r"[Aa]m$", "BEM"), # irregular forms of 'to be' | |
(r"[Aa]re$", "BER"), # | |
(r"[Ii]s$", "BEZ"), # | |
(r"[Ww]as$", "BEDZ"), # | |
(r"[Ww]ere$", "BED"), # | |
(r"[Bb]een$", "BEN"), # | |
(r"[Hh]ave$", "HV"), # irregular forms of 'to have' | |
(r"[Hh]as$", "HVZ"), # | |
(r"[Hh]ad$", "HVD"), # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
f = open('fichero.txt') # El fichero no existe | |
except ... : | |
print('¡El fichero no existe!') | |
else: | |
print(f.read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Perro: | |
# El método __init__ es llamado al crear el objeto | |
def __init__(self, nombre, raza): | |
print(f"Creando perro {nombre}, {raza}") | |
# Atributos de instancia | |
self.nombre = nombre | |
self.raza = raza | |
mi_perro = Perro("Toby", "Bulldog") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instalamos el jdk (java) | |
!apt-get install openjdk-8-jdk-headless -qq > /dev/null | |
# Descargamos spark | |
!wget https://dlcdn.apache.org/spark/spark-3.4.0/spark-3.4.0-bin-hadoop3.tgz | |
# Descomprimimos el binario de spark | |
!tar xvzf spark-3.4.0-bin-hadoop3.tgz | |
# Cargamos el modulo os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1>My First Heading</h1> | |
<h3>My Third Heading</h3> | |
<div id ="names"> | |
<ul> | |
<li>Liam James</li> | |
<li>William Jones</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_values(axs, orient="v", space=.01): | |
def _single(ax): | |
if orient == "v": | |
for p in ax.patches: | |
_x = p.get_x() + p.get_width() / 2 | |
_y = p.get_y() + p.get_height() + (p.get_height()*0.01) | |
value = '{:.1f}'.format(p.get_height()) | |
ax.text(_x, _y, value, ha="center") | |
elif orient == "h": | |
for p in ax.patches: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def visualizar_clasificador(clasificador, X, y): | |
#definimos los máximos valores de X e y para la malla | |
min_x, max_x = X[:, 0].min() - 1.0, X[:, 0].max() + 1.0 | |
min_y, max_y = X[:, 1].min() - 1.0, X[:, 1].max() + 1.0 | |
#definimos el paso de la malla | |
mesh_step_size = 0.01 | |
#definimos la malla para x e y | |
x_vals, y_vals = np.mgrid[min_x:max_x:mesh_step_size, min_y:max_y:mesh_step_size] | |
#corremos el clasificador sobre la malla | |
resultados = clasificador.predict(np.c_[x_vals.ravel(), y_vals.ravel()]) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [ | |
446.6565, | |
454.4733, | |
455.663, | |
423.6322, | |
456.2713, | |
440.5881, | |
425.3325, | |
485.1494, |
NewerOlder