Plot Model
Analyzing performance of trained machine learning model is an integral step in any machine learning workflow. Analyzing model performance in PyCaret is as simple as writing plot_model. The function takes trained model object and type of plot as string within plot_model function.
Plots by Module
- Classification
- Regression
- Clustering
- Anomaly Detection
- Natural Language Processing
- Association Rule Mining
Classification
Name | Plot |
Area Under the Curve | ‘auc’ |
Discrimination Threshold | ‘threshold’ |
Precision Recall Curve | ‘pr’ |
Confusion Matrix | ‘confusion_matrix’ |
Class Prediction Error | ‘error’ |
Classification Report | ‘class_report’ |
Decision Boundary | ‘boundary’ |
Recursive Feature Selection | ‘rfe’ |
Learning Curve | ‘learning’ |
Manifold Learning | ‘manifold’ |
Calibration Curve | ‘calibration’ |
Validation Curve | ‘vc’ |
Dimension Learning | ‘dimension’ |
Feature Importance | ‘feature’ |
Model Hyperparameter | ‘parameter’ |
Code
# Importing dataset from pycaret.datasets import get_data diabetes = get_data('diabetes') # Importing module and initializing setup from pycaret.classification import * clf1 = setup(data = diabetes, target = 'Class variable') # creating a model lr = create_model('lr') # plotting a model plot_model(lr)
- AUC
- Confusion Matrix
- Threshold
- Precision Recall
- Error Plot
- Class Report
- Feature Selection
- Learning Curve
- Manifold Learning
- Calibration Curve
- Validation Curve
- Dimensions
- Feature Importance
- Decision Boundary
Regression
Name | Plot |
Residuals Plot | ‘residuals’ |
Prediction Error Plot | ‘error’ |
Cooks Distance Plot | ‘cooks’ |
Recursive Feature Selection | ‘rfe’ |
Learning Curve | ‘learning’ |
Validation Curve | ‘vc’ |
Manifold Learning | ‘manifold’ |
Feature Importance | ‘feature’ |
Model Hyperparameter | ‘parameter’ |
Code
# Importing dataset from pycaret.datasets import get_data boston = get_data('boston') # Importing module and initializing setup from pycaret.regression import * reg1 = setup(data = boston, target = 'medv') # creating a model lr = create_model('lr') # plotting a model plot_model(lr)
- Residuals
- Error Plot
- Cooks Distance
- Feature Selection
- Learning Curve
- Validation Curve
- Manifold
- Feature Importance
Clustering
Name | Plot |
Cluster PCA Plot (2d) | ‘cluster’ |
Cluster TSnE (3d) | ‘tsne’ |
Elbow Plot | ‘elbow’ |
Silhouette Plot | ‘silhouette’ |
Distance Plot | ‘distance’ |
Distribution Plot | ‘distribution’ |
Code
# Importing dataset from pycaret.datasets import get_data jewellery = get_data('jewellery') # Importing module and initializing setup from pycaret.clustering import * clu1 = setup(data = jewellery) # creating a model kmeans = create_model('kmeans') # plotting a model plot_model(kmeans)
Anomaly Detection
Name | Plot |
t-SNE (3d) Dimension Plot | ‘tsne’ |
UMAP Dimensionality Plot | ‘umap’ |
Code
# Importing dataset from pycaret.datasets import get_data anomalies = get_data('anomaly') # Importing module and initializing setup from pycaret.anomaly import * ano1 = setup(data = anomalies) # creating a model iforest = create_model('iforest') # plotting a model plot_model(iforest)
Natural Language Processing
Name | Plot |
Word Token Frequency | ‘frequency’ |
Word Distribution Plot | ‘distribution’ |
Bigram Frequency Plot | ‘bigram’ |
Trigram Frequency Plot | ‘trigram’ |
Sentiment Polarity Plot | ‘sentiment’ |
Part of Speech Frequency | ‘pos’ |
t-SNE (3d) Dimension Plot | ‘tsne’ |
Topic Model (pyLDAvis) | ‘topic_model’ |
Topic Infer Distribution | ‘topic_distribution’ |
Word cloud | ‘wordcloud’ |
UMAP Dimensionality Plot | ‘umap’ |
Code
# Importing dataset from pycaret.datasets import get_data kiva = get_data('kiva') # Importing module and initializing setup from pycaret.nlp import * nlp1 = setup(data = kiva, target = 'en') # creating a model lda = create_model('lda') # plotting a model plot_model(lda)
- Frequency Plot
- Distribution Plot
- Bigram
- Trigram
- Sentiments
- Part of Speech
- t-SNE
- uMAP
- Wordcloud
- Topic Distribution
- Topic Model
Association Rule Mining
Plot | Abbrev. String |
Support, Confidence and Lift (2d) | ‘frequency’ |
Support, Confidence and Lift (3d) | ‘distribution’ |
Code
# Importing dataset from pycaret.datasets import get_data france = get_data('france') # Importing module and initializing setup from pycaret.arules import * arul1 = setup(data = france, transaction_id = 'Invoice', item_id = 'Description') # creating a model model = create_model(metric = 'confidence') # plotting a model plot_model(model)
Try this next
Was this page helpful?
GitHub