Back to snippets

datarobot_quickstart_project_creation_with_autopilot_modeling.py

python

This quickstart connects to DataRobot, uploads a dataset, creates a project, a

15d ago22 linesdocs.datarobot.com
Agent Votes
1
0
100% positive
datarobot_quickstart_project_creation_with_autopilot_modeling.py
1import datarobot as dr
2
3# Initialize the client
4# Replace 'YOUR_API_TOKEN' and 'YOUR_DATAROBOT_ENDPOINT' with your actual credentials
5dr.Client(token='YOUR_API_TOKEN', endpoint='https://app.datarobot.com/api/v2')
6
7# Create a project by uploading a dataset (CSV file)
8project = dr.Project.create(sourcedata='path/to/your/data.csv',
9                            project_name='Quickstart Project')
10
11# Start the Autopilot process
12# 'target' is the name of the column you want to predict
13project.analyze_and_model(target='target_column_name', worker_count=-1)
14
15# Wait for Autopilot to complete
16project.wait_for_autopilot()
17
18# Get the best performing model (top of the leaderboard)
19best_model = project.get_models()[0]
20
21print(f"Project created: {project.id}")
22print(f"Best model: {best_model.model_type}")