logistic-regression

Sklearn logistic regression - adjust cutoff point

人盡茶涼 提交于 2021-01-29 05:36:46
问题 I have a logistic regression model trying to predict one of two classes: A or B. My model's accuracy when predicting A is ~85%. Model's accuracy when predicting B is ~50%. Prediction of B is not important however prediction of A is very important. My goal is to maximize the accuracy when predicting A. Is there any way to adjust the default decision threshold when determining the class? classifier = LogisticRegression(penalty = 'l2',solver = 'saga', multi_class = 'ovr') classifier.fit(np

Plot of the LC50 Curve in R using ggplot2 with estimates obtained in the stan

假如想象 提交于 2021-01-28 19:34:44
问题 I'm trying to make the following graphic below in ggplot2. See that I am adjusting a logistic regression model under the Bayesian approach using the stan package. data: https://drive.google.com/file/d/1NNA6DFYFSVkwuL92RYe58E_Z99BXl7HE/view?usp=sharing library(dplyr) library(rstanarm) library(ggplot2) dados<- read.table("dados.csv", header = T, sep=";", dec = ",") dados$periodo <- as.factor(dados$periodo) dados <- dados %>% mutate(proporcao = (dados$resposta)/60) dados <- dados %>% mutate

confusionMatrix for logistic regression in R

我怕爱的太早我们不能终老 提交于 2021-01-28 07:52:52
问题 I want to calculate two confusion matrix for my logistic regression using my training data and my testing data: logitMod <- glm(LoanStatus_B ~ ., data=train, family=binomial(link="logit")) i set the threshold of predicted probability at 0.5: confusionMatrix(table(predict(logitMod, type="response") >= 0.5, train$LoanStatus_B == 1)) And the the code below works well for my training set. However, when i use the test set: confusionMatrix(table(predict(logitMod, type="response") >= 0.5, test

Explain matplotlib contourf function

感情迁移 提交于 2021-01-28 07:21:41
问题 I am trying to plot a decision region (based on the output of a logistic regression) with matplotlib contourf funtion. The code I am using: subplot.contourf(x2, y2, P, cmap=cmap_light, alpha = 0.8) where x2 and y2 are two 2D matrices generated via numpy meshgrids. P is computed using P = clf.predict(numpy.c_[x2.ravel(), y2.ravel()]) P = P.reshape(x2.shape) Each element of P is a boolean value based on the output of the logistic regresssion. The rendered plot looks like this My question is how

Logistic Unit Fixed Effect Model in R

只愿长相守 提交于 2021-01-27 22:44:52
问题 I'm trying to estimate a logistic unit fixed effects model for panel data using R. My dependent variable is binary and measured daily over two years for 13 locations. The goal of this model is to predict the value of y for a particular day and location based on x. zero <- seq(from=0, to=1, by=1) ids = dplyr::data_frame(location=seq(from=1, to=13, by=1)) dates = dplyr::data_frame(date = seq(as.Date("2015-01-01"), as.Date("2016-12-31"), by="days")) data = merge(dates, ids) data$y <- sample(zero

How does statsmodels encode endog variables entered as strings?

时光怂恿深爱的人放手 提交于 2021-01-27 21:53:11
问题 I'm new to using statsmodels to do statistical analyses. I'm getting expected answers most of the time but there are some things I don't quite understand about the way that statsmodels defines endog (dependant) variables for logistic regression when entered as strings. An example Pandas dataframe to illustrate the issue can be defined as shown below. The yN, yA and yA2 columns represent different ways to define an endog variable: yN is a binary variable coded 0, 1; yA is a binary variable

How to calculate nonlinear (binary) Fixed-Effects Logit for Longitudinal/Panel Data?

坚强是说给别人听的谎言 提交于 2021-01-27 14:35:57
问题 I'm trying to estimate child work based on a lagged variable on children's school aspirations. I'm deciding whether I should use glm or clogit to run my models (need fixed effect logits). When I run my glm, my coefficients are very different from my clogit. model1 <- glm(chldwork~lag_aspgrade_binned+age+as.factor(childid), data=finaletdtlag, family='binomial') GLM Output: Call: glm(formula = chldwork ~ lag_aspgrade_binned + age + as.factor(childid), family = "binomial", data = finaletdtlag)

regression models in r output table to word

吃可爱长大的小学妹 提交于 2021-01-27 06:33:49
问题 I have been using sjplot to create a combined table. This creates a HTML table. I would like to make a table that can be exported to word. I have reviewed this post which discusses copy and pasting into word, but this alters the formatting of the columns and lines. Output several regression tables into multiple pages of a Word document in R n1 <- glm(N ~ Age_2 , data = n_data, family = "binomial") g1 <- glm(G ~ Age_2 , data = g1_data, family = "binomial") ga1 <- glm(G_1 ~ Age_2 , data = ga1

regression models in r output table to word

寵の児 提交于 2021-01-27 06:33:01
问题 I have been using sjplot to create a combined table. This creates a HTML table. I would like to make a table that can be exported to word. I have reviewed this post which discusses copy and pasting into word, but this alters the formatting of the columns and lines. Output several regression tables into multiple pages of a Word document in R n1 <- glm(N ~ Age_2 , data = n_data, family = "binomial") g1 <- glm(G ~ Age_2 , data = g1_data, family = "binomial") ga1 <- glm(G_1 ~ Age_2 , data = ga1

regression models in r output table to word

吃可爱长大的小学妹 提交于 2021-01-27 06:32:29
问题 I have been using sjplot to create a combined table. This creates a HTML table. I would like to make a table that can be exported to word. I have reviewed this post which discusses copy and pasting into word, but this alters the formatting of the columns and lines. Output several regression tables into multiple pages of a Word document in R n1 <- glm(N ~ Age_2 , data = n_data, family = "binomial") g1 <- glm(G ~ Age_2 , data = g1_data, family = "binomial") ga1 <- glm(G_1 ~ Age_2 , data = ga1