我有一个 excel 文件,其中包含与确定葡萄酒质量相关的详细信息,我想使用函数sklearn.linear_model.SGDClassifier(SVM => Hinge loss) 和 (Logarithmic regression =>log loss)来实现线性模型概念Python。我通过scikit learn网站了解了有关这些功能的基础知识,但无法使用 excel 文件实现模型。我对 python 和机器学习非常陌生,我发现很难实现这个模型。我在 python 中打开了 excel 文件,并尝试从文件中 [随机] 取出两列,并将其用作输入来调用模型中可用的fit函数。但是,我收到一条错误消息,指出未知标签类型:数组. 我也尝试了其他几种方法,但是没有任何效果。有人可以指导我的实施过程吗?
from xlrd import open_workbook
from sklearn import linear_model
i = 0
fa = []
ph = []
book = open_workbook('F:/BIG DATA/winequality.xlsx')
sheet = book.sheet_by_name('Sheet1')
num_rows = sheet.nrows - 1
num_cols = sheet.ncols - 1
curr_row = 0
while curr_row <num_rows:
curr_row += 1
cell_val = sheet.cell_value(curr_row,0)
cell_val1 = sheet.cell_value(curr_row,10)
fa.append([float(cell_val),float(cell_val1)])
cell_val2 = sheet.cell_value(curr_row,8)
ph.append(float(cell_val2))
model = linear_model.SGDClassifier()
print(model.fit(fa,ph))

错误信息截图:
