【问题标题】:Catboost understanding - Conversion of Categorical valuesCatboost 理解 - 分类值的转换
【发布时间】:2018-04-12 21:19:34
【问题描述】:

我有一些关于 catboost 的愚蠢问题。

从 catboost 的文档中,我了解到行之间存在一些排列/洗牌,用于分类数据转换。(https://tech.yandex.com/catboost/doc/dg/concepts/algorithm-main-stages_cat-to-numberic-docpage/#algorithm-main-stages_cat-to-numberic)

我试图通过一次观察来预测我的模型是否有效,但我得到了一个错误。但是,通过 2 次观察,它可以正常工作。

我的问题是,对于 catboost 分类器的预测,由于排列,我们是否必须至少给出 2 个观察值?如果是,第一次观察对输出有影响吗?

【问题讨论】:

    标签: python machine-learning catboost


    【解决方案1】:

    Catboost 确实有这样的限制。但是,它与排列无关,因为它们仅在拟合阶段应用。

    问题是在predictfit 之前应用了相同的方法catboost.Pool._check_data_empty。对于拟合而言,拥有不止一个观察结果确实至关重要。

    现在检查功能需要sum(x.shape)>2,这确实很奇怪。下面的代码说明了这个问题:

    import catboost
    import numpy as np
    x_train3 = np.array([[1,2,3,], [2,3,4], [3,4,5]])
    x_train1 = np.array([[1], [2], [3]])
    y_train = np.array([1,2,3])
    x_test3_2 = np.array([[4,5,6], [5,6,7]])
    x_test3_1 = np.array([[4,5,6,]])
    x_test1_2 = np.array([[4], [5]])
    x_test1_1 = np.array([[4]])
    model3 = catboost.CatBoostRegressor().fit(x_train3, y_train)
    model1 = catboost.CatBoostRegressor().fit(x_train1, y_train)
    print(model3.predict(x_test3_2)) # OK
    print(model3.predict(x_test3_1)) # OK
    print(model1.predict(x_test1_2)) # OK
    print(model1.predict(x_test1_1)) # Throws an error!
    

    目前,您可以通过在调用 predict 之前再添加一两个假行来做得很好。它们不会影响原始行的输出。

    【讨论】:

      猜你喜欢
      • 2021-07-08
      • 1970-01-01
      • 1970-01-01
      • 2020-06-11
      • 2021-01-31
      • 1970-01-01
      • 1970-01-01
      • 2016-07-27
      • 1970-01-01
      相关资源
      最近更新 更多