MOSTLY AI Python client
Use the MOSTLY AI Python client to train generators, generate synthetic data, connect to data sources, share data with your team, and much more.
Intent | Primitive |
---|---|
Train a Generator on tabular or language data | g = mostly.train(config) |
Generate any number of synthetic data records | sd = mostly.generate(g, config) |
Live probe the generator on demand | df = mostly.probe(g, config) |
Connect to any data source within your org | c = mostly.connect(config) |
For a complete API reference, see the Python Client package documentation (opens in a new tab).
Installation
You can install the latest release of mostlyai
via pip:
pip install -U mostlyai
Get an API key
To use the Python client, you need an API key. Get your API key for the REST API or Python client from your user profile menu.
Steps
- Hover over the profile menu in the upper right and select API key.
- Click Generate API Key.
What's next
Your key is immediately copied to your clipboard. You can now use it for the REST API or to instantiate your Python client.
from mostlyai import MostlyAI
mostly = MostlyAI(api_key="mostly-**********")
Examples
As you explore the Generators, Synthetic datasets, and Connectors pages, you will find code snippets that show how to accomplish a task with the Python client. Use the Python and UI tabs to switch between the code snippets and the UI steps.
Quick Start
import pandas as pd
from mostlyai import MostlyAI
# initialize client
mostly = MostlyAI(
api_key='INSERT_YOUR_API_KEY', # or set env var `MOSTLYAI_API_KEY`
base_url='https://app.mostly.ai' # or set env var `MOSTLYAI_BASE_URL`
)
# train a generator
df = pd.read_csv('https://github.com/mostly-ai/public-demo-data/raw/dev/census/census.csv.gz')
g = mostly.train(data=df)
# probe for some samples
syn = mostly.probe(g, size=10)
# generate a synthetic dataset
sd = mostly.generate(g, size=2_000)
# start using it
sd.data()