Search⌘ K
AI Features

Building the Model

Explore how to build a classification model using PyCaret, including training with stratified k-fold cross-validation. Learn to tune hyperparameters to improve model accuracy, make predictions on test data, visualize results with plots, and finalize and save the model for deployment. This lesson provides hands-on guidance for effective classification model development.

Creating the model

We’ll use the create_model() function to train the Linear Discriminant Analysis model because it performed best in the model comparison.

Python 3.5
# Creating the model
model = create_model('lda')

Model


Accuracy

AUC

Recall

Prec.

F1

Kappa

MCC

0

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

1

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

2

0.9167

1.0000

0.9167

0.9333

0.9153

0.8750

0.8843

3

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

4

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

5

0.9167

1.0000

0.9167

0.9333

0.9153

0.8750

0.8843

6

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

7

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

8

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

9

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

1.0000

Mean

0.9833

1.0000

0.9833

0.9867

0.9831

0.9750

0.9769

SD

0.0333

0.0000

0.0333

0.0267

0.0339

0.0500

0.0463

This function uses stratified kk-fold cross-validation to evaluate model accuracy, a variation of the standard kk-fold technique used in the Regression chapter. The dataset is consecutively partitioned into ...