Created
November 28, 2022 09:21
-
-
Save naenumtou/93dbf7661c46966f10150a5f68ca404e to your computer and use it in GitHub Desktop.
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
# 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