I have a model which takes 2D input data and does multi class classification in keras. I would like to plot the probability calibration curve. However, using the scikit function, it returns an error saying that it cannot process 2D data. Please help.

My code is:

model= custom_model()
# define and fit calibration model
calibrated = CalibratedClassifierCV(model, method='sigmoid', cv=5)
calibrated.fit(x_train, y_train)

The error is:

Traceback (most recent call last):

   File "<ipython-input-41-bcfb033e1749>", line 1, in <module>
     yhat_calibrated = calibrated(x_train, x_test, y_train)

   File "<ipython-input-39-a3023fc5b92f>", line 100, in calibrated
     calibrated.fit(x_train, y_train)

 line 133, in fit

 line 756, in check_X_y

 line 570, in check_array
     % (array.ndim, estimator_name))

 ValueError: Found array with dim 3. Estimator expected <= 2.

If not scikit, are there any other libraries that can help?

  • $\begingroup$ have a look at what you feed in. The data has wrong dimensions. $\endgroup$
    – Peter
    May 30 '19 at 10:38
  • 1
    $\begingroup$ scikit calibrated.fit has support for 1D feature vectors ( batch_size, feature_dims). My data is 2D(batch_size, dim1, dim2) as in input to CNNs $\endgroup$ May 30 '19 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.