<jupyter_start><jupyter_text>Load data and create dataframes<jupyter_code>root_df = pd.read_csv('../input/train.csv')
X = root_df.drop(['id', 'target'], axis=1)
y = root_df['target']
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)<jupyter_output><empty_output><jupyter_text>Data is imbalanced!So lets use the 'roc_auc' metric to account for this<jupyter_code>y.value_counts()<jupyter_output><empty_output><jupyter_text>Build a pipeline / classifier<jupyter_code>pipe = Pipeline(steps=[
    ('pre', None),
    ('feature_selection', None),
    ('clf', LogisticRegression(solver='liblinear')),
    ]
)

params = {  
    'pre': [
        None, StandardScaler(), MinMaxScaler(),
    ],
    'feature_selection': [
        None, 
        SelectFromModel(LogisticRegression()),
        SelectFromModel(XGBClassifier(n_estimators=500, max_depth=3)),

    ],
    'clf__penalty': ['l1', 'l2'],
    'clf__C': [000.1, 00.1, 0.1, 1, 10], 
    'clf__class_weight': [None, 'balanced']
}
clf = GridSearchCV(pipe, param_grid=params, scoring='roc_auc', cv=8, n_jobs=-1)<jupyter_output><empty_output><jupyter_text>Train and score classifier<jupyter_code>clf.fit(X_train, y_train)
clf.best_estimator_
roc_auc_score(y_test, clf.predict_proba(X_test)[:,1])<jupyter_output><empty_output><jupyter_text>Export Data<jupyter_code>test_df = pd.read_csv('../input/test.csv')
X = test_df.drop(['id'], axis=1)
predictions = clf.predict_proba(X)[:,1]
submission = {
    "id": test_df['id'],
    "target": predictions
}
submission = pd.DataFrame(submission)
submission.to_csv('submission.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16451810926949048, 'fraction_numerical': 0.01596071209330878, 'mean_word_length': 6.0562770562770565, 'pattern_counts': {'":': 2, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '566894', 'license': 'MIT', 'n_tokens_mistral': 653, 'n_tokens_neox': 630, 'n_words': 91, 'path': 'kernels/LogitModel.ipynb', 'repo_name': 'Jasper-Koops/Kaggle-Overfit2-Challenge', 'size': '1629'}