我正在尝试使用Matlab生成线性回归模型的混淆矩阵。这是我到目前为止所做的:
%read in the data: logistic.txt
table = readtable('logistic.txt');
%Assign the columns in logistic.txt to variable names in 2)
X1 = table.gre; X2 = table.gpa; X3 = table.rank; Y = table.admit;
%Fit a linear regression model and plot it:
mdl = fitlm(table, 'Responsevar','admit');
%plot(mdl);
%Predict the admittance of a new student input defined in assignment
sample = [780, 3.8, 2];
prediction = predict(mdl, sample)
%Generate a confusion matrix
inputvar = [X1 X2 X3];
net = patternnet(10);
net = train(net, inputvar, Y);
results = net(inputvar);
plotconfusion(Y, results)
logistic.txt是一个包含400行的四列列表,其中“admit”是二进制响应变量。 我收到以下错误:
Error using network/train (line 340)
Inputs and targets have different numbers of samples.
Error in hw2q2 (line 17)
net = train(net, Y, inputvar);
从MathWorks示例中我无法确切地说出我做错了什么。