Pycebox IcePlot не работает на Xgboost во время работы в Random Forest - PullRequest
0 голосов
/ 11 февраля 2020

Ниже появляется ошибка, когда я запускаю Pycebox с XGBoost, обучение проходит отлично, хотя я не уверен, почему появляется поле [fx] при работе с iceplot. Также у меня есть двойное подтверждение, что они не находятся в наборе данных

ValueError: feature_names mismatch: ['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)'] ['f0', 'f1', 'f2', 'f3']
expected petal width (cm), petal length (cm), sepal length (cm), sepal width (cm) in input data
training data did not have the following fields: ***f3, f1, f0, f2***

Я создал пример, используя данные радужной оболочки

XGboost Code:

    from sklearn.datasets import load_iris
    from pycebox.ice import ice, ice_plot
    from sklearn.model_selection import train_test_split
    import pandas as pd
    import numpy as np
    from sklearn.ensemble import RandomForestRegressor
    import xgboost as xgb
    import matplotlib.pyplot as plt

    iris = load_iris()
    data1 = pd.DataFrame(data= np.c_[iris['data'], iris['target']],
                         columns= iris['feature_names'] + ['target'])
    target = data1['target']
    training = data1.drop(['target'],axis=1)

    X_train, X_test, y_train, y_test = train_test_split(training, target, test_size=0.4)
    xg_reg = xgb.XGBRegressor(random_state=1234,eval_metric='rmse',n_jobs=-1)
    xg_reg.fit(X_train,y_train)
    forty_ice_df = ice(data=X_train, column='petal length (cm)', 
                   predict=xg_reg.predict)
    ice_plot(forty_ice_df, c='dimgray', linewidth=0.3)
    plt.ylabel('Pred. Target')
    plt.xlabel('petal length (cm)')

Пока это работает в Случайном Лесу

rf = RandomForestRegressor(random_state = 1234, n_jobs=18)
rf.fit(X_train, y_train)
forty_ice_df = ice(data=X_train, column='petal length (cm)', 
                   predict=rf.predict)
ice_plot(forty_ice_df, c='dimgray', linewidth=0.3)
plt.ylabel('Pred. Target')
plt.xlabel('petal length (cm)')
...