Skip to main content

No project description provided

Project description

# Python wrapper for the machinelearningforkids.co.uk API

This library was designed for use with [machinelearningforkids.co.uk](https://machinelearningforkids.co.uk).

## 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

API_KEY = "PASTE-API-KEY-HERE"
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](http://simplecv.org/) 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.

Source Distribution

ml4k-0.8.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file ml4k-0.8.tar.gz.

File metadata

  • Download URL: ml4k-0.8.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

File hashes

Hashes for ml4k-0.8.tar.gz
Algorithm Hash digest
SHA256 ed77e874821f566567d68cfeb59200e02de596360e20a86346c75d0b1552c440
MD5 30266dc9044a9a4bf33f8229b3de7d76
BLAKE2b-256 8aa8e3a93bcdb7e6b1f4a7117fe917e10282b126fabe0631c2bf159e0162df16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page