Questions tagged [logistic-regression]

Logistic regression is a statistical classification model used for making categorical predictions.

Logistic regression is a statistical analysis method used for predicting and understanding categorical dependent variables (e.g., true/false, or multinomial outcomes) based on one or more independent variables (e.g., predictors, features, or attributes). The probabilities describing the possible outcomes of a single trial are modeled as a function of the predictors using a logistic function (as it follows):

enter image description here

A logistic regression model can be represented by:

enter image description here

The logistic regression model has the nice property that the exponentiated regression coefficients can be interpreted as odds ratios associated with a one unit increase in the predictor.

Multinomial logistic regression (i.e., with three or more possible outcomes) are also sometimes called Maximum Entropy (MaxEnt) classifiers in the machine learning literature.


Tag usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

3746 questions
1
vote
1 answer

Getting incorrect values of theta while trying to implement stochastic gradient descent

I am trying to implement Stochastic Gradient Descent algorithm for logistic regression. I have written a small train function whose job is to get the theta values / coefficients. But the values of theta come out to be incorrect and are same as the…
Jatt
  • 665
  • 2
  • 8
  • 20
1
vote
1 answer

scikit-learn LogisticRegressionCV: best coefficients

I am trying to understand how the best coefficients are calculated in a logistic regression cross-validation, where the "refit" parameter is True. If I understand the docs correctly, the best coefficients are the result of first determining the…
1
vote
1 answer

Logistic regression gradient descent algorithm returns different coefficients from R's built in GLM function

I have been trying to program a gradient descent algorithm in R for logistic regression in order to understand it better. In Andrew NG's ML course they seem to skip this part and instead show the advanced optimization approach. However, I would like…
pd441
  • 2,644
  • 9
  • 30
  • 41
1
vote
1 answer

loop for writing a multivariate binary logistic regression analysis

df <- data.frame( disease = c(0,1,0,1), var1 = c(0,1,2,0), var2 =c(0,1,2,0), var3 = c(0,1,2,0), var40 = c(0,1,2,0), Bi = c(0,1,0,1), gender = c(1,0,1,0), P1 = c(-0.040304832,0.006868288,0.002663759,0.020251087), P2 =…
1
vote
1 answer

How can I figure out which label each set of coefficients in LogisticRegression.coef_ maps to in sklearn?

I've trained a number of Logistic Regression models for a project that I am working on. I've attained the coefficients of my features using the coef attribute. However, as I have four different target labels, the output consists of four sets of…
1
vote
0 answers

Create a binary matrix where columns equals rows

I am trying to run a regression of a list of bond's values against the credit (S&P) rating of the bond. For that I am trying to create a binary matrix of where the columns (a list of all available S&P credit rating [AAA, AA+,..., BBB-, etc..]). My…
1
vote
2 answers

How can I voluntarily overfit my model for text classification

I would like to show an example of a model that overfit a test set and does not generalize well on future data. I split the news dataset in 3 sets: train set length: 11314 test set length: 5500 future set length: 2031 I am using a text dataset and…
rolele
  • 781
  • 9
  • 24
1
vote
1 answer

Scaling data using pipelines in scikit-learn: StandardScaler vs. RobustScaler

I would like to use GridSearchCV to determine the optimal regularization parameter "C" in a logistic regression with L1 regularization. I would also like to scale/standardize my input features. Scaling the entire training dataset with a single…
1
vote
0 answers

How to find accuracy for logistic regression and gradient descent with training and validation data sets?

I am trying to implement logistic regression with gradient descent on the notMNIST dataset. This is my code thus far, which parses the data and plots the accuracy against the epochs. I have done my training in 7 mini batches of 500 each. There are a…
1
vote
0 answers

Spark 2.x - Running Logistic with word2vec or HashingTF

I am running a Logistic Regression with the following code given at https://spark.apache.org/docs/2.2.0/ml-pipeline.html (Example: Pipeline) Original Code from Link... import org.apache.spark.ml.{Pipeline, PipelineModel} import…
1
vote
1 answer

Manually build logistic regression model for prediction in Sklearn

I wonder how to build a LogisticRegression model "m" manually by setting explicit the values for m.coef_ and m.intercept_. This sounds weird but in some cases I try to classify data where all cases are negativ (0) and the fit of the model gives an…
Grisuji
  • 25
  • 7
1
vote
1 answer

choose logistic regression or decision tree

I have i project where the features are 0 or 1 (it means YES or NO) and labels are from 0 to 9. The application will ask 100 questions to the user and answers will be 0 or 1 (the features). From those question I will tell him which label is…
1
vote
1 answer

python scikit learn logistic regression error

I am trying to plot a logistic regression graph from the following data X = np.array([0,1,2,3,4,5,6,7,8,9,10,11]) y = np.array([0,0,0,0,1,0,1,0,1,1,1,1]) However when I try: import numpy as np import matplotlib.pyplot as plt from sklearn import…
spicy burrito
  • 187
  • 4
  • 12
1
vote
1 answer

Can we use Logistic Regression to predict numerical(continuous) variable i.e Revenue of the Restaurant

I have been given a task to predict the revenue of the Restaurant based on some variables can i use Logistic regression to predict the Revenue data. the dataset is of kaggle Restaurant Revenue Prediction Project. PS :- I have been told to use…
1
vote
1 answer

How to Add Labels in SAS Logistic Regression Procedure

I am looking for a way to add labels to the predictors in a logistic regression procedure (aka proc logistic), so that in the result, I can read the labels instead of acronyms of the predictors. I tried to add the labels in the data step, and then…
Counter10000
  • 525
  • 1
  • 8
  • 25