
Introduction to PyCaret 3.4
Welcome to the world of PyCaret 3.4! This open-source, low-code machine learning library in Python is designed to simplify and accelerate your machine learning workflows. With PyCaret, you can transform what used to take hundreds of lines of code into just a few, making your experiments exponentially faster and more productive.
Inspired by the R programming language’s caret library, PyCaret serves as a convenient wrapper around popular libraries like scikit-learn, XGBoost, CatBoost, and more. It effectively caters to both experienced data scientists and enthusiastic learners alike.
How to Install PyCaret
Installing PyCaret is straightforward and can be done in three different ways:
Option 1: Install via PyPi
PyCaret is tested and supported on 64-bit systems with:
- Python versions: 3.9, 3.10, 3.11, and 3.12
- Ubuntu version: 16.04 or later
- Windows version: 7 or later
To install:
pip install pycaret
If you need optional dependencies, you can install them individually as follows:
pip install pycaret[analysis]
pip install pycaret[models]
Option 2: Build from Source
To install the development version directly from the source, run:
pip install git+https://github.com/pycaret/pycaret.git@master --upgrade
Option 3: Docker
For a separate environment, using Docker is an excellent choice. You can run a pre-installed version of PyCaret in a Jupyter notebook:
docker run -p 8888:8888 pycaret/slim
Quickstart: Using PyCaret
Let’s dive into a simple example of using PyCaret with two approaches: the Functional API and the OOP API.
1. Functional API
# Loading the sample dataset
from pycaret.datasets import get_data
data = get_data('juice')
# Initialization
from pycaret.classification import *
s = setup(data, target='Purchase', session_id=123)
# Model Training
best = compare_models()
# Evaluate the model
evaluate_model(best)
# Predict on new data
new_data = data.copy().drop('Purchase', axis=1)
predictions = predict_model(best, data=new_data)
# Save the model
save_model(best, 'best_pipeline')
Think of using PyCaret as being a master chef in a kitchen. Each function is like a specific tool—a knife for chopping, a pot for boiling—that allows you to handle various ingredients (datasets) seamlessly. In this way, you can whip up delicious dishes (models) with a few simple actions rather than complex recipes!
2. OOP API
# OOP API Example
from pycaret.datasets import get_data
data = get_data('juice')
from pycaret.classification import ClassificationExperiment
s = ClassificationExperiment()
s.setup(data, target='Purchase', session_id=123)
best = s.compare_models()
s.evaluate_model(best)
new_data = data.copy().drop('Purchase', axis=1)
predictions = s.predict_model(best, data=new_data)
s.save_model(best, 'best_pipeline')
Who Should Use PyCaret?
PyCaret is an open-source library suited for:
- Experienced Data Scientists looking to boost productivity.
- Citizen Data Scientists preferring a low-code solution.
- Data Science Professionals needing quick prototypes.
- Students and enthusiasts wanting to learn about Machine Learning.
Training on GPUs
PyCaret allows you to leverage GPU capabilities for faster model training. Just set use_gpu=True
during setup. However, some models may require additional library installations.
Troubleshooting
If you encounter issues during installation, ensure your Python version and dependencies are compatible. Also, check the version of PyCaret is up to date using:
pip install --upgrade pycaret
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.