Yellowbrick预测错误图编辑标签和图例

2024-05-15 17:52:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用Yellowbrick可视化工具绘制预测错误,但我没有得到预期的结果。该图类似于pp图或qq图,但不正确。此外,我无法更改轴的标签和添加标题,也无法获得任何默认标签和图例。 谁能告诉我该怎么办。 以下是visualizer的代码:

def predict_error(model):
    visualizer = PredictionError(model)
    visualizer.fit(X_train, Y_train)  # Fit the training data to the visualizer
    visualizer.score(X_test, Y_test)  # Evaluate the model on the test data
    visualizer.show()   

这是我得到的输出:

enter image description here


Tags: 工具thetest标题datamodel可视化错误
1条回答
网友
1楼 · 发布于 2024-05-15 17:52:46

我们最近有一位贡献者在我们的ResidualsPlot中添加了一个QQ绘图功能,虽然该提交尚未部署,但在此之前,您可以使用these instructions分叉并克隆Yellowbrick,然后按如下方式创建QQ绘图:

from sklearn.linear_model import Ridge
from sklearn.model_selection import train_test_split as tts

from yellowbrick.datasets import load_concrete
from yellowbrick.regressor import ResidualsPlot

# Load a regression dataset
X, y = load_concrete()

# Create the train and test data
X_train, X_test, y_train, y_test = tts(
    X, y, test_size=0.2, random_state=37
)

# Instantiate the visualizer,
# setting the `hist` param to False and the `qqplot` parameter to True
visualizer = ResidualsPlot(
    Ridge(), 
    hist=False, 
    qqplot=True,
    train_color="gold",
    test_color="maroon"
)
visualizer.fit(X_train, y_train)
visualizer.score(X_test, y_test)
visualizer.show()

结果如下: Example of QQ-plot with Yellowbrick

相关问题 更多 >