logistic-regression

R Step function looks for data in global environment, not inside defined function

时光怂恿深爱的人放手 提交于 2021-02-07 10:13:48
问题 I have a problem with step forward regression and My understanding is that i don't pass argument Data correctly. I have the function: ForwardStep <- function(df,yName, Xs, XsMin) { Data <- df[, c(yName,Xs)] fit <- glm(formula = paste(yName, " ~ ", paste0(XsMin, collapse = " + ")), data = Data, family = binomial(link = "logit") ) ScopeFormula <- list(lower = paste(yName, " ~ ", paste0(XsMin, collapse = " + ")), upper = paste(yName, " ~ ", paste0(Xs, collapse = " + "))) result <- step(fit,

Simple binary logistic regression using MATLAB

元气小坏坏 提交于 2021-02-06 11:00:02
问题 I'm working on doing a logistic regression using MATLAB for a simple classification problem. My covariate is one continuous variable ranging between 0 and 1, while my categorical response is a binary variable of 0 (incorrect) or 1 (correct). I'm looking to run a logistic regression to establish a predictor that would output the probability of some input observation (e.g. the continuous variable as described above) being correct or incorrect. Although this is a fairly simple scenario, I'm

Simple binary logistic regression using MATLAB

こ雲淡風輕ζ 提交于 2021-02-06 10:59:44
问题 I'm working on doing a logistic regression using MATLAB for a simple classification problem. My covariate is one continuous variable ranging between 0 and 1, while my categorical response is a binary variable of 0 (incorrect) or 1 (correct). I'm looking to run a logistic regression to establish a predictor that would output the probability of some input observation (e.g. the continuous variable as described above) being correct or incorrect. Although this is a fairly simple scenario, I'm

How to get comparable and reproducible results from LogisticRegressionCV and GridSearchCV

这一生的挚爱 提交于 2021-02-06 08:58:24
问题 I want to score different classifiers with different parameters. For speedup on LogisticRegression I use LogisticRegressionCV (which at least 2x faster) and plan use GridSearchCV for others. But problem while it give me equal C parameters, but not the AUC ROC scoring. I'll try fix many parameters like scorer , random_state , solver , max_iter , tol ... Please look at example (real data have no mater): Test data and common part: from sklearn import datasets boston = datasets.load_boston() X =

How to get comparable and reproducible results from LogisticRegressionCV and GridSearchCV

那年仲夏 提交于 2021-02-06 08:58:00
问题 I want to score different classifiers with different parameters. For speedup on LogisticRegression I use LogisticRegressionCV (which at least 2x faster) and plan use GridSearchCV for others. But problem while it give me equal C parameters, but not the AUC ROC scoring. I'll try fix many parameters like scorer , random_state , solver , max_iter , tol ... Please look at example (real data have no mater): Test data and common part: from sklearn import datasets boston = datasets.load_boston() X =

Getting LinAlgError: Singular matrix Error

三世轮回 提交于 2021-02-05 08:10:30
问题 I'm using the below function to calculate p-value to build fit logistic regression model. But I get LinAlgError: Singular matrix error. from sklearn import linear_model import scipy.stats as stat class LogisticRegression_with_p_values: def __init__(self, *args, **kwargs): self.model = linear_model.LogisticRegression(*args, **kwargs) def fit(self, X, y): self.model.fit(X, y) denom = (2.0 * (1.0 + np.cosh(self.model.decision_function(X)))) denom = np.tile(denom, (X.shape[1],1)).T F_ij = np.dot(

Logistic Regression in Caret - No Intercept?

旧巷老猫 提交于 2021-02-05 06:34:24
问题 Performing logistic regression in R using the caret package and trying to force a zero intercept such that probability at x=0 is .5. In other forms of regression, it seems like you can turn the intercept off using tunegrid, but that has no functionality for logistic regression. Any ideas? model <- train(y ~ 0+ x, data = data, method = "glm", family = binomial(link="probit"), trControl = train.control) And yes, I "know" that the probability at x=0 should be .5, and thus trying to force it. 回答1

Toy example of Logistic Regression with Tensorflow probability and the titanic dataset fails

怎甘沉沦 提交于 2021-01-29 20:00:18
问题 I am learning tensorflow-probability and this is a toy example of logistic regression with the titanic dataset. My model does not seem to learn and the loss is nan. I don't understand why. Below you will find three different implementations, all return the same results. One uses a sigmoid activation, the second uses a DistributionLambda Layer with a Bernoulli distribution and the third a DistributionLambda Layer with a Beta distribution. Are there any corrections I should make to this code?

R: can caret::train function for glmnet cross-validate AUC at fixed alpha and lambda?

霸气de小男生 提交于 2021-01-29 10:12:26
问题 I would like to calculate the 10-fold cross-validated AUC of an elastic net regression model with the optimal alpha and lambda using caret::train https://stats.stackexchange.com/questions/69638/does-caret-train-function-for-glmnet-cross-validate-for-both-alpha-and-lambda/69651 explains how to cross-validate alpha and lambda with caret::train My question on Cross Validated got closed, because it has been classified as a programming question: https://stats.stackexchange.com/questions/505865/r

ValueError: Penalty term must be positive

一笑奈何 提交于 2021-01-29 07:22:18
问题 When I'm fit my model using logistic regression showing me a value error like ValueError: Penalty term must be positive. C=[1e-4, 1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3, 1e4] for i in C[-9:]: logisticl2 = LogisticRegression(penalty='l2',C=C) logisticl2.fit(X_train,Y_train) probs = logisticl2.predict_proba(X_test) getting error: ValueError: Penalty term must be positive; got (C=[0.0001, 0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0, 10000.0]) 回答1: Looking more closely, you'll realize that you are