不适合虹膜数据集的逻辑回归模型
问题描述:
试图使虹膜数据集适用逻辑回归模型,但它不合适。代码有什么问题。谢谢。不适合虹膜数据集的逻辑回归模型
# Dependencies used: numpy, matpotlib.pyplot, csv
# dataset: Iris
# Binary classification using gradient descent
# python 3.5
# input data matrix = x(99 X 1) # including ones vector
# discrete output data matrix = y(99 X 1)
# parameters matrix = theta(5 X 1)
for j in range(3500):
# hypothesis function
h = 1/(1 + np.exp(-x.dot(theta)))
# gradient descent
theta = theta - (0.00001/m) * np.sum(x.T.dot(h - y)) + (30.0/m)*np.sum(np.sum(theta[1:5, :]**2))
# cost function
cost = -(1/m) * np.sum(y.T.dot(np.log(h)) + (1-y).T.dot(np.log(1-h)))
j_iter.append(cost)
Iter.append(j)
答
虹膜数据集包含三个输出类,这意味着你的代码应执行多项式回归。大多数二项回归是几种工具中采用的一种,这意味着输入数据集只能包含两个输出类。请仔细检查你的代码是否处理了三个类,然后继续......这可能是你的问题。
这没有[mcve]。 – ImportanceOfBeingErnest