Comments (5)
This code address both concerns but @bbengfort maybe you have a better trick to stop showing the plot. I feel like we answered this question before.
from yellowbrick.classifier import ClassificationReport, ConfusionMatrix
from sklearn import datasets
from sklearn.model_selection import train_test_split
import xgboost as xgb
import matplotlib.pyplot as plt
X, y = datasets.load_iris(return_X_y=True)
x_train, x_val, y_train, y_val = train_test_split(X,y,stratify=y,test_size = 0.2)
model = xgb.XGBClassifier(objective ='multi:softprob',
num_class=3,
use_label_encoder=False,
enable_categorical=False,
n_estimators=10)
model.fit(x_train,
y_train,
early_stopping_rounds=10,
eval_set=[(x_train, y_train), (x_val, y_val)])
# Specify class counts on the model
model.class_counts_ = 3
fig, ax = plt.subplots()
visualizer = ClassificationReport(model, is_fitted=True)
visualizer.score(x_val, y_val)
# Clear Figure works but @bbengfort might have a better approach
visualizer.show('test.png', clear_figure=True);
from yellowbrick.
@lwgray thank you for adding those suggestions!
@ggous if you're in a Jupyter notebook, this StackOverflow post has some suggestions for preventing the image from being rendered. Otherwise clear_figure
as @lwgray mentioned is probably your best bet.
from yellowbrick.
@ggous thank you for using Yellowbrick and for reporting the issue that you found to us! I hope that you're finding Yellowbrick useful.
In order to use the ClassificationReport
the model needs the class_counts_
learned attribute. This appears in most scikit-learn classifiers. I believe the xgb
package adds learned attributes if it understands it's in a scikit-learn context. I am not really sure why it doesn't have it when you fit the model and after -- I don't use the xgb
package very often.
Could you try directly adding class_counts_
to the model before creating the visualizer to see if that helps things?
@lwgray do you have experience using xgb
-- if so, perhaps you could comment on this issue?
from yellowbrick.
Hi bbengfort.
I can't find an attribute of class_counts_
in xgb.
I am not sure how to add it before the visualizer.
from yellowbrick.
Also, is there a way for only saving the visualizer without showing it?
I am using visualizer.show(outpath='./file.png')
but I want only to save , not to display the result plot.
from yellowbrick.
Related Issues (20)
- learning curve visualizer for catboost automl using Pipelines HOT 2
- Radviz error from DataFrame which doesn't have sequantial index HOT 3
- How not to plot legend in RadViz plot? HOT 4
- On the generation of RadViz plot HOT 1
- Use classification visualizers directly from predictions, targets and logits? HOT 1
- [SilhouetteVisualizer] Constructor argument is_fitted is ignored during initialization HOT 1
- ConfusionMatrix visualizer error with sklearn models HOT 3
- Is there a way to hide the figure from KElbowVisualizer? HOT 3
- Let `KElbowVisualizer` use all the distance metrics supported by sklearn HOT 5
- The PredictionError can't be visualized due to the dim error HOT 2
- Adjusting markersize in `prediction_error` HOT 2
- Matplotlib warning about color usage in Datasaurus
- No figure output of the show method and produce a lot of findfont: Generic family 'sans-serif' not found warnings HOT 2
- Unable to use Silhouette Visualizer with Gaussian Mixture Model HOT 7
- Can't plot class report with trained model HOT 1
- Interactive plots - support plotly backend. HOT 4
- InterclusterDistance AttributeError: 'NoneType' object has no attribute '_get_renderer' HOT 2
- Add arguments to change PCA biplot arrow and arrow label colors and other properties HOT 1
- yellowbrics conflict with matplotlib: use_line_collection in cause!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yellowbrick.