All Questions
55 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: ...
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 ...
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 ...
-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 ...
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 ...
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('...
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 ...
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)
...
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) ...
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. ...
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')]...
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 ...
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 ...
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 ...
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 ...