Making Predictions
Discover predictors and make predictions.
Function provides a Python client for making predictions in any Python app.
Installing Function
To start, open a terminal window and run the following command:
# Open a terminal and run the following command:
pip install --upgrade fxn
Logging in to Function
First, head over to your Account ↗ page to generate an access key:
Now, let's login to Function with your access key:
import fxn
# Set your access key
# Or set the `FXN_ACCESS_KEY` environment variable
fxn.access_key = "<ACCESS KEY>"
Making Predictions
First, we'll need a predictor to make predictions with. You can either use a public predictor on Function, or make your own. In this guide, we'll be using the @samplefxn/greeting
predictor:
You can discover and use public predictors on Function.
We'll be using the greeting predictor in this guide.
The predictor accepts a name
of the person to greet, optionally with their age
and city
. Let's make the prediction:
# Predict
prediction = fxn.Prediction.create(
tag="@samplefxn/greeting",
name="Rhea",
age=44,
city="Los Angeles"
)
# Print
print(prediction.results[0])
Function supports serializing audio, images, video, tensors, and much more. For more info, see
Value
→