Skip to main content

All Questions

0 votes
0 answers
54 views

Why am I getting RunTime warning while computing cost function for logistic regression?

<ipython-input-20-5561a7703323>:8: RuntimeWarning: divide by zero encountered in log cost=(-y[i]*np.log(g_i) - (1-y[i])*np.log(1-g_i)) <ipython-input-20-5561a7703323>:8: RuntimeWarning: ...
Mridul Hemrajani's user avatar
0 votes
0 answers
287 views

statsmodel multinomial logistic regression outputs all nan values

I'm trying to fit a multinomial logreg with statsmodel. X = sm.add_constant(df) logreg_model = sm.MNLogit(y[:n], X).fit() Where df is a one row dataframe (just because I'm trying each variable ...
pedritoanonimo's user avatar
0 votes
0 answers
162 views

Getting this error: This solver needs samples of at least 2 classes in the data, but the data contains only one class: '2'

I have a code that is supposed to do these things: Load already trained model Load an unseen dataset Create a pipeline which takes Bert encoder (SentenceTransformer('all-mpnet-base-v2')) and my ...
Python-data's user avatar
-1 votes
1 answer
107 views

Got "MinMaxScaler is expecting 17625 features as input." error while preprocessing dataset

I'm trying to preprocess a large gene data set in order to predict some targets. After splitting into train and test. I removed all features that had over 25% 0's across all rows in the X train, then ...
Jasoosa's user avatar
  • 13
1 vote
1 answer
2k views

LogisticRegression is expecting 17388 features as input

I am trying to create a model using Logistic Regression that will predict an endpoint. However, when running the last line of code shown below, I keep getting the error "X has 23146 features, but ...
Jasoosa's user avatar
  • 13
1 vote
1 answer
8k views

ValueError: [TypeError("'numpy.int32' object is not iterable"), TypeError('vars() argument must have __dict__ attribute')]

I'm running my LogicRegression model using FastApi locally(127.0.0.1). Then it occurred ValueError just like this: ValueError: [TypeError("'numpy.int32' object is not iterable"), TypeError('...
Eureka's user avatar
  • 21
0 votes
1 answer
156 views

Threshold does not work on numpy array for accuracy metric

I am trying to implement logistic regression from scratch using numpy. I wrote a class with the following methods to implement logistic regression for a binary classification problem and to score it ...
R00's user avatar
  • 73
2 votes
1 answer
102 views

My code giving differnt result where as the same code in my Machine learning assignment expects a different result?

MY CODE def lrCostFunction(theta, X, y, lambda_): m = y.size if y.dtype == bool: y = y.astype(int) tempt = theta tempt[0] = 0 J = 0 grad = np.zeros(theta.shape) ...
MBAQ's user avatar
  • 31
0 votes
0 answers
788 views

Adam optimization for gradient descent update doesn't seem to work with logistic regression

Helo, I'm learning machine learning from first principle, so i coded up logistic regression with back prop from scratch using numpy and calculus. Updating derivative with weighted average (momentum) ...
superbik's user avatar
4 votes
2 answers
247 views

Vectorized Regularized Gradient Descent not passing numerical check

I've written an implementation in Python using NumPy of vectorized regularized Gradient descent for logistic regression. I've used a numerical check method to check that my implementation is correct. ...
MitakaJ9's user avatar
  • 311
0 votes
0 answers
308 views

Trying to run Logistic regression model using categorical variables, but can't change dtype from object

I had several categorical variables that I created dummies for: #Create Dummy Variables with get_dummies (for Diabetes) new_df = pd.concat([new_df,pd.get_dummies(new_df['DIABETES'],prefix='DIABETES')]...
dwool's user avatar
  • 29
0 votes
1 answer
644 views

Logistic regression from scratch

I am implementing multinomial logistic regression using gradient descent + L2 regularization on the MNIST dataset. My training data is a dataframe with shape (n_samples=1198, features=65). On each ...
Isaac's user avatar
  • 43
0 votes
1 answer
949 views

Looping Logistic Regression over DataFrame in Python

I am stuck on where I am going wrong with this loop to perform Logistic Regression on a dataframe with 25 features. When I reshape it giving the error : "ValueError: Expected 2D array, got 1D ...
thejahcoop's user avatar
1 vote
1 answer
2k views

PYTHON : IndexError: index 2 is out of bounds for axis 0 with size 2

This was my piece of code initially : Here X is the array of data points with dimensions (m x n) where m is number of data points to predict, and n is number of features without the bias term. y is ...
Savannah Madison's user avatar
1 vote
1 answer
1k views

What is wrong with my custom logistic regression implementation?

I am trying to reflect almost the same results as sklearn would give but I am not getting good results. The values of intercepts from my custom implementation and sklearn's implementation have a ...
Akshay Panwar's user avatar

15 30 50 per page