When predicting data, the data type is object resulting in an error TypeError: unsupported operand type(s) for -:'str' and'float'

Solution

Change data type:

data:pd.DataFrame = data.astype('int64')
# 或是:
data:pd.DataFrame = data.astype('float')

Problem resolution

First of all, make sure that the code itself has no problem, because when training the data, when checking the number type of the Dataframe, it is found that the data.dtypesdisplayed result is object, so normal training cannot be performed, just switch the data type.

Guess you like

Origin blog.csdn.net/weixin_35757704/article/details/113885057