AI Hero Python SDK
Project description
AI Hero Python SDK
Go from Zero to ML in minutes.
With AI Hero, you can protototype automations to power your product features, automate routine tasks, and analyze customer feedback - all with a simple python library or our no-code, self-serve platform.
An automation is an abstraction of an ML model. Apart from training data, it may include a database, heuristics, business logic, etc.
Choose from our growing list of automations to tag text, recommend products, tag images, detect customer sentiment, and other tasks!
Usage
Using an automation created on the AI Hero Platform with this Python API.
- First, install this library.
pip install aihero
- Establish a connection to AI Hero in your Python program.
from aihero import Client
aihero_client = Client()
-
We recommend you use the AI Hero Platform to create your automation. For example, we can create an automation to detect sentiment in short text.
-
Using the platform, you can create an API key. Use it with this python API to get access to your automation.
# Get the automation object, using the automation id and your API key for that automation.
automation = aihero_client.get_automation(automation_id='<YOUR_AUTOMATION_ID>', api_key='<YOUR_API_KEY>')
- To start using your automation, you can use the predict function.
# Predict using your trained automation.
# For example, for detecting sentiment in short text:
prediction = automation.predict(guid="<UNIQUE_ID>", text="This works great!")
# predction object:
# {'explanation': 'The sentiment is positive', 'tags': {'negative': 0.00013113021850585938, 'positive': 0.9998688697814941}}
Available Automations with the API
To use any of the automations below, please create one on the platform if you havent already, and get your API key.
Detect Sentiment in Short Text
The sentiment detection automation does not need any training and is ready to use.
# Predict using your trained automation.
# For example, for detecting sentiment in short text:
prediction = automation.predict(guid="<UNIQUE_ID>", text="This works great!")
# predction object:
# {'explanation': 'The sentiment is positive', 'tags': {'negative': 0.00013113021850585938, 'positive': 0.9998688697814941}}
Tag Short Text
- Set the tags you want to tag your model with:
automation.set_tags(['<TAG/CATEGORY 1>', '<TAG/CATEGORY 2>', '<TAG/CATEGORY 3>'])
print(automation.get_tags())
- Add the texts to train the model with:
automation.add_short_text(
guid="<UNIQUE_ID>",
text="It's great that I can add training data to the model."
)
- You can then trigger AI Hero so that it will try to understand the data. Without feedback or ground truth, AI Hero attempts its best prediction based on its understanding of the data. With enough feedback or ground truth, AI Hero will use Machine Learning to fit a model to your data.
# Trigger understanding. You'll be notified when the automation is ready.
understanding_job = automation.understand()
# To check the status.
print(automation.get_status(understanding_job))
- Once you get an email notifying you that your automation is ready, you can start using it with the API.
# Predict using your trained automation.
prediction = automation.predict(guid="<UNIQUE_ID>", text="This works great!")
Tag Entire Images
- Set the tags you want to tag your model with:
automation.set_tags(['<TAG/CATEGORY 1>', '<TAG/CATEGORY 2>', '<TAG/CATEGORY 3>'])
print(automation.get_tags())
- Add the images to train the model with:
automation.add_image(guid="<UNIQUE_ID>", image_url="<IMAGE_URL>")
- You can then trigger AI Hero so that it will try to understand the data. Without feedback or ground truth, AI Hero attempts its best prediction based on its understanding of the data. With enough feedback or ground truth, AI Hero will use Machine Learning to fit a model to your data.
# Trigger understanding. You'll be notified when the automation is ready.
understanding_job = automation.understand()
# To check the status.
print(automation.get_status(understanding_job))
- Once you get an email notifying you that your automation is ready, you can start using it with the API.
# Predict using your trained automation.
prediction = automation.predict(guid="<UNIQUE_ID>", image_url="<IMAGE_URL>")
Improving your Automations.
While AI Hero does the best job it can, it may need some more examples to improve. In the email you get when learning is completed, click on the link in the email to teach the automation by giving feedback on the predictions.
You can also add more ground truth examples for it to learn with:
automation.set_ground_truth(
guid="<UNIQUE_ID>",
ground_truth={"<TAG/CATEGORY 1>": True, "<TAG/CATEGORY 2>": False, "<TAG/CATEGORY 3>": True}
)
Pricing.
Please check your automation at AI Hero Platform for pricing information to the automation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aihero-0.1.10-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 081762591aa962f35753aaedb46fd583890725e59ef7b8e09bbb1c6ab1a92f08 |
|
MD5 | 1125236bc80dc97115caa6228b7d64fd |
|
BLAKE2b-256 | da690c4e355e428912377f7f447428a1bf23d69d9ccc439b777e58fc6e6dac1a |