<jupyter_start><jupyter_text>sklearn.ensemble<jupyter_code>from sklearn.ensemble import VotingClassifier, VotingRegressor

kbest = SelectKBest(score_func=f_classif, k=1000)
pipe1 = Pipeline([('kbest', kbest), ('est', XGBClassifier(booster='gblinear'))])

rfc = ensemble.RandomForestClassifier(random_state=10, class_weight="balanced_subsample",
                                      criterion='gini', n_estimators=500, max_features='log2')
pipe2 = Pipeline([('kbest', kbest), ('est', rfc)])

tree_xgc = XGBClassifier(subsample=0.7)
pipe3 = Pipeline([('kbest', kbest), ('est', tree_xgc)])


voting = BinarizeTargetClassifier(
    VotingClassifier(estimators=[('pipe1', pipe1), ('pipe2', pipe2), ('pipe1', pipe3)],
                     voting='soft', n_jobs=2))

rval = cross_validate(voting, X, y, cv=cv, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])<jupyter_output><empty_output><jupyter_text>Tree algorithms<jupyter_code># RandomForestClassifier
model = ensemble.RandomForestClassifier(random_state=0, class_weight="balanced")
estimator = BinarizeTargetClassifier(model)

rval = rval_rfc = cross_validate(estimator, X, y, cv=cv, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])
# RandomForestClassifier
from sklearn.model_selection import ShuffleSplit
model = ensemble.RandomForestClassifier(random_state=10, class_weight="balanced_subsample",
                                        criterion='gini', n_estimators=500, max_features='log2')
estimator = BinarizeTargetClassifier(model)
cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=4, random_state=123)

rval = rval_rfc = cross_validate(estimator, X, y, cv=cv2, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])
from sklearn.feature_selection import SelectKBest, f_classif

kbest = SelectKBest(score_func=f_classif, k=300)
pipe = Pipeline([('kbest', kbest), ('est', ensemble.RandomForestClassifier(random_state=0))])

estimator = BinarizeTargetClassifier(pipe)

cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=2, random_state=123)
#estimator = StackingRegressor(regressors=[li_xgbc, b_li_xgbr], meta_regressor=tree_xgbc)
rval = rval_xgbc = cross_validate(estimator, X, y, cv=cv, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])
from sklearn.feature_selection import SelectKBest, f_classif, f_regression

kbest = SelectKBest(score_func=f_regression, k=1000)
pipe = Pipeline([('kbest', kbest), ('est', XGBRegressor())])

estimator = BinarizeTargetRegressor(pipe)

cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=4, random_state=999)
#estimator = StackingRegressor(regressors=[li_xgbc, b_li_xgbr], meta_regressor=tree_xgbc)
rval = rval_xgbc = cross_validate(estimator, X, y, cv=cv, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])
from sklearn.feature_selection import SelectKBest, f_classif, f_regression

kbest = SelectKBest(score_func=f_classif, k=1000)
pipe = Pipeline([('kbest', kbest), ('est', XGBClassifier())])

estimator = BinarizeTargetClassifier(pipe)

cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=4, random_state=999)
#estimator = StackingRegressor(regressors=[li_xgbc, b_li_xgbr], meta_regressor=tree_xgbc)
rval = rval_xgbc = cross_validate(estimator, X, y, cv=cv, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])
from sklearn.feature_selection import SelectKBest, f_classif, f_regression

kbest = SelectKBest(score_func=f_regression, k=2000)
pipe = Pipeline([('kbest', kbest), ('est', XGBRegressor())])

estimator = BinarizeTargetRegressor(pipe)

cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=4, random_state=999)
#estimator = StackingRegressor(regressors=[li_xgbc, b_li_xgbr], meta_regressor=tree_xgbc)
rval = rval_xgbc = cross_validate(estimator, X, y, cv=cv, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])<jupyter_output><empty_output><jupyter_text>Linear model<jupyter_code>from sklearn.feature_selection import SelectKBest, f_classif

kbest = SelectKBest(score_func=f_classif, k=1000)
pipe = Pipeline([('kbest', kbest), ('est', XGBClassifier(booster='gblinear', n_estimators=500))])

estimator = BinarizeTargetClassifier(pipe)

cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=4, random_state=999)

#estimator = StackingRegressor(regressors=[li_xgbc, b_li_xgbr], meta_regressor=tree_xgbc)
rval = rval_xgbc = cross_validate(estimator, X, y, cv=cv2, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])
from sklearn.feature_selection import SelectKBest, f_classif

kbest = SelectKBest(score_func=f_regression, k=1000)
pipe = Pipeline([('kbest', kbest), ('est', XGBRegressor(booster='gblinear', n_estimators=500))])

estimator = BinarizeTargetRegressor(pipe)

cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=4, random_state=999)

#estimator = StackingRegressor(regressors=[li_xgbc, b_li_xgbr], meta_regressor=tree_xgbc)
rval = rval_xgbc = cross_validate(estimator, X, y, cv=cv2, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])<jupyter_output><empty_output><jupyter_text>dart model<jupyter_code>from sklearn.feature_selection import SelectKBest, f_classif

kbest = SelectKBest(score_func=f_classif, k=10000)
pipe = Pipeline([('kbest', kbest), ('est', XGBClassifier(booster='dart'))])

estimator = BinarizeTargetClassifier(pipe)

cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=4, random_state=999)

#estimator = StackingRegressor(regressors=[li_xgbc, b_li_xgbr], meta_regressor=tree_xgbc)
rval = rval_xgbc = cross_validate(estimator, X, y, cv=cv2, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])
from sklearn.feature_selection import SelectKBest, f_classif

kbest = SelectKBest(score_func=f_regression, k=10000)
pipe = Pipeline([('kbest', kbest), ('est', XGBRegressor(booster='dart'))])

estimator = BinarizeTargetRegressor(pipe)

cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=4, random_state=999)

#estimator = StackingRegressor(regressors=[li_xgbc, b_li_xgbr], meta_regressor=tree_xgbc)
rval = rval_xgbc = cross_validate(estimator, X, y, cv=cv2, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])<jupyter_output><empty_output><jupyter_text>stacking<jupyter_code>from sklearn.feature_selection import SelectKBest, f_classif

kbest = BinarizeTargetTransformer(SelectKBest(score_func=f_classif, k=1000))

li_xgbc = XGBClassifier(booster='gblinear')

cv3 = OrderedKFold(n_splits=10)
stacking = StackingCVClassifier(classifiers=[li_xgbc], meta_classifier=li_xgbc, cv=cv3, use_features_in_secondary=True)

pipe = Pipeline([('kbest', kbest), ('est', BinarizeTargetClassifier(stacking))])

estimator = pipe

cv2 = RepeatedOrderedKFold(n_splits=5, n_repeats=4, random_state=999)

#estimator = StackingRegressor(regressors=[li_xgbc, b_li_xgbr], meta_regressor=tree_xgbc)
rval = rval_xgbc = cross_validate(estimator, X, y, cv=cv2, scoring=scoring, n_jobs=2)
rval, np.mean(rval['test_ap']), np.mean(rval['test_auc'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1413303332864576, 'fraction_numerical': 0.02179721558149346, 'mean_word_length': 9.352256186317321, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '436737', 'license': 'MIT', 'n_tokens_mistral': 2948, 'n_tokens_neox': 2836, 'n_words': 416, 'path': 'docs/Examples/drug_respons_02.ipynb', 'repo_name': 'bgruening/Galaxy-ML-1', 'size': '7111'}