kaggle教程--7--Partial Dependence Plots

Partial Dependence Plots:部分依赖图

模型训练后(fit),才可以创建部分依赖图(PDP)

部分依赖图,反映出了某一列特征,对目标列(target)的影响

例子:

from sklearn.ensemble.partial_dependence import partial_dependence, plot_partial_dependence

# get_some_data is defined in hidden cell above.
X, y = get_some_data()
# scikit-learn originally implemented partial dependence plots only for Gradient Boosting models
# this was due to an implementation detail, and a future release will support all model types.
my_model = GradientBoostingRegressor()
# fit the model as usual
my_model.fit(X, y)
# Here we make the plot
my_plots = plot_partial_dependence(my_model,
features=[0,1,2], # column numbers of plots we want to show
X=X, # raw predictors data.
feature_names=['Distance', 'Landsize', 'BuildingArea'], # labels on graphs
grid_resolution=10) # number of values to plot on x axis 代表横坐标上点的数量,越大表示图上的点越多,默认为100

猜你喜欢

转载自www.cnblogs.com/wangzhonghan/p/10509374.html