Quickstart#

Important

drx is an unofficial, experimental library; interfaces will change. We invite and encourage you to use and provide feedback, but ask that you be mindful of the experimental, and unoffical nature when choosing to use on a project.

Install#

pip install datarobotx

drx dependencies will be automatically installed as needed.

Use#

import datarobotx as drx

df = pd.read_csv("https://s3.amazonaws.com/datarobot_public_datasets/10k_diabetes_20.csv")

# Configure (if needed)
drx.Context(token='=NjIzMG****', endpoint='https://app.datarobot.com/api/v2') 

# Run AutoML
model = drx.AutoMLModel().fit(df[:-200], target='readmitted')

# Get predictions
model.predict(df[-200:])

# That's it

Configure#

There are three options for configuring drx:

  1. Configuration with drconfig.yaml

  2. Configuration with environment variables

  3. In-line, programmatic configuration using drx.Context()

When imported, drx will automatically attempt to read and initialize configuration from ~/.config/datarobot/drconfig.yaml and the environment variables DATAROBOT_API_TOKEN and DATAROBOT_ENDPOINT. If parameters conflict, environment variables take precedence.

Optionally, the default prediction environment to use for deployments can be defined by setting the key pred_server_id in drconfig.yaml, or alternatively the environment variable DATAROBOT_PRED_SERVER_ID. If omitted, the first prediction environment returned by GET /api/v2/predictionServers/ will be used by default.

Programmatic configuration#

>>> import datarobotx as drx
>>> drx.Context()  # show current configuration
{'token': '***', 'endpoint': 'https://app.datarobot.com/api/v2', 'pred_server_id': '***'}
>>> drx.Context(token='foo', endpoint='bar')  # update current configuration
{'token': 'foo', 'endpoint': 'bar', 'pred_server_id': '***'}
>>> c = drx.Context()
>>> c.pred_server_id = 'foo_bar'  # alternative approach to update
>>> drx.Context()
{'token': 'foo', 'endpoint': 'bar', 'pred_server_id': 'foo_bar'}
>>> drx.Context(config_path='my_path/my_config.yaml')  # update from file
{'token': 'my_config_token', 'endpoint': 'my_config_endpoint', 'pred_server_id': 'my_config_pred_server_id'}

Use More#

Check out some examples of what can be done with drx in the Model, and Consume sections and consider reading our FAQ. You can also check out the example notebook we have in the repo.

Upgrade#

pip install --upgrade datarobotx