<jupyter_start><jupyter_text>Voting Classifier<jupyter_code>%run pipeline_utils.ipynb
# from sklearn import model_selection
# from sklearn.linear_model import LogisticRegression
# from sklearn.naive_bayes import GaussianNB 
from sklearn.ensemble import RandomForestClassifier
# from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import VotingClassifier
from sklearn.svm import SVC
# from sklearn.metrics import roc_curve, auc

# clf1 = LogisticRegression(random_state=1)
# clf2 = RandomForestClassifier(random_state=1)
# clf3 = GaussianNB()
svmPipeline = Pipeline([
#     ("preprocess", preprocess),
    ("svm", SVC(probability=True))
])

mlpPipeline = Pipeline([
#     ('preprocess', preprocess),
    ('mlp', mlp.MLPClassifier())
])

rfPipeline = Pipeline([
#     ("preprocess", preprocess),
    ("rfc", RandomForestClassifier())
])

xgbPipeline = Pipeline([
#     ("preprocess", preprocess),
    # best params found after doing grid search on XG boost
    ("xgb", xgb.XGBClassifier(max_depth=5,subsample=0.6,colsample_bytree=1.0,gamma=2,min_child_weight=1))
])


estimators = [
    ('mlp', mlpPipeline),
    ('xgb', xgbPipeline),
    ('svm', svmPipeline)
]

# classifier = VotingClassifier(estimators,voting='soft',weights=[2,2,1])
# classifier.fit(Xtr,Ytr.ravel())

votingPipeline = Pipeline([
    ("preprocess", preprocess),
    ("VC", VotingClassifier(estimators,voting='soft',weights=[3,2,1]))
])

votingPipeline.fit(Xtr,Ytr.ravel())
# eclf = VotingClassifier(clfs=[clf1, clf2, clf3], voting='soft',weights=[1,1,1])
# labels = ['Logistic Regression', 'Random Forest', 'Naive Bayes']

# eclf.fit(Xtr,Ytr)
# pred = eclf.predict(Xva)
# print("Score: ",np.mean(pred==Yva))

auc(votingPipeline, Xtr, Ytr)
auc(votingPipeline, Xva, Yva)
auc(votingPipeline,Xts,Yts)
# import joblib
# joblib.dump(votingPipeline, 'voting_model.pkl', compress=1)
# votingPipeline = joblib.load('voting_model.pkl')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14992272024729522, 'fraction_numerical': 0.01287995878413189, 'mean_word_length': 6.498069498069498, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '302803', 'license': 'MIT', 'n_tokens_mistral': 722, 'n_tokens_neox': 709, 'n_words': 124, 'path': 'adult/voting_pipeline.ipynb', 'repo_name': 'clyton/uci-cs273p-project', 'size': '1941'}