Closed mvpalheta closed 3 years ago
Well, the predicted probabilities are those calculated by the model that you supplied to the ClassifierExplainer
, so the result of model.predict_proba(X)
.
So I'm not sure why you would want to change those, but if you really do, you can just monkeypatch them. They get calculated and assigned to explainer._pred_probas
, with this line of code: self._pred_probas = self.model.predict_proba(self.X)
, so if you really want to override those, then just do it manually:
explainer = ClassifierExplainer(model, X_test, y_test)
explainer._pred_probas = some_numpy_array
What is your usecase though? Why would you want to override them? If you want to pick a different positive class, you can just supply the parameter pos_label
, or even set it afterwards:
explainer = ClassifierExplainer(model, X_test, y_test, pos_label=1)
explainer.pos_label = 3
I want to use the package to facilitate the development of dashboards for monitoring models in production. in several real cases the final predicted probabilities are a mix of probability of the model plus adjustments, based on some factors. this is my case. I already have the final predicted probabilities in my database so it would be easier to use them than to replicate the entire flow in python.
Ah, gotcha, then the monkeypatch outlined above should work.
Hi, the dashboard system is not compatible with classifiers other than RandomForest ? (such LogisticRegression, Extra tree, svm...) Thanks
All sklearn compatible models should work! (although I haven't tested svm yet)
even with LogisticRegression, extra trees not! AttributeError: 'ClassifierExplainer' object has no attribute 'no_of_trees'
Ah, yes, the tree visualizer onlyworks with scikit-learn RandomForestClassifier and RandomForestRegressor and xgboost XGBClassifier and XGBRegressor. Could probably get it too work with ExtraTrees without too much work. And LightGBM should also get supported by dtreeviz soon so then I will add support for that as well.
LogisticRegression is already supported though!
is there any way to use my own predicted probabilities instead of those calculated by ClassifierExplainer?