Created
November 8, 2018 00:33
-
-
Save xiaowei1234/7c8a6d585802366a411e30cccf43e973 to your computer and use it in GitHub Desktop.
This file contains 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
pl = Pipeline([ | |
('impute', Imputer(strategy='median')) | |
, ('standardize', StandardScaler()) | |
# , ('interactions', PolynomialFeatures(include_bias=False)) | |
, ('clf', SGDClassifier()) | |
]) | |
alpha = [0.0001, 0.001, 0.1] | |
l1_ratio = [0.1, 0.2, 0.4] | |
C_options = [0.2, 0.4, 0.6, 0.8] | |
param_grid = [ | |
{ | |
'clf': [SGDClassifier(penalty='elasticnet', max_iter=500, loss='log')] | |
, 'clf__l1_ratio': l1_ratio | |
, 'clf__alpha': alpha | |
}, | |
{'clf': [LogisticRegression(penalty='l2', max_iter=500)] | |
, 'clf__C': C_options | |
} | |
] | |
grid = GridSearchCV(pl, param_grid=param_grid, scoring={'auc': auc_scorer, 'log': log_scorer} | |
, refit='log', cv=6, verbose=5, return_train_score=True, n_jobs=2) | |
pmml_pipe = make_pmml_pipeline(grid, X.columns.values, y.name) | |
sklearn2pmml(pmml_pipe, 'pmml_model.pmml', with_repr=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment