Creating your first Trial
Learn how to programmatically create and run a trial using the EvoML Client.
Step 1: Connecting into the platform
Use your credentials to connect to the EvoML platform.
from typing import Final
import evoml_client as ec
import pandas as pd
# Pease replace with your deploy-platform URL
API_URL: Final[str] = "https://evoml.ai"
# Please replace with your username
USERNAME: Final[str] = ""
# Please replace with your password
PASSWORD: Final[str] = ""
# Connect to the platform
ec.init(base_url=API_URL, username=USERNAME, password=PASSWORD)
Step 2: Upload a Dataset
Upload the heart.csv dataset to the EvoML platform.
dataset = ec.Dataset.from_file("./data/heart.csv")
dataset.put()
dataset_id = dataset.dataset_id
print(f"Dataset ID: {dataset_id}")
Step 3: create the configuration of the Trial
Define the trial parameters: task type, budget, objective, and dataset ID.
from evoml_client.trial_conf_models import BudgetMode
config = ec.TrialConfig.with_default(
task=ec.MlTask.classification.value,
budget_mode=BudgetMode.fast,
loss_funcs=["F1"],
dataset_id=dataset_id,
)
Set up the trial with the target column and trial name.
trial, dataset = ec.Trial.from_dataset_id(
dataset_id,
target_col="Sex",
trial_name="Classification - Sex",
config=config,
)
Run the trial in blocking mode, waiting for execution to complete.
trial.run(timeout=900)
Retrieve and preview the models generated by the trial.
models = trial.get_models()
print(models)