scikit learn elastic net

Solutions on MaxInterview for scikit learn elastic net by the best coders in the world

showing results for - "scikit learn elastic net"
Lohan
31 Jul 2016
1from sklearn.linear_model import ElasticNet
2EN = ElasticNet(random_state=0)
3EN.fit(X, y)
4EN.score(X, y) #Return the mean accuracy on the given test data and labels
5EN.predict(X) #Return the predictions
6
7#Regression Metrics
8#Mean Absolute Error
9
10from sklearn.metrics import mean_absolute_error 
11mean_absolute_error(y_true, y_pred)
12
13#Mean Squared Error
14
15from sklearn.metrics import mean_squared_error
16mean_squared_error(y_true, p_pred)
17
18#R2 Score
19
20from sklearn.metrics import r2_score
21r2_score(y_true, y_pred)
22
23#If you like the answer, please upvote -;)