Model#

class datarobotx.Model(project_id=None, model_id=None)#

DataRobot training model.

Represents a model on a project leaderboard. Implements prediction and deployment asynchronously.

Parameters:
  • model_id (str, optional) – DataRobot id for the model from which to initialize the object

  • project_id (str, optional) – DataRobot id for the project containing the model from which to initialize the object

Attributes:

dr_model

DataRobot python client datarobot.Model object.

dr_project

DataRobot python client datarobot.Project object.

Methods:

deploy([name, registered_model_id])

Deploy the model into ML Ops.

from_url(url)

Class method to initialize from a URL string.

predict(X, **kwargs)

Make batch predictions using the model.

predict_proba(X, **kwargs)

Calculate class probabilities using the model.

deploy(name=None, registered_model_id=None)#

Deploy the model into ML Ops.

Parameters:
  • name (str, optional, default=None) – Name for the deployment. If None, a name will be generated

  • registered_model_id (str, optional, default=None) – ID to reuse an existing registered model or if None (the default) create a new one.

Returns:

Resulting ML Ops deployment

Return type:

Deployment

property dr_model: Model#

DataRobot python client datarobot.Model object.

Returns:

datarobot.Model object associated with this drx.Model

Return type:

datarobot.Model

property dr_project: Project#

DataRobot python client datarobot.Project object.

Returns:

datarobot.Project object associated with this drx.Model

Return type:

datarobot.Project

classmethod from_url(url)#

Class method to initialize from a URL string.

Useful for copy and pasting between GUI and notebook environments

Parameters:

url (str) – URL of a DataRobot GUI page related to the model of interest

Returns:

model – The constructed Model object

Return type:

Model

predict(X, **kwargs)#

Make batch predictions using the model.

Predictions are calculated asynchronously - returns immediately but reinitializes the returned DataFrame with data once predictions are completed.

Predictions are made within the project containing the model using modeling workers. For real-time predictions, first deploy the model.

Parameters:
  • X (pandas.DataFrame or str) – Dataset to be scored - target column can be included or omitted. If str, can be AI catalog dataset id or name (if unambiguous)

  • **kwargs (Any) – Other key word arguments to pass to the _predict function

Returns:

Resulting predictions (contained in the column ‘predictions’) Returned immediately, updated automatically when results are completed. If attribute access is attempted, will block until results are completed.

Return type:

pandas.DataFrame

predict_proba(X, **kwargs)#

Calculate class probabilities using the model.

Only available for classifier models.

Parameters:
  • X (pandas.DataFrame or str) – Dataset to compute class probabilities on; target column can be included or omitted. If str, can be AI catalog dataset id or name (if unambiguous)

  • **kwargs (Any) – Other key word arguments to pass to the _predict function

Returns:

Resulting predictions; probabilities for each label are contained in the column ‘class_{label}’; returned immediately, updated automatically when results are completed. If attribute access is attempted, will block until results are completed.

Return type:

pandas.DataFrame

See also

predict