Skip to content

Instantly share code, notes, and snippets.

View xiaowei1234's full-sized avatar

Xiao Wei xiaowei1234

View GitHub Profile
pl = Pipeline([
('impute', Imputer(strategy='median'))
, ('standardize', StandardScaler())
# , ('interactions', PolynomialFeatures(include_bias=False))
, ('clf', SGDClassifier())
])
alpha = [0.0001, 0.001, 0.1]
@xiaowei1234
xiaowei1234 / sklearn2pmml_pipe.py
Created November 8, 2018 00:24
sklearn2pmml pipe
pl = PMMLPipeline([
('featureUnion', featureU)
, ('impute', Imputer(strategy='median'))
, ('standardize', StandardScaler())
# , ('interactions', PolynomialFeatures(include_bias=False))
# , ('clf', SGDClassifier(alpha=0.008, l1_ratio=0.13, max_iter=450,loss='log'
# ,penalty='elasticnet', n_iter=None, tol=None))# alpha = 0.8
, ('clf', LogisticRegression(penalty='l2', max_iter=500, C=0.8))
])
@xiaowei1234
xiaowei1234 / sklearn2pmml features.py
Last active November 8, 2018 00:18
sklearn2pmml feature engineering and creation
featureU = FeatureUnion([
('transformations', DataFrameMapper([
(trend_vars, ExpressionTransformer("X[:, 0] - X[:, 1]"))
, (to_logs, make_pipeline(Imputer(strategy='median')
, FunctionTransformer(np.log1p)
))
])
)
, ('identity', DataFrameMapper([(non_trans_vars, ContinuousDomain())]))
])