Questions tagged [logistic-regression]

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

0
votes
0answers
23 views

How to deal with binary predictors in a logistic regression model? [migrated]

I'm building a logistic regression model in R using glm(y ~ x1 + x2 + x3 + x4, data = train.set, family = binomial(link = 'logit')). Among 4 predictors x1, x2, x3, x4, they all are categorical. ...
1
vote
1answer
26 views

Python Vanilla Code for simple Logistic regression

Given the Coefient and intercept, How to manually compute the Probability and Predict score for Logistic regression. from sklearn.linear_model import LogisticRegression X=data_X.values y=data_Y clf =...
0
votes
0answers
8 views

Should I change the lambda parameter in L2 regularisation whilst my model suffers from overfitting?

I have trained a neural network that on the training set gives 0.5% error but on the test set 7% so there is a clear overfitting. I have used $L_2$-regularisation. Should I increase or decrease the $\...
0
votes
0answers
40 views

Calculating Odds Ration using glm function [on hold]

I need to find the odds ratio with predictive factors of age, cholesterol, and insurance type, with the outcome called dm, which is either yes or no. I have tried the following code, and other ...
0
votes
1answer
24 views

Predicting not possible due to mismatch of features

I use sklearn to create a logistic regression model based on a xlsx-file. I remove some target and redundant features from the dataset. Now I want to make a prediction and want to get the label based ...
0
votes
0answers
41 views

Logistic regression with custom dataset

From deeplearning course on Coursera I've implemented logistic regression : import numpy as np from sklearn.datasets import load_iris import matplotlib.pyplot as plt def sigmoid(z): s = 1 / (1 +...
0
votes
1answer
22 views

How to make prediction with single sample in sklearn model.predict?

I trained a logistic regression model with some data. I applied standard scalar to train and test data, trained model. But if I want to make prediction with the model with the data outside the train ...
0
votes
0answers
11 views

Percentages as both dependent and independent variables [closed]

I need to do different types of regression: 1) dependent variable expressed as percentage (continuous in [0;1]), independent variable is a running variable (continuous in [0;+inf[) 2) both dependent ...
1
vote
0answers
10 views

Discrepancy in Results from epiDisplay ordinal.or.display p value and calculated p for polr from MASS package?

I am trying to calculate Odds Ratios and associated p-values for a set of biomarkers using ordinal logistic regression (specifically, polr from MASS package). I've been using the 'ordinal.or.display()'...
-3
votes
2answers
27 views

ValueError: This solver needs samples of at least 2 classes in the data, but the data contains only one class: False

I have a example dict starting like this {'first': {'second': [], 'third': 1.0, 'fourth': {'fifth': 'test', 'value': 2.0}, 'sixth': {'seventh': 3.0, 'eight': 4.0, I tried this y_test = np....
0
votes
0answers
14 views

Issues with a neural network multinomial logistic regression in R, error with NA/NaN argument and warning about numerical expression

I am using R with the nnet package to perform a multinomial logistic regression on a training dataset with ~5800 training dataset records and 45 predictor variables in that training data. Predictor ...
0
votes
0answers
9 views

Predictor values corresponding to main probability levels in case of possibly multilevel factor predictor variables in logistic regession in R?

Full question (with >150 characters): How to handle predictor values corresponding to p=0.25,0.50,0.75 probability levels in case of possibly multilevel factor (categoric) predictor variables in ...
0
votes
0answers
14 views

Neural Network and Logistic regression - Bias and weights initialization

I want define a simple neural network to compute alogistic regression for two classes (0 and 1) and the following data as training set: (1, 2) -> 0 (2, 2) -> 0 (3, 4) -> 1 (4, 4) -> 1 (5, ...
0
votes
0answers
14 views

Getting LinAlgError: Singular matrix error on the same data and code

I am trying to build a logistic regression model in python using sklearn and statsmodel. However i get the singular matrix error. My Data set has 273 variables with a 80 20 split of the target. The ...
1
vote
1answer
19 views

How to fix “The metric ”Accuracy“ was not in the result set. AUC will be used instead”

I am trying to run a logistic regression on a classification problem the dependent variable "SUBSCRIBEDYN" is a factor with 2 levels ("Yes" and "No") train.control <- trainControl(method = "...
1
vote
2answers
37 views

How to obtain the ggplot graph for the logistic regression imitation in Wikipedia's example in R?

(reproducible example added) I tried to imitate the Wikipedia's "Probability of passing an exam versus hours of study" logistic regression example here: I could not obtain the same ggplot graph in ...
-1
votes
0answers
19 views

How to plot regression coefficient changes over time [closed]

I am using the normal multivariate regression model (OLS) and the probit model (logistic regression). I constantly feed new data for the model, so the coefficients of the regressions (OLS and probit) ...
0
votes
0answers
5 views

using logistic function to fit function, visually i see the curve doesn't match, but the model score is high - howcome?

i have a data set with x axis composed of values between [100-350] and y axis binary 0's and 1's. i used sklearn logistic regression to find the logistic function that will fit my data most ...
0
votes
1answer
33 views

How to increase false positives and reduce false negatives in a logistic regression?

The results I am getting in a record linkage problem is classifying more values as false positives than false negatives. Is there a way to balance these? # Initialize the classifier logreg = rl....
0
votes
1answer
40 views

Obtaining wrong error-curve for logistic regression (Bug in Code)

I started machine learning and wrote this code. But for some reason I am getting zig-zag error curve instead of a decreasing logarithmic curve. The "form_binary_classes" for now does nothing but take ...
0
votes
1answer
29 views

Does logistical regression is the better method for creating a Scoring Model?

I have a data-set of user details, in which I want to generate a score for each user. The needed output range looks like low, medium and high.I am working on logistical regression. Is that the right ...
1
vote
0answers
14 views

Always getting accuracy of 1 how to fix it?

I'm trying to apply logistic regression on my dataset but its giving accuracy of 1 df = pd.read_csv("train.csv", header=0) df = df[["PassengerId", "Survived", "Sex", "Age", "Embarked"]] df.dropna(...
0
votes
0answers
14 views

How to create proper data set for logistic regression in Python (based on DFS)?

I have to implement logistic regression in Python to find the path to the goal based on my data sets. My question is how to create proper dataset and how to use it for machine learning. As you can ...
-1
votes
0answers
74 views

How to fix “ Empty 'DataFrame': no numeric data to plot” and KeyError “Class”

I'm trying to predict heard disease in patients by using different machine learning algorithems like linear regression, KNeighbor classifier etc. My dataset have 14 attributes and 304 entities. But it ...
1
vote
0answers
28 views

How to test logistic regression code written from scratch?

I have written a logistic regression program scratch using numpy. Can you guys give me some pointer to how to test the code? I tried using a spam email database, but it is huge. I can't debug. Is ...
0
votes
2answers
48 views

How can i iterate over a 'list' of models in python with scikit learn?

I built a function that displays some evaluation metrics for a single model, and now I want to apply this function to a pool of models I have estimated. The inputs of the old function was: ...
0
votes
1answer
15 views

how to model all relationships between independent variables in R?

I have a small data set with 4 independent (call them a, b, c, d) and 1 dependent variables. Since there are few independent variables, I want to explore all combinations of these variables. There can ...
0
votes
1answer
32 views

Hot to avoid Python Dask Logistic regression Multiple constant columns detected error

I am using python3 with Dask for fitting a logistic regression model. I have two numpy arrays x, y And I use this code to convert them into dask arrays data = da.from_array(data, chunks=(1000, data....
1
vote
1answer
36 views

Understanding the mathematical expression of cost function

It is very naive of me, but I am not able to get this expression for cost function: ||y - Xw||^2_2 + alpha * ||w||^2_2 What does the 2_2 mean? It is mentioned on Scikit-Learn web page.
-1
votes
0answers
17 views

How to apply a logistic.display()-like function (from epiDisplay pckg) to a Firth's regression (generated with logistf and brglm)

I have generated two objects (Firth's regressions from brglm and logistf) and I would like to display them as in the logist.display() function of the epiDisplay package. Would it be possible? Do I ...
-2
votes
0answers
33 views

How create logistic regression with spark on numeric data

It is my first course of spark . Im doing Logistic regression with spark using data existing in this link Can anyone that can help me to do it? My code is train, test = df.randomSplit([0.7, 0.3], ...
0
votes
0answers
22 views

How to create a data frame in the success/number of trials format for elrm starting from excel

I'm trying to generate a data frame in the success/number of trials syntax in order to proceed with an Exact logistic regression (as shown here https://stats.idre.ucla.edu/r/dae/exact-logistic-...
0
votes
0answers
20 views

Build model for daily probability of meeting a certain end of period goal [migrated]

I was hoping for some consultation with how to go about the following: To give context, I work for an agency that manages advertisements on social media for general motors - specifically their car ...
0
votes
0answers
6 views

StepAIC throwing error as “Error in x[good, , drop = FALSE] : (subscript) logical subscript too long”

I am working on a mortality prediction model with logistic regression setup. To select variables, I am running stepwise regression on the model through stepAIC function of MASS package. I had been ...
0
votes
0answers
6 views

Prediction table

I just completed running predictions in logistic regression and I wrote a code to display my predictions and few features in a tabular format but I got an error. I have written a code to have 3 ...
-1
votes
0answers
23 views

An unexpected result after multinomial regression on iris dataset with SGD

I tried to implement a logistic regression based on Multi layer Perceptron and SGD optimizer on the iris dataset and the results seem odd. I only get 66% accuracy after 5 epoch (all the versicolor ...
0
votes
0answers
13 views

How can I make spatial predictions for a raster stack with a 'lrm' model (rms package)?

I have fitted a logistic regression model using 'lrm' function of 'rms' package and I need to make spatial predictions for a stack of rasters (one for each of my predictors). I've tried to use '...
1
vote
1answer
19 views

How can i make the run time of Multi-Class Classification faster?

I'm trying to train and run Multi-Class classifiers for Random Forest and Logistic Regression. As of now on my machine which has an 8GB RAM and an i5 core, it's taking quite some time to run inspite ...
0
votes
0answers
23 views

scipy optimize not working where same code is working in matlab

I am trying to implement logistic regression in python without sckitlearn, my code seems fine but none of the optimize algorithm is able to find the optimum value for parameter(coefficients) I also ...
0
votes
0answers
12 views

“ a valid collection.” % x) TypeError: Singleton array array(<map object at 0x0E9735B0>, dtype=object) cannot be considered a valid collection

I have this error : It seems that it the map function causing problem but I do not know. nal Accuracy: 0.382 Traceback (most recent call last): File "VerbatimFM.py", line 120, in <module> ...
1
vote
1answer
33 views

Space between categories on the y-axis

I'm plotting a graph of odds-ratios and confidence intervals, and would like to have space in between the different categories of variables on the y-axis, but I'm having trouble doing that. Here is ...
1
vote
2answers
32 views

How to see the parameters LogisticRegression() has found where the cost is minimal?

With sklearn's LogisticRegression(), how can I see the parameters it has found after .fit() where the cost is minimal? I use the book of Geron about scikit-learn and tensorflow and on page 137 he ...
1
vote
2answers
31 views

How to use logistic regression on test data

I am using Logistic Regression on my Titanic model and PyCharm is asking me to pass DataFrames with bool values only: Traceback (most recent call last): File "C:/Users/security/Downloads/AP/Titanic-...
0
votes
1answer
22 views

Logistic Regression SKLEARN could not convert string to float: 'DailyReturns'

Trying to run Logistic regression but I am getting this error could not convert string to float: 'DailyReturns' I have checked my data DailyReturns is the column name. Also: apple['DailyReturns']....
0
votes
0answers
19 views

Logistic Regression is all about stats?

Following the iris DataSets exemples , I tried to make my first Logistic Regression. My X is the number of words in a sentence and I would like (with the help of other parameters but later) to find ...
1
vote
0answers
44 views

Mixed effects model on time series in R

I want to run a mixed effects logistic regression model on a time series in R to determine which predictor variables are significant and whether they vary in importance over the time series. I have ...
-1
votes
1answer
18 views

How to force binary classification into multinomial classification

It's known that logistic regression for 2 classes will give us the probability for the first class and then using threshold we can decide which class it's in. Whereas, in multinomial classification, ...
0
votes
0answers
16 views

Advice for Logistic Regression Programming in Python

As a training project, I was asked to write a multinomial logistic regression Python program, run it on a dataset, and compare it with a "standard" logistic regression program. The dataset (after a ...
0
votes
0answers
20 views

What is the purpose of Logit function? At what stage of model building process this logit function is used?

We have two prominent functions (or we can say equations) in logistic regression algorithms: Logistic regression function. Logit function. I would like to know: Which of these equation(s) is/are ...
0
votes
0answers
20 views

How to fix ValueError: Unknown label type: 'continuous' when using Logistic Regression

I am trying to use Logistic Regression to measure the following: Best Parameters, Best Cross-Validation Score, and Test score. I am using this dataset https://www.kaggle.com/ashaheedq/video-games-...