Posted on:

06 Nov 2024

0

Section 6 - Class 43. Build a logistic regression model with p-values

Got the following error when trying to fit the model (and in the backend run the code you provided for the LogistRegression_with_p_values):

UFuncTypeError                            Traceback (most recent call last)
Cell In[188], line 1
----> 1 reg.fit(inputs_train, loan_data_targets_train)
 
Cell In[184], line 18, in LogisticRegression_with_p_values.fit(self, X, y)
     16 denom = np.tile(denom,(X.shape[1],1)).T
     17 F_ij = np.dot((X / denom).T,X)
---> 18 Cramer_Rao = np.linalg.inv(F_ij)
     19 sigma_estimates = np.sqrt(np.diagonal(Cramer_Rao))
     20 z_scores = self.model.coef_[0] / sigma_estimates
 
File ~\anaconda3\Lib\site-packages\numpy\linalg\linalg.py:561, in inv(a)
    559 signature = 'D->D' if isComplexType(t) else 'd->d'
    560 extobj = get_linalg_error_extobj(_raise_linalgerror_singular)
--> 561 ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
    562 return wrap(ainv.astype(result_t, copy=False))
 
UFuncTypeError: Cannot cast ufunc 'inv' input from dtype('O') to dtype('float64') with casting rule 'same_kind'
Could you please help me to understand how can we fix that?

Thank you.
0 answers ( 0 marked as helpful)

Submit an answer