Skip to content

Instantly share code, notes, and snippets.

@erykml
Created August 30, 2022 20:38
Show Gist options
  • Save erykml/6143a1dfe6b2909c3788fb7063f60cb0 to your computer and use it in GitHub Desktop.
Save erykml/6143a1dfe6b2909c3788fb7063f60cb0 to your computer and use it in GitHub Desktop.
N_SAMPLES = 500
N_OUTLIERS = 25
X, y, coef = datasets.make_regression(
n_samples=N_SAMPLES,
n_features=1,
n_informative=1,
noise=20,
coef=True,
random_state=42
)
coef_list = [["original_coef", float(coef)]]
# add outliers
np.random.seed(42)
X[:N_OUTLIERS] = 10 + 0.75 * np.random.normal(size=(N_OUTLIERS, 1))
y[:N_OUTLIERS] = -15 + 20 * np.random.normal(size=N_OUTLIERS)
plt.scatter(X, y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment