IIS_2023_1/malkova_anastasia_lab_5/lasso_test.py
2023-11-17 00:28:29 +04:00

18 lines
485 B
Python

from scores import MAPE
from sklearn.linear_model import Lasso
def lasso_test(X_train, X_test, y_train, y_test, alpha):
lasso = Lasso(alpha=alpha)
# Train model
lasso.fit(X_train, y_train)
# Show score of model
lasso_predict = lasso.predict(X_test)
lasso_MAPE = MAPE(y_test, lasso_predict)
print("MAPE value: ", lasso_MAPE)
Accuracy = 100 - lasso_MAPE
print(
'Accuracy of Lasso Regression(alpha={:}): {:0.2f}%.'.format(alpha, Accuracy))