# Ceteris Lab downloadable Python script
# Course: Fundamentals of Python for Financial Econometrics

import numpy as np

x = np.array([1., 2., 3., 4.])
y = 2.5 * x
slope = 0.0
learning_rate = 0.02
for _ in range(500):
    gradient = -2 * np.mean(x * (y - slope*x))
    slope -= learning_rate * gradient
print(round(slope, 4))

from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import Ridge

pipeline = Pipeline([
    ("scale", StandardScaler()),
    ("model", Ridge(alpha=1.0)),
])
print([name for name, _ in pipeline.steps])

import numpy as np
x = np.array([1., 2., 3., 4.])
gradient = -2 * np.mean(x * (y - slope*x))
print(round(slope, 4))
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
