[英]couldn't compile a logistic regression code in matlab
我已經在墊子實驗室上運行了此代碼.....
function [store,temp] = LR( X,y )
store=zeros(10,10);
indices = crossvalind('Kfold',y,10);
for i = 1:10
test = (indices == i); train = ~test;
[b,dev,stats] = glmfit(X(train,:),y(train),'binomial','logit');
temp= glmval(b,X(test,:),'logit');
store(:,i)=temp;
end
end
但出現錯誤,下標分配維度不匹配。 LR(第8行)中的錯誤store(:,i)= temp;
請幫忙
檢查store(:,i)
和temp
的尺寸。 也許您需要用temp'
轉置temp
或將store(:,i)
修改為store(i,:)
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.