I found a mistake in Lasso function
이전 댓글 표시
In the function of Lasso (function [B,stats] = lasso(X,Y,varargin)), X is A numeric matrix (NxP). There is an optional input parameter called 'Weights'.
% 'Weights' Observation weights. Must be a vector of non-negative
% values, of the same length as columns of X. At least
% two values must be positive. (default ones(N,1) or
% equivalently (1/N)*ones(N,1)).
Since N is the number of samples and P is the number of features, Weights should be the ones(P,1). If Weights is ones(N,1), that is the weight of samples.
If my thoughts are wrong, I hope someone helps me correct. Thanks!
function [B,stats] = lasso(X,Y,varargin)
%LASSO Perform lasso or elastic net regularization for linear regression.
% [B,STATS] = lasso(X,Y,...) Performs L1-constrained linear least
% squares fits (lasso) or L1- and L2-constrained fits (elastic net)
% relating the predictors in X to the responses in Y. The default is a
% lasso fit, or constraint on the L1-norm of the coefficients B.
%
% Positional parameters:
%
% X A numeric matrix (dimension, say, NxP)
% Y A numeric vector of length N
%
% Optional input parameters:
%
% 'Weights' Observation weights. Must be a vector of non-negative
% values, of the same length as columns of X. At least
% two values must be positive. (default ones(N,1) or
% equivalently (1/N)*ones(N,1)).
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Linear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!