Closed akshat-suwalka-dream11 closed 7 months ago
Hello @akshat-suwalka-dream11, Thank you for the comment and adding the code. It seems like this is not a MAPIE specific issue? I can't seem to understand where in your code you make use of the MAPIE library. Could you please provide more details?
It would seem your issue is regarding CatBoostRegressor
and in this case I suggest you ask your question to their Github.
I hope you find a solution.
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.
I have the save the model but while loading and predicting it is throwing error 'ConformalMultiQuantile' object has no attribute 'calibration_adjustments'
class ConformalMultiQuantile(CatBoostRegressor):
Store quantiles 0.005 through 0.99 in a list
quantiles = [q/200 for q in range(1, 200)]
Instantiate the conformal multi-quantile model
conformal_model = ConformalMultiQuantile(iterations=100, quantiles=quantiles, verbose=10)
Fit the conformal multi-quantile model
conformal_model.fit(X_train, y_train)
import os import pickle
Define the directory path and file name
directory_path = "/da/" file_name = "model_a.pkl" file_path = os.path.join(directory_path, file_name)
Create the directory if it doesn't exist
os.makedirs(directory_path, exist_ok=True)
Now you can save the model
with open(file_path, "wb") as f: pickle.dump(conformal_model, f)
import os import pickle
Define the directory path and file name
directory_path = "/da/" file_name = "model_a.pkl" file_path = os.path.join(directory_path, file_name)
Load the model
with open(file_path, "rb") as f: loaded_model = pickle.load(f)
preds_uncalibrated_1 = conformal_model.predict(X_test) preds_uncalibrated_2 = loaded_model.predict(X_test)
Error 12 preds_uncalibrated_1 = conformal_model.predict(X_test) preds_uncalibrated_2 = loaded_model.predict(X_test) AttributeError: 'ConformalMultiQuantile' object has no attribute 'calibration_adjustments'
AttributeError Traceback (most recent call last) File:2
1 preds_uncalibrated_1 = conformal_model.predict(X_test)
----> 2 preds_uncalibrated_2 = loaded_model.predict(X_test)
File:104, in ConformalMultiQuantile.predict(self, data, prediction_type, ntree_start, ntree_end, thread_count, verbose, task_type)
100 preds = super().predict(data, prediction_type, ntree_start, ntree_end, thread_count, verbose, task_type)
102 # Adjust the predicted quantiles according to the quantiles of the
103 # conformity scores
--> 104 if self.calibration_adjustments is not None:
106 preds = preds - self.calibration_adjustments
108 return preds