Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

No project description provided

Project description

# Python wrapper for the API

This library was designed for use with [](

## Installation

Use pip to install the `ml4k` package:

sudo pip install ml4k

## Usage

In order to use your machine learning model, create a `Model` object
with your project's API key:

import ml4k

model = ml4k.Model(API_KEY)

The following methods are available:

### `model.classify(data)`

Classifies the given data and returns a dictionary with the result. The
result dictionary contains the `"label"` and `"confidence"` values.

### `model.add_training_data(label, data)`

Adds training data to the given label "bucket". You can pass text,
images, or a list of numbers.

## Examples

### Recognizing Text

# Get input from user and pass it to our model
command = input("Type a command: ")
result = model.classify("Turn on the lamp")

if result["label"] == "lamp_on":
print("Turning on the lamp")
elif result["label"] == "lamp_off":
print("Turning off the lamp")

### Recognizing Images

Recognizing images is similar, but you need to pass binary image data.
There are many was to get image data in python, such as opening and
reading a file, or capturing from the webcam using a the
[SimpleCV]( library.

Images will be automatically downsized before sending to the API.

# Assuming you have image data stored as a binary string...
result = model.classify(image)
if result["label"] == "dog":
print("That's a dog")
elif result["label"] == "cat":
print("That's a cat")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ml4k, version 0.8
Filename, size File type Python version Upload date Hashes
Filename, size ml4k-0.8.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page