Skip to main content

API reference

Full API reference for the Modelbit python package.

Logging in

modelbit.login()

Log into Modelbit. Opens a browser tab that authenticates your Modelbit session. Returns a logged-in Modelbit object.

import modelbit
mb = modelbit.login()

Datasets

Datasets require a logged-in session. These methods are called on the logged-in Modelbit object.

Related Guide

Read the Datasets section of the docs for more info on using datasets as feature stores.

mb.datasets() -> List[Dataset]

Returns a list of accessible datasets.

for ds_name in mb.datasets():
print(ds_name)

mb.get_dataset(dataset_name, [filters=]) -> pandas.DataFrame

Fetches a dataset and returns it as a pandas dataframe.

Parameters

  • dataset_name: str The name of the requested dataset.
  • filters: Optional[Dict[str, List[Any]]] If supplied with a filters dict, the DataFrame returned will be filtered to rows matching the filter criteria. The keys of the filters dict are column names. The values are lists of values to match against.

Example

similar_customers = mb.get_dataset(
"customer_features",
filters={
"REGION": ["NA", "SA"]
"EMPLOYEE_COUNT": ["100-500","500-5000"]
}
)

Warehouses

Warehouses require a logged-in session. These methods are called on the logged-in Modelbit object.

Related Guide

Learn how to configure your Snowflake or Redshift warehouse for Modelbit.

mb.warehouses()

Displays a list of configured warehouses.

Deployments

Related Guide

Learn how to deploy models to Modelbit from your Python notebook or from git.

Deployments require a logged-in session. This method is called on the logged-in Modelbit object.

mb.deploy(sklearn_object, [name=, python_version=])

Deploys a SciKit-Learn model or pipeline to production.

Parameters

  • sklearn_object: sklearn.BaseEstimator The SciKit-Learn model or pipeline to deploy to production. When this model's API is called in production, sklearn_object.predict will be called.
  • name: Optional[str] The name of the deployment. If unsupplied, the name of the sklearn_object is used.
  • python_version: Optional[str, 3.7|3.8|3.9|3.10] Python version to run in production.

Example

mb.deploy(my_sklearn_model, python_version="3.8")

mb.deploy(deployment_function, [name=, python_version=, python_packages=, system_packages=, dataframe_mode=, example_dataframe=])

Deploys a Python function and optional associated function arguments to production.

Parameters

  • deployment_function: Callable The function to deploy to Modelbit. If the function uses Python type hints for its parameters and return type, Modelbit will generate smarter sample code. Return values must be JSON-serializable.
  • name: Optional[str] The name of the deployment. If unsupplied, the name of the deployment_function is used.
  • python_version: Optional[str, 3.7|3.8|3.9|3.10] Python version to run in production.
  • python_packages: : Optional[List[str]] The pip packages to install in the deployment's environment. E.g. ["scikit-learn==1.0.2"].
  • system_packages: : Optional[List[str]] The apt-get packages to install in the deployment's environment. E.g. ["libgomp1"].
  • dataframe_mode: : Optional[bool] Whether to deploy in DataFrame mode. If True, example_dataframe must be specified.
  • example_dataframe: : Optional[pandas.DataFrame] DataFrame with the columns and column types to expect in production in DataFrame mode. If specified, dataframe_mode must be True.

Example

mb.deploy(my_deployment_function, python_version="3.8")

Git Branches

Related Guide

modelbit.switch_branch(name)

Change the branch that mb commands will use.

Parameters

  • name: str The name of the branch to switch to using in the current notebook session

Example

mb.switch_branch("my_branch")

Sending Emails

Related Guide

modelbit.send_email(subject, to, msg)

Send an email from a deployment. All emails are sent from support@modelbit.com.

Parameters

  • subject: str The subject line of the email
  • to: List[str] The email addresses of the recipients of the email
  • msg: str The body of the email

Example

mb.send_email(
subject = "Batch complete!",
to = ["tom@modelbit.com"],
msg = "Completed a batch of inferences!"
)