Skip to content

Instantly share code, notes, and snippets.

# Import dataset from pycaret repository
from pycaret.datasets import get_data
insurance = get_data('insurance')
# Initialize environment
from pycaret.regression import *
r1 = setup(insurance, target = 'charges', session_id = 123,
normalize = True,
polynomial_features = True, trigonometry_features = True,
feature_interaction=True,
FROM python:3.7
RUN pip install virtualenv
ENV VIRTUAL_ENV=/venv
RUN virtualenv venv -p python3
ENV PATH="VIRTUAL_ENV/bin:$PATH"
WORKDIR /app
ADD . /app
FROM python:3.7
RUN pip install virtualenv
ENV VIRTUAL_ENV=/venv
RUN virtualenv venv -p python3
ENV PATH="VIRTUAL_ENV/bin:$PATH"
WORKDIR /app
ADD . /app
from pycaret.clustering import *
clu1 = setup(data, ignore_features = ['Country Name', 'Indicator Name'])
# import regression module
from pycaret.regression import *
# init setup
reg1 = setup(data, target = 'charges', silent=True,
categorical_features=['sex', 'smoker', 'region', 'children'],
numeric_features=['age', 'bmi'])
#tune with default n_iter i.e. 10
tuned_dt1 = tune_model('dt')
#tune with n_iter = 50
tuned_dt2 = tune_model('dt', n_iter = 50)
tuned_lda = tune_model(model='lda', supervised_target='status', estimator='xgboost')
# Importing dataset
from pycaret.datasets import get_data
credit = get_data('credit')
# Importing module and initializing setup
from pycaret.classification import *
clf1 = setup(data = credit, target = 'default')
# create a model
xgboost = create_model('xgboost')
predict_model(xgboost, probability_threshold=0.2)
# import classification module
from pycaret.classification import *
# init setup
clf1 = setup(data, target = 'name-of-target')
# return best model
best = compare_models()
# return best model based on Recall