<jupyter_start><jupyter_text>LightGBM模型<jupyter_code>import pandas as pd
from lightgbm import LGBMClassifier
from sklearn.model_selection import GridSearchCV
import seaborn as sb
from sklearn.metrics import roc_auc_score, plot_roc_curve, classification_report
from matplotlib import pyplot as plt
from yellowbrick.classifier.rocauc import roc_auc
X = pd.read_csv('datasets/X.csv', index_col='id')
X_t = pd.read_csv('datasets/X_t.csv', index_col='id')
y = pd.read_csv('datasets/y.csv', index_col='id')
y_t = pd.read_csv('datasets/y_t.csv', index_col='id')
m = GridSearchCV(
    LGBMClassifier(),
    cv=3,
    verbose=2,
    param_grid={
        "num_leaves": [20, 30, 40],
        "n_estimators": [50, 100],
        "min_child_samples": [20, 30]
    }
)
m.fit(X, y)
m.best_estimator_
lightgbm_model = m.best_estimator_.fit(X, y)
roc_auc_score(y_t, lightgbm_model.predict_proba(X_t)[:, 1])
plot_roc_curve(lightgbm_model, X_t, y_t)
plt.show()
visualizer = roc_auc(lightgbm_model, X, y, classes=[0, 1])
visualizer.score(X_t, y_t)
visualizer.show()
print(classification_report(y_t, lightgbm_model.predict(X_t)))<jupyter_output>precision    recall  f1-score   support

           0       0.70      0.68      0.69     59612
           1       0.69      0.71      0.70     60388

    accuracy                           0.69    120000
   macro avg       0.69      0.69      0.69    120000
weighted avg       0.69      0.69      0.69    120000
{'fraction_non_alphanumeric': 0.11366806136680614, 'fraction_numerical': 0.06276150627615062, 'mean_word_length': 3.1235632183908044, 'pattern_counts': {'":': 3, '<': 4, '<?xml version=': 0, '>': 4, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '660874', 'license': 'MIT', 'n_tokens_mistral': 613, 'n_tokens_neox': 559, 'n_words': 112, 'path': 'tabular-playground-series-nov-2021/step.3.lightgbm.ipynb', 'repo_name': 'threecifanggen/kaggle-practice', 'size': '1434'}