<jupyter_start><jupyter_text>Model evaluationWe can now rank our evaluation of all the models to choose the best one for our problem. While both Decision Tree and Random Forest score the same, we choose to use Random Forest as they correct for decision trees' habit of overfitting to their training set.<jupyter_code>models = pd.DataFrame({
    'Model': ['Support Vector Machines', 'KNN', 'Logistic Regression', 
              'Random Forest', 'Gaussian Naive Bayes', 
              'Stochastic Gradient Decent', 'Linear SVC', 
              'Decision Tree', 'MLP', 'Gradient Boosting','Extra Trees'],
    'Score': [acc_svc, acc_knn, acc_log, 
              acc_random_forest, acc_gaussian, 
              acc_sgd, acc_linear_svc, acc_decision_tree, acc_mlp, acc_gradient_boosting,acc_extra_trees],
    'Score1': [acc_svc, acc_knn1, acc_log1, 
              acc_random_forest1, acc_gaussian, 
              acc_sgd1, acc_linear_svc, acc_decision_tree, acc_mlp1, acc_gradient_boosting1,acc_extra_trees1]})
models.sort_values(by='Score1', ascending=False)
# Ensemble of the "tuned" top models

classifiers=[
    ('svc', SVC(C=1000, gamma=0.001, probability=True, kernel='rbf')),
    ('linear_svc', SVC(kernel='linear', probability=True)),
    ('sgd', SGDClassifier(max_iter=1000, tol=1e-3, alpha=0.1,learning_rate='optimal',loss='modified_huber', penalty='l2')),
    ('gb', GradientBoostingClassifier(criterion='friedman_mse',max_depth=4,n_estimators=240)),
    ('lr', LogisticRegression(C=0.3,multi_class='multinomial', solver='lbfgs')),
    ('knn', KNeighborsClassifier(n_neighbors = 8)),
    ('mlp', MLPClassifier(solver='lbfgs', hidden_layer_sizes=(14,4,1), alpha=0.001, activation='tanh',learning_rate='adaptive')),
    ('ef', ExtraTreesClassifier(criterion='entropy',max_depth=5,n_estimators=240)),
    ('rf', RandomForestClassifier(criterion='gini',max_depth=4,n_estimators=240)),
]

    
voting=VotingClassifier(classifiers,voting="soft")
%time voting.fit(X_train, Y_train)
Y_pred=voting.predict(X_test)
%time acc_grid_search = (cross_val_score(voting, X_train, Y_train, cv=5, scoring="accuracy").mean()) * 100

print(acc_grid_search)

# Submission

# He didn't confess yet, but he will...


submission = pd.DataFrame({
        "PassengerId": test_df_tr["PassengerId"],
        "Survived": Y_pred
    })
submission.to_csv('submission.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13777219430485763, 'fraction_numerical': 0.02219430485762144, 'mean_word_length': 5.3537234042553195, 'pattern_counts': {'":': 2, '<': 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': '129956', 'license': 'MIT', 'n_tokens_mistral': 877, 'n_tokens_neox': 821, 'n_words': 163, 'path': 'Titanic/Titanic.ipynb', 'repo_name': 'directcsd/Kaggle', 'size': '2388'}