【问题标题】:couldn't compile a logistic regression code in matlab无法在 matlab 中编译逻辑回归代码
【发布时间】:2014-05-09 04:38:23
【问题描述】:

我已经在 mat lab 上运行过这段代码.....

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 行) 商店(:,i)=温度;

请帮忙

【问题讨论】:

  • temp 的大小是多少?在store(:,i)=temp;之前的那一行输入size(temp),它会告诉你为什么它不起作用。
  • 为什么这个标签是 SVM?不要只是为了它而标记。另外,您确定不需要在X 矩阵中添加一列吗?最后请至少提供Xy 的尺寸,但是最好完整描述您认为您的代码正在做什么

标签: matlab machine-learning logistic-regression


【解决方案1】:

检查store(:,i)temp 的尺寸。也许您需要将temp 转置为temp' 或将store(:,i) 修改为store(i,:)

【讨论】:

    猜你喜欢
    • 2013-11-18
    • 2018-04-25
    • 2013-05-02
    • 1970-01-01
    • 2017-11-02
    • 2013-12-21
    • 2017-12-02
    • 2018-04-12
    • 1970-01-01
    相关资源
    最近更新 更多