繁体   English   中英

无法在Matlab中编译逻辑回归代码

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM