This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wrap1 = DataFrameMapper([ | |
('col_with_nulls', ExpressionTransformer("0 if pandas.isnull(X[0]) else 1") | |
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.linear_model import PoissonRegressor, Lasso | |
X_array = np.asarray([[1, 2], [1, 3], [1, 4], [1, 3]]) | |
y = np.asarray([2, 2, 3, 2]) | |
Preg_alpha_1 = PoissonRegressor(alpha=1., fit_intercept=False).fit(X_array, y) | |
print('alpha 1', Preg_alpha_1.coef_) | |
Preg_alpha_2 = PoissonRegressor(alpha=2., fit_intercept=False).fit(X_array/2., y) | |
print('alpha 2', Preg_alpha_2.coef_) | |
Lreg_alpha_1 = Lasso(alpha=1., fit_intercept=False).fit(X_array, y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.linear_model import PoissonRegressor, Lasso, Ridge | |
import statsmodels.api as sm | |
X_array = np.asarray([[1, 2], [1, 3], [1, 4], [1, 3]]) | |
y = np.asarray([2, 2, 3, 2]) | |
Preg_alpha_1 = PoissonRegressor(alpha=1., fit_intercept=False).fit(X_array, y) | |
print('alpha 1 Poisson Reg', Preg_alpha_1.coef_) | |
Preg_alpha_2 = PoissonRegressor(alpha=2., fit_intercept=False).fit(X_array*4., y) | |
print('alpha 2 Poisson Reg', Preg_alpha_2.coef_) |
OlderNewer