Building a Classification Model with PyCaret
Python
In this example, we're using the PyCaret library to train a classification model. First we initialize the setup for the dataset which in this case is the Titanic dataset. Then we compare different classification models, select the best one before training a final model. Lastly, we make predictions on the test dataset using the trained model.
1| from pycaret.classification import * 2| 3| # Initialize setup 4| setup(train, target='Survived') 5| 6| # Compare different models and choose the best one 7| best_model = compare_models() 8| 9| # Train the chosen model 10| model = create_model(best_model) 11| 12| # Make predictions on test data 13| predictions = predict_model(model, data=test)
147
131
125
118