Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 用一个热编码特征自动学习中的特征和特征重要性_Python_Machine Learning_Scikit Learn_Xgboost_Feature Selection - Fatal编程技术网

Python 用一个热编码特征自动学习中的特征和特征重要性

Python 用一个热编码特征自动学习中的特征和特征重要性,python,machine-learning,scikit-learn,xgboost,feature-selection,Python,Machine Learning,Scikit Learn,Xgboost,Feature Selection,我正在尝试使用Auto Sklearn训练XGBoost模型 模型训练很好,但是,我需要特性重要性来优化模型并用于报告目的 autosklearn.classification.AutoSklearnClassifier没有可以为我执行此操作的函数 我试图从底层管道中获取功能和功能重要性分数 我已经使用下面GitHub问题中给出的细节尝试了一些事情 (一) (二) 我还尝试过使用“Trace”python模块。这返回了超过900000行代码。不知道从哪里开始 我的代码正在编写中,但看起来像:

我正在尝试使用Auto Sklearn训练XGBoost模型

模型训练很好,但是,我需要特性重要性来优化模型并用于报告目的

autosklearn.classification.AutoSklearnClassifier
没有可以为我执行此操作的函数

我试图从底层管道中获取功能和功能重要性分数

我已经使用下面GitHub问题中给出的细节尝试了一些事情

(一)

(二)

我还尝试过使用“Trace”python模块。这返回了超过900000行代码。不知道从哪里开始

我的代码正在编写中,但看起来像:

import pandas as pd
import numpy as np
import autosklearn.classification
import sklearn.model_selection
import sklearn.datasets
import sklearn.metrics
import datetime
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score, roc_curve, auc
from sklearn import preprocessing
from sklearn.preprocessing import LabelEncoder
import eli5 as eli
import pdb
df = pd.read_csv('titanic_train.csv')
df_target = df['Survived']
drop_Attbr = ['PassengerId', 'Name', 'Ticket', 'Cabin','Survived','Sex','Embarked']
df_labels = df.drop(drop_Attbr,axis=1)
feature_types = ['categorical'] +['numerical']+(['categorical']* 2)+['numerical']
df_train, df_test, y_train, y_test = train_test_split(df_labels, df_target, test_size=1/3, random_state=42)
automl = autosklearn.classification.AutoSklearnClassifier(
        time_left_for_this_task=15,
        per_run_time_limit=5,
        ensemble_size=1,
        disable_evaluator_output=False,
        resampling_strategy='holdout',
        resampling_strategy_arguments={'train_size': 0.67},
        include_estimators=['xgradient_boosting']
    )
automl.fit(df_train, y_train,feat_type=feature_types)
y_hat = automl.predict(df_test)
a_score = sklearn.metrics.accuracy_score(y_test, y_hat)
print("Accuracy score "+str(a_score))
我在寻找这样的结果:

Feature 1 : Feature Importance score 1;
Feature 2 : Feature Importance score 2;
Feature 3 : Feature Importance score 3;
Feature 4 : Feature Importance score 4;
Feature 5 : Feature Importance score 5;
试试这个

for identifier in automl._automl._automl.model_:
    if identifier in automl.ensemble_.get_selected_model_identifiers():
        model = automl._automl._automl.models_[identifier].pipeline_._final_estimator()
        print(model.get_score())   

pythoin'auto_ml'中还有一个库。您可以使用“pip install auto_ml”安装它。它有一个参数“ml\u for_analytics”,如果设置为true,则可以为您提供您正在查找的报告。我目前正在使用“auto\u ml”。我们想将我们的管道移动到Auto-Sklearn。对于集合大小=1,print(automl.get_models_with_weights())会给出如下输出。我认为,它没有可以列举的特征。有没有办法从底层的Auto Sklearn管道中获取它?它看起来像是集合模型的权重。我已经更新了我的解决方案,你能试试吗?尝试了几个版本的代码,得到了一个属性错误,下面的屏幕截图:实际上我不能在我的机器上安装autosklearn,这就是为什么我不能自己检查。你能试试最新的吗。谢谢,谢谢,我会调查的。这个解决方案有效吗?