A column-vector y was passed when a 1d array was expected

前端 未结 8 675
慢半拍i
慢半拍i 2020-12-12 10:40

I need to fit RandomForestRegressor from sklearn.ensemble.

forest = ensemble.RandomForestRegressor(**RF_tuned_parameters)
model = fo         


        
8条回答
  •  被撕碎了的回忆
    2020-12-12 11:04

    use below code:

    model = forest.fit(train_fold, train_y.ravel())
    

    if you are still getting slap by error as identical as below ?

    Unknown label type: %r" % y
    

    use this code:

    y = train_y.ravel()
    train_y = np.array(y).astype(int)
    model = forest.fit(train_fold, train_y)
    

提交回复
热议问题