【问题标题】:Issue with the prediction error plot using the yellowbrick library (regression)使用黄砖库的预测误差图问题(回归)
【发布时间】:2022-04-20 20:58:35
【问题描述】:

我有三个回归模型:

  • 线性回归:使用 ols_regressor = sm.OLS()
  • 随机森林:使用 rf = RandomForestRegressor()
  • 人工神经网络:使用 tensorflow 和 keras

我想为三个模型绘制一个预测误差图,我发现了 yellowbrick 库,它看起来非常简单。

在他们的文档中,他们有两种应用功能的方式:

# Method 1:
from yellowbrick.regressor import PredictionError

# Instantiate the linear model and visualizer
model = Lasso()
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()                 # Finalize and render the figure

# Method 2:
from yellowbrick.regressor import prediction_error

# Instantiate the linear model and visualizer
model = Lasso()
visualizer = prediction_error(model, X_train, y_train, X_test, y_test)

在尝试任何一种方法时,线性回归和 NN 模型都会出现以下错误:

YellowbrickTypeError: This estimator is not a regressor; try a classifier or clustering score visualizer instead!

它在随机森林中绘制得很好。

它们是回归量,我的数据中没有任何分类变量。为什么会这样?我可以使用什么替代方案或应该添加什么?

来源:https://www.scikit-yb.org/en/latest/api/regressor/peplot.html

【问题讨论】:

    标签: python regression yellowbrick


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2019-09-09
      • 2020-08-07
      • 2013-08-20
      • 2019-06-03
      • 1970-01-01
      • 2020-11-24
      • 1970-01-01
      • 2020-10-08
      • 2021-10-16
      相关资源
      最近更新 更多