1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        【機(jī)器學(xué)習(xí)】盤(pán)點(diǎn)Kaggle中常見(jiàn)的AutoML工具庫(kù)及用法

        共 4735字,需瀏覽 10分鐘

         ·

        2021-11-04 19:44

        在日常的Kaggle比賽和工作中,經(jīng)常會(huì)遇到AutoML工具。本文總結(jié)了常見(jiàn)的AutoML庫(kù),可供大家選擇。

        LightAutoML

        項(xiàng)目鏈接:https://github.com/sberbank-ai-lab/LightAutoML

        推薦指數(shù):???

        LightAutoML是基于Python環(huán)境下的結(jié)構(gòu)化自動(dòng)機(jī)器學(xué)習(xí)庫(kù),現(xiàn)在支持的任務(wù)有:

        • 二分類(lèi)
        • 多分類(lèi)
        • 回歸任務(wù)

        LightAutoML現(xiàn)在只支持單表單記錄的形式,即每一行由樣本的特征和標(biāo)簽組成。

        import?pandas?as?pd
        from?sklearn.metrics?import?f1_score

        from?lightautoml.automl.presets.tabular_presets?import?TabularAutoML
        from?lightautoml.tasks?import?Task

        df_train?=?pd.read_csv('../input/titanic/train.csv')
        df_test?=?pd.read_csv('../input/titanic/test.csv')

        automl?=?TabularAutoML(
        ????task?=?Task(
        ????????name?=?'binary',
        ????????metric?=?lambda?y_true,?y_pred:?f1_score(y_true,?(y_pred?>?0.5)*1))
        )
        oof_pred?=?automl.fit_predict(
        ????df_train,
        ????roles?=?{'target':?'Survived',?'drop':?['PassengerId']}
        )
        test_pred?=?automl.predict(df_test)

        pd.DataFrame({
        ????'PassengerId':df_test.PassengerId,
        ????'Survived':?(test_pred.data[:,?0]?>?0.5)*1
        }).to_csv('submit.csv',?index?=?False)

        H2O AutoML

        項(xiàng)目鏈接:https://docs.h2o.ai/h2o/latest-stable/h2o-docs/automl.html

        推薦指數(shù):????

        H2O AutoML是基于Python環(huán)境和R環(huán)境下的結(jié)構(gòu)化自動(dòng)機(jī)器學(xué)習(xí)庫(kù),支持分布式部署,對(duì)模型調(diào)參、模型選擇和特征篩選支持比較完備,但使用起來(lái)比較復(fù)雜。

        import?h2o
        from?h2o.automl?import?H2OAutoML

        h2o.init()
        train_hf?=?h2o.H2OFrame(train_df.copy())
        test_hf?=?h2o.H2OFrame(test_df.copy())

        train_hf[target_column]?=?train_hf[target_column].asfactor()

        aml?=?H2OAutoML(
        ????seed=2021,?
        ????max_runtime_secs=100,
        ????nfolds?=?3,
        ????exclude_algos?=?["DeepLearning"]
        )

        aml.train(
        ????x=list(feature_columns),?
        ????y=target_column,?
        ????training_frame=train_hf
        )

        preds?=?aml.predict(h2o.H2OFrame(test_df[feature_columns].copy()))
        preds_df?=?h2o.as_list(preds)
        preds_df

        submission[['Class_1',?'Class_2',?'Class_3',?'Class_4']]?=?preds_df[['Class_1',?'Class_2',?'Class_3',?'Class_4']]
        submission.to_csv('h2o_automl_300s.csv',?index=False)
        submission.head()

        MLJAR AutoML

        項(xiàng)目鏈接:https://github.com/mljar/mljar-supervised

        推薦指數(shù):????

        MLJAR AutoML是基于Python環(huán)境下的結(jié)構(gòu)化自動(dòng)機(jī)器學(xué)習(xí)庫(kù),所支持的機(jī)器學(xué)習(xí)模型非常多,且對(duì)模型可視化支持的非常好。

        from?supervised.automl?import?AutoML?#?mljar-supervised
        automl?=?AutoML(
        ????mode="Compete",?
        ????eval_metric="f1",
        ????total_time_limit=300,
        ????features_selection=False?#?switch?off?feature?selection
        )
        automl.fit(
        ????train[feature_cols],?
        ????train[target_column]
        )

        preds?=?automl.predict(test[feature_cols])

        submission['Survived']?=?preds
        submission.to_csv('mljar_automl_300s_f1_metric.csv',?index=False)
        submission.head()

        PyCaret

        項(xiàng)目鏈接:https://pycaret.org/

        推薦指數(shù):?????

        PyCaret是基于Python環(huán)境下的結(jié)構(gòu)化自動(dòng)機(jī)器學(xué)習(xí)庫(kù),支持的任務(wù)包括:

        • 分類(lèi)
        • 回歸
        • 聚類(lèi)
        • 異常檢測(cè)
        • NLP
        • 關(guān)聯(lián)規(guī)則

        PyCaret支持的模型比較多,項(xiàng)目也比較活躍,但對(duì)模型的可視化做的不夠。

        from?pycaret.classification?import?*
        from?category_encoders.cat_boost?import?CatBoostEncoder

        cat_train_df?=?train_df.copy()
        cat_test_df?=?test_df.copy()

        ce?=?CatBoostEncoder()

        cols_to_encode?=?['name',?'sex',?'ticket',?'cabin',?'embarked']
        cat_train_df[pure_cat_cols]?=?ce.fit_transform(cat_train_df[pure_cat_cols],?cat_train_df[target_column])
        cat_test_df[pure_cat_cols]?=?ce.transform(cat_test_df[pure_cat_cols])

        setup(
        ????data?=?cat_train_df[feature_cols.to_list()?+?[target_column]],?
        ????target?=?target_column,
        ????fold?=?3,
        ????silent?=?True,
        )

        best_models?=?compare_models(
        ????sort='F1',?
        ????n_select=3,?
        ????budget_time=300,
        )?#?we?will?use?it?later

        best?=?automl(optimize?=?'F1')

        EvalML: AutoML

        項(xiàng)目鏈接:https://evalml.alteryx.com/en/latest/

        推薦指數(shù):???

        EvalML是一款比較模塊比較完備的自動(dòng)機(jī)器學(xué)習(xí)框架,支持分類(lèi)、回歸和時(shí)間序列任務(wù)。但提出的時(shí)間稍晚,所以使用的人很少。

        from?evalml.automl?import?AutoMLSearch
        X?=?train_df.drop(columns=[target_column,?'passengerid'])
        y?=?train_df[target_column]

        X_train,X_test,y_train,y_test?=?train_test_split(X,?y,?test_size=0.2)
        automl?=?AutoMLSearch(
        ????X_train=X_train,?
        ????y_train=y_train,?
        ????problem_type='binary',
        ????random_seed=2021,
        ????max_time=300,
        )

        automl.search()
        pipeline?=?automl.best_pipeline
        pipeline.fit(X,?y)

        TPOT: Genetic Approach

        項(xiàng)目鏈接:http://epistasislab.github.io/tpot/

        推薦指數(shù):???

        TPOT是一款非常輕量級(jí)的自動(dòng)機(jī)器學(xué)習(xí)框架,利用遺傳算法可以快讀完成特征的構(gòu)造。但TPOT所支持的功能較少,所以場(chǎng)景有限。

        from?tpot?import?TPOTClassifier
        from?sklearn.model_selection?import?train_test_split

        tpot?=?TPOTClassifier(generations=5,?population_size=50,?verbosity=2,?random_state=42)
        tpot.fit(X_train,?y_train)
        print(tpot.score(X_test,?y_test))
        tpot.export('tpot_digits_pipeline.py')

        FLAML

        項(xiàng)目鏈接:https://github.com/microsoft/FLAML

        推薦指數(shù):????

        FLAML是由微軟提出的自動(dòng)機(jī)器學(xué)習(xí)庫(kù),支持分類(lèi)和回歸任務(wù)。FLAML對(duì)特征的構(gòu)造和搜索支持的比較好,非常輕量。

        from?flaml?import?AutoML
        from?sklearn.datasets?import?load_boston

        automl?=?AutoML()

        #?Specify?automl?goal?and?constraint
        automl_settings?=?{
        ????"time_budget":?300,??#?in?seconds
        ????"metric":?'accuracy',
        ????"task":?'classification',
        }
        automl.fit(
        ????X_train=train_df[feature_cols],?
        ????y_train=train_df[target_column],
        ????**automl_settings
        )

        print(automl.predict_proba(train_df[feature_cols]))

        往期精彩回顧




        站qq群554839127,加入微信群請(qǐng)掃碼:
        瀏覽 95
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
        評(píng)論
        圖片
        表情
        推薦
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            女人与拘性猛交高清视频 | 国产高清无码18 | 天天摸天天操视频 | 色爱无码综合网国产极品网红 | 又黄又刺激 | 日本羞羞无码一区二区视频网站 | 总裁含着她的乳尖h在线观看 | 中国少妇精品 OOO喷水 | 国产探花福利福利私拍av在线 | 97超碰人人在线 |