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")
Metadata
Release files for ml4k 0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ml4k-0.8.tar.gz | 3.0 kB | Without provenance | Details |
Release files / ml4k-0.8.tar.gz
| Download URL | ml4k-0.8.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed77e874821f566567d68cfeb59200e02de596360e20a86346c75d0b1552c440
|
|
BLAKE2b-256 checksum How to use checksums |
8aa8e3a93bcdb7e6b1f4a7117fe917e10282b126fabe0631c2bf159e0162df16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for ml4k 0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.