Slide 16
Slide 16 text
ଟ߲ࣜճؼ
from sklearn.linear_model import LinearRegression, Lasso,
OrthogonalMatchingPursuit
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline
poly_preprocess = PolynomialFeatures(poly_dim, include_bias=False)
# models
linear = LinearRegression()
lasso = Lasso(alpha=0.002, max_iter=500000, tol=0.000001)
omp = OrthogonalMatchingPursuit(n_nonzero_coefs=5)
def fit_and_predict(predictor):
model = make_pipeline(poly_preprocess, predictor)
model.fit(x.reshape(-1, 1), y)
y_predicted = model.predict(x.reshape(-1, 1))
t_predicted = model.predict(t.reshape(-1, 1))
return y_predicted, t_predicted