The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Anybody can ask a question
Anybody can answer
The best answers are voted up and moderated by our team

Credit Risk Modeling PD Model Estimation

Credit Risk Modeling PD Model Estimation


When estimating the PD Model with Logistic Regression I am getting a Value error on the lecture code: ”

ValueError                                Traceback (most recent call last)
<ipython-input-32-966f89d3c717> in <module>
----> 1, loan_data_targets_train)
      2 # Estimates the coefficients of the object from the 'LogisticRegression' class
      3 # with inputs (independent variables) contained in the first dataframe
      4 # and targets (dependent variables) contained in the second dataframe.

~/opt/anaconda3/lib/python3.7/site-packages/sklearn/linear_model/ in fit(self, X, y, sample_weight)
   1526         X, y = check_X_y(X, y, accept_sparse='csr', dtype=_dtype, order="C",
-> 1527                          accept_large_sparse=solver != 'liblinear')
   1528         check_classification_targets(y)
   1529         self.classes_ = np.unique(y)

~/opt/anaconda3/lib/python3.7/site-packages/sklearn/utils/ in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, warn_on_dtype, estimator)
    753                     ensure_min_features=ensure_min_features,
    754                     warn_on_dtype=warn_on_dtype,
--> 755                     estimator=estimator)
    756     if multi_output:
    757         y = check_array(y, 'csr', force_all_finite=True, ensure_2d=False,

~/opt/anaconda3/lib/python3.7/site-packages/sklearn/utils/ in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
    576         if force_all_finite:
    577             _assert_all_finite(array,
--> 578                                allow_nan=force_all_finite == 'allow-nan')
    580     if ensure_min_samples > 0:

~/opt/anaconda3/lib/python3.7/site-packages/sklearn/utils/ in _assert_all_finite(X, allow_nan, msg_dtype)
     58                     msg_err.format
     59                     (type_err,
---> 60                      msg_dtype if msg_dtype is not None else X.dtype)
     61             )
     62     # for object dtype data, we only check for NaNs (GH-13254)

ValueError: Input contains NaN, infinity or a value too large for dtype('float64')"
It works fine in the video lecture, but the same code won't run in jupyter. Can you help me please?
1 Answer

365 Team

Hi Mariam, 
thanks for reaching out and sorry for the late response. 
Could you please provide a lecture link to the video, where you’re experiencing difficulties?
Thanks so much in advance!
365 Eli

Complete Data Science Education
Get 50% OFF