Python训练营打卡day32

DAY 32 官方文档的阅读
知识点回顾:
1.官方文档的检索方式:github和官网
2.官方文档的阅读和使用:要求安装的包和文档为同一个版本
3.类的关注点:
a.实例化所需要的参数
b.普通方法所需要的参数
c.普通方法的返回值
4.绘图的理解:对底层库的调用

作业:参考pdpbox官方文档中的其他类,绘制相应的图,任选即可


iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['target'] = iris.target 
features = iris.feature_names  
target = 'target'
 
X_train, X_test, y_train, y_test = train_test_split(
    df[features], df[target], test_size=0.2, random_state=42
)
 
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)
 
import  pdpbox
print(pdpbox.__version__)
 
from pdpbox.info_plots import TargetPlot
 
feature = 'petal length (cm)'
feature_name = feature 
 
feature = 'petal length (cm)'
feature_name = feature 
)
target_plot = TargetPlot(
    df=df, 
    feature=feature, 
    feature_name=feature_name,  
    # target='target',
    target='target',  
    grid_type='percentile',  
    num_grid_points=10 
 
target_plot.plot()
type(target_plot.plot())
len(target_plot.plot())
target_plot.plot()[0]
target_plot.plot()[2]
 
fig, axes, summary_df = target_plot.plot(
    which_classes=None,  
    show_percentile=True,  
    engine='plotly',
    template='plotly_white'
)
)
fig.update_layout(
    width=800, 
    height=500,  
    title=dict(text=f'Target Plot: {feature_name}', x=0.5)  
 
fig.show()

@浙大疏锦行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值