• 自动化机器学习pycaret: PyCaret Basic Auto Classification LightGBM


    1. from IPython.display import clear_output
    2. !pip3 install pycaret --user
    3. clear_output()
    !pip install numpy==1.20.0
    
    1. import numpy as np
    2. import pandas as pd
    3. import random
    4. import os
    5. from pycaret.classification import *
    1. TRAIN_PATH = "../input/titanic/train.csv"
    2. TEST_PATH = "../input/titanic/test.csv"
    3. SAMPLE_SUBMISSION_PATH = "../input/titanic/gender_submission.csv"
    4. SUBMISSION_PATH = "submission.csv"
    5. ID = "PassengerId"
    6. TARGET = "Survived"
    7. SEED = 2022
    8. def seed_everything(seed: int = SEED):
    9. random.seed(seed)
    10. np.random.seed(seed)
    11. os.environ["PYTHONHASHSEED"] = str(seed)
    12. seed_everything()

    1. import pandas as pd
    2. train = pd.read_csv(TRAIN_PATH)
    3. test = pd.read_csv(TEST_PATH)
    4. test

     

     

     

    1. setup(
    2. data=train,
    3. target=TARGET,
    4. silent=True
    5. )

     

    ({'lr': ,
      'knn': ,
      'nb': ,
      'dt': ,
      'svm': ,
      'rbfsvm': ,
      'gpc': ,
      'mlp': ,
      'ridge': ,
      'rf': ,
      'qda': ,
      'ada': ,
      'gbc': ,
      'lda': ,
      'et': ,
      'xgboost': ,
      'lightgbm': ,
      'catboost': ,
      'dummy': },
     True,
     150    0
     547    1
     125    1
     779    1
     183    1
           ..
     370    1
     317    0
     351    0
     339    0
     289    1
     Name: Survived, Length: 623, dtype: int64,
     10,
     8860,
     '88e1',
     Pipeline(memory=None, steps=[('empty_step', 'passthrough')], verbose=False),
     False,
                Age       Fare  Pclass_1  Pclass_2  Pclass_3  \
     0    22.000000   7.250000       0.0       0.0       1.0   
     1    38.000000  71.283302       1.0       0.0       0.0   
     2    26.000000   7.925000       0.0       0.0       1.0   
     3    35.000000  53.099998       1.0       0.0       0.0   
     4    35.000000   8.050000       0.0       0.0       1.0   
     ..         ...        ...       ...       ...       ...   
     886  27.000000  13.000000       0.0       1.0       0.0   
     887  19.000000  30.000000       1.0       0.0       0.0   
     888  29.466112  23.450001       0.0       0.0       1.0   
     889  26.000000  30.000000       1.0       0.0       0.0   
     890  32.000000   7.750000       0.0       0.0       1.0   
     
          Name_Aks Mrs. Sam (Leah Rosen)  Name_Albimona Mr. Nassef Cassem  \
     0                               0.0                              0.0   
     1                               0.0                              0.0   
     2                               0.0                              0.0   
     3                               0.0                              0.0   
     4                               0.0                              0.0   
     ..                              ...                              ...   
     886                             0.0                              0.0   
     887                             0.0                              0.0   
     888                             0.0                              0.0   
     889                             0.0                              0.0   
     890                             0.0                              0.0   
     
          Name_Ali Mr. Ahmed  Name_Allen Mr. William Henry  \
     0                   0.0                           0.0   
     1                   0.0                           0.0   
     2                   0.0                           0.0   
     3                   0.0                           0.0   
     4                   0.0                           1.0   
     ..                  ...                           ...   
     886                 0.0                           0.0   
     887                 0.0                           0.0   
     888                 0.0                           0.0   
     889                 0.0                           0.0   
     890                 0.0                           0.0   
    model = create_model('lightgbm')

    tuneModel = tune_model(model,optimize = 'AUC')

     

    plot_model(tuneModel)

     

    plot_model(tuneModel, plot='feature')

     

     

  • 相关阅读:
    Springboot项目中的异常处理与返回结果的统一
    Java八股文(Spring Security)
    Android 系统 使用blktrace的方法
    CPP-Templates-2nd--第二十章 基 于 类 型 属 性 的 重 载(Overloading on Type Properties)
    形态之间相互变换的两种方法
    微信小程序 ——入门介绍及简单的小程序编写
    logrus包学习(一)
    计算机网络整理-简称&缩写【期末复习|考研复习】
    文字的力量
    Java学习 --- 作用域
  • 原文地址:https://blog.csdn.net/sinat_37574187/article/details/126092161