Python 调整部分依赖关系图的大小-看起来太小

Python 调整部分依赖关系图的大小-看起来太小,python,matplotlib,scikit-learn,Python,Matplotlib,Scikit Learn,我通过Scikit learn的库创建了部分依赖关系图。然而,我面临着一个挑战,在调整情节,使其更大,因为我可以阅读所有的情节完全。是否有更改打印视图和大小的方法 代码: 创建的绘图: 我已使用以下代码解决了尺寸问题: import matplotlib.pyplot as plt fig, ax = plot_partial_dependence(my_model, features=[0,1,2,3,4,5,6,7,8,9,10,

我通过Scikit learn的库创建了部分依赖关系图。然而,我面临着一个挑战,在调整情节,使其更大,因为我可以阅读所有的情节完全。是否有更改打印视图和大小的方法

代码:

创建的绘图:


我已使用以下代码解决了尺寸问题:

import matplotlib.pyplot as plt
fig, ax = plot_partial_dependence(my_model,       
                        features=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],
                        X=X,        
                        feature_names=['core_self_evaluations', '1b_score', 'investigate','respect_for_people','social','mastery_orientation','realistic','conventional','astronaut_score','innovation','agreeableness','gradeClass_second_lower','AC_TeamPlayer','enterprising','AC_Problemsolving','AC_StartsConversation','verbal','leadership_score','Race_chinese','performance_orientation','self_monitoring','UniLoc_overseas','attention_to_detail'], # labels on graphs
                        grid_resolution=5) 
fig.set_figwidth(8)
fig.set_figheight(15)
fig.tight_layout()

这提供了非常好的布局和可定制的高度和宽度。要查看的提示是方法的返回值(即“fig”和“ax”)。使用这两个返回值,可以使用额外的选项,例如独立设置宽度和高度。

在V0.22中,
ax
参数是新的

以下是当前的方式:

fig, ax = plt.subplots(figsize=(14, 14))
plot_partial_dependence(est, X, ax=ax)

为当前API更新。

亲爱的Dinesh,由于大部分协变量在部分依赖图中返回恒定的水平线,您不应该从分析中删除它们吗?这也将有助于更好地描述您的模型的主要特点。亲爱的菲利普,很抱歉我的反应太晚。是的,你说得对。我失去了我分析的原始数据。但是你的建议是正确的。
fig, ax = plt.subplots(figsize=(14, 14))
plot_partial_dependence(est, X, ax=ax)