Skip to main content

AntiNex Python client

Project description

AntiNex Python Client

Python API Client for training deep neural networks with the REST API running

https://github.com/jay-johnson/train-ai-with-django-swagger-jwt

https://travis-ci.org/jay-johnson/antinex-client.svg?branch=master https://readthedocs.org/projects/antinex-client/badge/?version=latest

Install

pip install antinex-client

AntiNex Stack Status

AntiNex client is part of the AntiNex stack:

Component

Build

Docs Link

Docs Build

REST API

Travis Tests

Docs

Read the Docs REST API Tests

Core Worker

Travis AntiNex Core Tests

Docs

Read the Docs AntiNex Core Tests

Network Pipeline

Travis AntiNex Network Pipeline Tests

Docs

Read the Docs AntiNex Network Pipeline Tests

AI Utils

Travis AntiNex AI Utils Tests

Docs

Read the Docs AntiNex AI Utils Tests

Client

Travis AntiNex Client Tests

Docs

Read the Docs AntiNex Client Tests

Run Predictions

These examples use the default user root with password 123321. It is advised to change this to your own user in the future.

Train a Deep Neural Network with a JSON List of Records

ai -u root -p 123321 -f examples/predict-rows-scaler-django-simple.json

Train a Deep Neural Network to Predict Attacks with the AntiNex Datasets

Please make sure the datasets are available to the REST API, Celery worker, and AntiNex Core worker. The datasets are already included in the docker container ai-core provided in the default compose.yml file:

https://github.com/jay-johnson/train-ai-with-django-swagger-jwt/blob/51f731860daf134ea2bd3b68468927c614c83ee5/compose.yml#L53-L104

If you’re running outside docker make sure to clone the repo with:

git clone https://github.com/jay-johnson/antinex-datasets.git /opt/antinex/antinex-datasets

Train the Django Defensive Deep Neural Network

Please wait as this will take a few minutes to return and convert the predictions to a pandas DataFrame.

ai -u root -p 123321 -f examples/scaler-full-django-antinex-simple.json

...

[30200 rows x 72 columns]

Using Pre-trained Neural Networks to make Predictions

The AntiNex Core manages pre-trained deep neural networks in memory. These can be used with the REST API by adding the "publish_to_core": true to a request while running with the REST API compose.yml docker containers running.

Run:

ai -u root -p 123321 -f examples/publish-to-core-scaler-full-django.json

Here is the diff between requests that will run using a pre-trained model and one that will train a new neural network:

antinex-client$ diff examples/publish-to-core-scaler-full-django.json examples/scaler-full-django-antinex-simple.json
5d4
<     "publish_to_core": true,
antinex-client$

Prepare a Dataset

ai_prepare_dataset.py -u root -p 123321 -f examples/prepare-new-dataset.json

Get Job Record for a Deep Neural Network

Get a user’s MLJob record by setting: -i <MLJob.id>

This include the model json or model description for the Keras DNN.

ai_get_job.py -u root -p 123321 -i 4

Get Predictions Results for a Deep Neural Network

Get a user’s MLJobResult record by setting: -i <MLJobResult.id>

This includes predictions from the training or prediction job.

ai_get_results.py -u root -p 123321 -i 4

Get a Prepared Dataset

Get a user’s MLPrepare record by setting: -i <MLPrepare.id>

ai_get_prepared_dataset.py -u root -p 123321 -i 15

Using a Client Built from Environment Variables

This is how the Network Pipeline streams data to the AntiNex Core to make predictions with pre-trained models.

Export the example environment file:

source examples/example-prediction.env

Run the client prediction stream script

ai_env_predict.py -f examples/predict-rows-scaler-full-django.json

Development

virtualenv -p python3 ~/.venvs/antinexclient && source ~/.venvs/antinexclient/bin/activate && pip install -e .

Testing

Run all

python setup.py test

Linting

flake8 .

pycodestyle .

License

Apache 2.0 - Please refer to the LICENSE for more details

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

antinex-client-1.3.4.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

antinex_client-1.3.4-py2.py3-none-any.whl (46.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file antinex-client-1.3.4.tar.gz.

File metadata

  • Download URL: antinex-client-1.3.4.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for antinex-client-1.3.4.tar.gz
Algorithm Hash digest
SHA256 d4ae73bc82c657700c58076970f4d8b44c0660956ee2859c3597c2abe809b0c2
MD5 ab740548a0456fea134553d17be7ee1f
BLAKE2b-256 3e4a1d98fcfb5a361aafb49267e9c75e6d02149ede9adda15a174ad654e049d6

See more details on using hashes here.

File details

Details for the file antinex_client-1.3.4-py2.py3-none-any.whl.

File metadata

  • Download URL: antinex_client-1.3.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 46.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for antinex_client-1.3.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 540e4b8b382f773a7954b0a0ebf40f1d44d5ee6f4ec34dfe82e9e6c474a45272
MD5 364c457b3ab6cadaf60a206b6b745a76
BLAKE2b-256 45a0fe87ebc71bcc0f051029fce30cc71db09675bd0a8e9594f70f18a6a876f4

See more details on using hashes here.

Supported by

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