Docs Navigation +

Python

You can use fuzzy.ai from your Python project using the Open Source library.

Installation

You can download the software at: https://github.com/fuzzy-ai/python

You can also fork the repository on Github.

Testing

It uses pytest. However, you need to have a Fuzzy.ai API key to make it work.

The test script (not the SDK itself!) looks for the API key in the FUZZY_IO_KEY environment variable. So you can run the test something like this:

FUZZY_IO_KEY=<yourkeyhere> python -m pytest

Basic usage

When you use the fuzzyio module, you always have to provide your API key first. Use the setup() function to do that:

import fuzzyio

fuzzyio.setup(YOUR_API_KEY)

To have a Fuzzy.ai agent make a decision for you, use the evaluate() function of the fuzzyio module:

from __future__ import print_function

agent_id = "AGENTIDHERE"

inputs = dict(height=188, weight=88.7)

outputs = fuzzyio.evaluate(agent_id, inputs)

print outputs["run_distance"]

If you need to provide feedback on the evaluation, use the evaluate_with_id() function to get an ID for the evaluation, and then provide that to the feedback() function:

agent_id = "AGENTIDHERE"

inputs = dict(height=188, weight=88.7)

(outputs, evaluation_id) = fuzzyio.evaluate_with_id(agent_id, inputs)

# Real-world usage of the run_distance will return some performance
# metric.

fuzzyio.feedback(evaluation_id, dict(weight_loss=0.25))

Advanced usage

All of the Fuzzy.ai API is available through this SDK.

The Agent class represents a single agent. It includes evaluate() and evaluate_with_id() methods as well as save() and delete() to change the agent on the server. Use that last part carefully!

The Evaluation class represents a single evaluation. It includes a get() method to fetch details about the evaluation and the feedback() method to fetch feedback on the evaluation.

The Feedback class represents a single feedback data point. It has a save() method to generate feedback for an evaluation.