【发布时间】:2021-11-26 03:12:53
【问题描述】:
我正在尝试运行 test_train_split,然后使用它来运行逻辑回归分析。
from sklearn.model_selection import train_test_split
x = hotel_data.iloc[:,:-1]
y = hotel_data.iloc[:,-1]
x_train, x_test, y_train, y_test = train_test_split(x,y, test_size=0.20, random_state=0)
当我运行代码时
logisticRegr.fit(x_train, y_train)
我明白了
ValueError: could not convert string to float: 'CityHotel'
“CityHotel”指的是我正在使用的“hotel_data”数据集中“酒店”列下的一种酒店。该列中的另一个选项是“ResortHotel”。
【问题讨论】:
标签: python machine-learning scikit-learn linear-regression