lasso-regression

“get_int_parms” not available for .Fortran() for package “glmnet”

自闭症网瘾萝莉.ら 提交于 2019-12-13 14:34:34
问题 I am trying to fit a simple lasso model with the latest glmnet package. I have read in a csv-file and have all my data stored as a "list" or matrix. I tried to follow this guide for the implementation: https://www.r-bloggers.com/ridge-regression-and-the-lasso/ But when I run: lasso.mod <- glmnet(b[,2:22], b$power, alpha=1) I get the following error: Error in .Fortran("get_int_parms", fdev = double(1), eps = double(1), : "get_int_parms" not available for .Fortran() for package "glmnet" In my

how to call python and sklearn from matlab? [duplicate]

老子叫甜甜 提交于 2019-12-13 08:08:49
问题 This question already has answers here : Call Python function from MATLAB (13 answers) Closed 3 years ago . I need to call sklearn function on matlab. I have heard that there are some problems in calling numpy function and sklearn is based on numpy. Is there any guide about that? 回答1: For Python I see different solutions: COM on Windows platforms. This requires to register an application, check if this is possible and allowed on the cluster. XMLRPC or SOAP. You may need to use Java-Classes in

Extracting non-zero coefficients in glmnet in R

北城以北 提交于 2019-12-11 18:38:52
问题 I'm doing a lasso logistic regression. I've used cv.glmnet to get the non-zero coefficients. And it seems to work i.e. I do get some non-zero coefficients and the rest go to zero. However, when I use coef function to print all coefficients it gives me a list of all coefficients. Is there a way to extract coefficients and their names that are not zero. The code of what I've done is: cv.lasso = cv.glmnet(x_train,y_train, alpha = 0.6, family = "binomial") coef(cv.lasso, s=cv.lasso$lambda.1se)

How to build a predict function with Lasso and RobustScalar?

梦想的初衷 提交于 2019-12-11 07:47:26
问题 I'm trying to figure out how to predict values with LASSO regression without using the .predict function that Sklearn provides. This is basically just to broaden my understanding of how LASSO works internally. I asked a question on Cross Validated about how LASSO regression works, and one of the comments mentioned how the predict function works the same as in Linear Regression. Because of this, I wanted to try and make my own function to do this. I was able to successfully recreate the

what does the option normalize = True in Lasso sklearn do?

风格不统一 提交于 2019-12-10 10:58:17
问题 I have a matrix where each column has mean 0 and std 1 In [67]: x_val.std(axis=0).min() Out[70]: 0.99999999999999922 In [71]: x_val.std(axis=0).max() Out[71]: 1.0000000000000007 In [72]: x_val.mean(axis=0).max() Out[72]: 1.1990408665951691e-16 In [73]: x_val.mean(axis=0).min() Out[73]: -9.7144514654701197e-17 The number of non 0 coefficients changes if I use the normalize option In [74]: l = Lasso(alpha=alpha_perc70).fit(x_val, y_val) In [81]: sum(l.coef_!=0) Out[83]: 47 In [84]: l2 = Lasso

Lasso error in glmnet NA/NaN/Inf

北战南征 提交于 2019-12-08 15:55:19
问题 I'm having an issue with glmnet in that I keep getting the error message "Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, : NA/NaN/Inf in foreign function call (arg 5) In addition: Warning message: In elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, : NAs introduced by coercion" Below I can replicate the error with the 'iris' data set, but here is the simplified code for my particular data: vars <- as.matrix(ind.vars) lasso <- glmnet(vars, y=cup98$TARGET

Using glmnet to predict a continuous variable in a dataset

隐身守侯 提交于 2019-12-08 13:24:30
问题 I have this data set. wbh I wanted to use the R package glmnet to determine which predictors would be useful in predicting fertility. However, I have been unable to do so, most likely due to not having a full understanding of the package. The fertility variable is SP.DYN.TFRT.IN. I want to see which predictors in the data set give the most predictive power for fertility. I wanted to use LASSO or ridge regression to shrink the number of coefficients, and I know this package can do that. I'm

what does the option normalize = True in Lasso sklearn do?

ⅰ亾dé卋堺 提交于 2019-12-06 07:25:17
I have a matrix where each column has mean 0 and std 1 In [67]: x_val.std(axis=0).min() Out[70]: 0.99999999999999922 In [71]: x_val.std(axis=0).max() Out[71]: 1.0000000000000007 In [72]: x_val.mean(axis=0).max() Out[72]: 1.1990408665951691e-16 In [73]: x_val.mean(axis=0).min() Out[73]: -9.7144514654701197e-17 The number of non 0 coefficients changes if I use the normalize option In [74]: l = Lasso(alpha=alpha_perc70).fit(x_val, y_val) In [81]: sum(l.coef_!=0) Out[83]: 47 In [84]: l2 = Lasso(alpha=alpha_perc70, normalize=True).fit(x_val, y_val) In [93]: sum(l2.coef_!=0) Out[95]: 3 It seems to

negative value for “mean_squared_error”

时间秒杀一切 提交于 2019-12-06 05:50:08
I am using scikit and using mean_squared_error as a scoring function for model evaluation in cross_val_score. rms_score = cross_validation.cross_val_score(model, X, y, cv=20, scoring='mean_squared_error') I am using mean_squared_error as it is a regression problem and the estimators (model) used are lasso , ridge and elasticNet . For all these estimators, I am getting rms_score as negative values. How is it possible, given the fact that the differences in y values are squared. You get the mean_squared_error with sign flipped returned by cross_validation.cross_val_score. There is an issued

Why calculating MSE in lasso regression gives different outputs?

ε祈祈猫儿з 提交于 2019-12-05 17:18:50
I am trying to run different regression models on the Prostate cancer data from the lasso2 package. When I use Lasso, I saw two different methods to calculate the mean square error. But they do give me quite different results, so I would want to know if I'm doing anything wrong or if it just means that one method is better than the other ? # Needs the following R packages. library(lasso2) library(glmnet) # Gets the prostate cancer dataset data(Prostate) # Defines the Mean Square Error function mse = function(x,y) { mean((x-y)^2)} # 75% of the sample size. smp_size = floor(0.75 * nrow(Prostate)