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()

@浙大疏锦行

你可能感兴趣的:(Python打卡训练,python,开发语言)