Skip to content

Instantly share code, notes, and snippets.

@naenumtou
Created November 28, 2022 09:21
Show Gist options
  • Save naenumtou/93dbf7661c46966f10150a5f68ca404e to your computer and use it in GitHub Desktop.
Save naenumtou/93dbf7661c46966f10150a5f68ca404e to your computer and use it in GitHub Desktop.
# Set auto reload
%reload_ext autoreload
%autoreload 2
# Import libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_regression
from sklearn.linear_model import LinearRegression, TheilSenRegressor
# Config
%config InlineBackend.figure_format = 'retina' #Retina display
plt.style.use('seaborn-deep') #Plot style
# Create regression data
X, y = make_regression(
n_samples = 150,
n_features = 1,
noise = 5
)
# Add outlier
for j in range(15):
X = np.append(
X, np.random.choice(X.flatten())
)
y = np.append(
y, np.random.choice(y.flatten())
)
X = X.reshape(-1,1)
y = y.reshape(-1,1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment