【发布时间】:2018-05-03 23:40:27
【问题描述】:
Hi 使用标准化数据来拟合 GradientBoostingRegressor,并绘制了主要 10 个变量的部分依赖关系。现在我想将它们与真实的非标准化值进行对比,因此想要访问 x 标签。我该怎么做?
我的代码相当于 http://scikit-learn.org/stable/auto_examples/ensemble/plot_partial_dependence.html
对于 3D 绘图很容易,因为我可以转换轴
axes[0] = (axes[0]*mysd0)+mymean0
axes[1] = (axes[1]*mysd1)+mymean1
具有平均值和标准偏差,但对于子图,我不知道如何访问标签。谢谢
这里是我说的部分代码:
from sklearn.model_selection import train_test_split
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.ensemble.partial_dependence import plot_partial_dependence
from sklearn.datasets.california_housing import fetch_california_housing
cal_housing = fetch_california_housing()
# split 80/20 train-test
X_train, X_test, y_train, y_test = train_test_split(cal_housing.data,
cal_housing.target,
test_size=0.2,
random_state=1)
names = cal_housing.feature_names
clf = GradientBoostingRegressor(n_estimators=100, max_depth=4,
learning_rate=0.1, loss='huber',
random_state=1)
clf.fit(X_train, y_train)
features = [0, 5, 1]
fig, axs = plot_partial_dependence(clf, X_train, features,
feature_names=names,
n_jobs=3, grid_resolution=50)
fig.suptitle('Partial dependence of house value on nonlocation features\n'
'for the California housing dataset')
在这个图中,我想访问和操作 x 轴标签...
【问题讨论】:
-
你能描述一下 x 矩阵吗?列 ?行?还要添加完整的代码
标签: python scikit-learn sklearn-pandas