gpt4 book ai didi

python - 调整部分依赖图的大小 - 看起来太小

转载 作者:太空宇宙 更新时间:2023-11-04 00:13:04 25 4
gpt4 key购买 nike

我通过 Scikit learn 的库创建了部分依赖图。但是,我面临着将地 block 大小调整得更大的挑战,因为我可以完全阅读所有地 block 。有没有一种方法可以更改绘图 View 和大小?

代码:

from sklearn.ensemble.partial_dependence import partial_dependence, plot_partial_dependence
import pandas as pd
from pandas import read_csv, DataFrame
from sklearn.ensemble import GradientBoostingRegressor
import numpy as np

my_model = GradientBoostingRegressor()
my_model.fit(X, y)

my_plots = 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)

创建的图:

enter image description here

最佳答案

我已经用下面的代码解决了大小问题:

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”)。使用这两个返回值,可以使用额外的选项,例如独立设置宽度和高度。

关于python - 调整部分依赖图的大小 - 看起来太小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51814870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com