Skip to content

Instantly share code, notes, and snippets.

View robintux's full-sized avatar

Abraham Zamudio Chauca robintux

  • GMMNS
  • Lima - Peru
View GitHub Profile
@robintux
robintux / funciones_auxiliares.py
Created April 2, 2024 16:37
Clase 17 : Series de tiempo (EPC)
# 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)
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"), #
try:
f = open('fichero.txt') # El fichero no existe
except ... :
print('¡El fichero no existe!')
else:
print(f.read())
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")
# 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
<!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>
@robintux
robintux / MostrarValores.py
Created July 21, 2022 17:47
Funcion para mostrar la altura de las barras en un sns.barplot
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:
@robintux
robintux / visualizar_clasificador.py
Created April 11, 2022 02:24
visualizar_clasificador
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()])
@robintux
robintux / repasopython.ipynb
Last active November 26, 2021 22:02
RepasoPython.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@robintux
robintux / Data4SeS.py
Created September 26, 2021 00:04
Data para pruebas de SES
data = [
446.6565,
454.4733,
455.663,
423.6322,
456.2713,
440.5881,
425.3325,
485.1494,