RandomForestClassfier.fit(): ValueError: could not convert string to float

后端 未结 8 912
礼貌的吻别
礼貌的吻别 2020-12-23 09:16

Given is a simple CSV file:

A,B,C
Hello,Hi,0
Hola,Bueno,1

Obviously the real dataset is far more complex than this, but this one reproduces

8条回答
  •  Happy的楠姐
    2020-12-23 09:59

    You can't pass str to your model fit() method. as it mentioned here

    The training input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csc_matrix.

    Try transforming your data to float and give a try to LabelEncoder.

提交回复
热议问题