Skip to content

Web-interface, and programmatic API for classification and regression predictions

License

Notifications You must be signed in to change notification settings

wazeerzulfikar/machine-learning-1

 
 

Repository files navigation

Machine Learning Build Status Coverage Status

This project provides a web-interface, as well as a programmatic-api for various machine learning algorithms. Some of it's general applications, have been outlined within index.rst.

Supported algorithms:

Contributing

Please adhere to contributing.md, when contributing code. Pull requests that deviate from the contributing.md, could be labelled as invalid, and closed (without merging to master). These best practices will ensure integrity, when revisions of code, or issues need to be reviewed.

Note: support, and philantropy can be inquired, to further assist with development.

Preconfiguration

This project implements puppet's r10k module via vagrant's plugin. A requirement of this implementation includes a Puppetfile (already defined), which includes the following syntax:

#!/usr/bin/env ruby
## Install Module: stdlib (apt dependency)
mod 'stdlib',
  :git => "git@github.com:puppetlabs/puppetlabs-stdlib.git",
  :ref => "4.6.0"

## Install Module: apt (from master)
mod 'apt',
  :git => "git@github.com:puppetlabs/puppetlabs-apt.git"
...

Specifically, this implements the ssh syntax git@github.com:account/repo.git, unlike the following alternatives:

  • https://github.com/account/repo.git
  • git://github.com/account/repo.git

This allows r10k to clone the corresponding puppet module(s), without a deterrence of DDoS. However, to implement the above syntax, ssh keys need to be generated, and properly assigned locally, as well as on the github account.

The following steps through how to implement the ssh keys with respect to github:

$ cd ~/.ssh/
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
$ ssh-agent -s
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
$ pbcopy < ~/.ssh/id_rsa.pub

Note: it is recommended to simply press enter, to keep default values when asked Enter file in which to save the key. Also, if ssh-agent -s alternative for git bash doesn't work, then eval $(ssh-agent -s) for other terminal prompts should work.

Then, at the top of any github page (after login), click Settings > SSH keys > Add SSH Keys, then paste the above copied key into the Key field, and click Add key. Finally, to test the ssh connection, enter the following within the same terminal window used for the above commands:

$ ssh -T git@github.com
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of
known hosts.
Hi jeff1evesque! You've successfully authenticated, but GitHub does not provide
shell access.

Configuration

Fork this project in your GitHub account. Then, clone your repository, with one of the following approaches:

  • simple clone: clone the remote master branch.
  • commit hash: clone the remote master branch, then checkout a specific commit hash.
  • release tag: clone the remote branch, associated with the desired release tag.

Installation

In order to proceed with the installation for this project, two dependencies need to be installed:

Once the necessary dependencies have been installed, execute the following command to build the virtual environment:

cd /path/to/machine-learning/
vagrant up

Depending on the network speed, the build can take between 10-15 minutes. So, grab a cup of coffee, and perhaps enjoy a danish while the virtual machine builds. Remember, the application is intended to run on localhost, where the Vagrantfile defines the exact port-forward on the host machine.

Note: a more complete refresher on virtualization, can be found within the vagrant wiki page.

The following lines, indicate the application is accessible via localhost:8080, on the host machine:

...
  ## Create a forwarded port mapping which allows access to a specific port
  #  within the machine from a port on the host machine. In the example below,
  #  accessing "localhost:8080" will access port 80 on the guest machine.
  config.vm.network "forwarded_port", guest: 5000, host: 8080
  config.vm.network "forwarded_port", guest: 443, host: 8585
...

Otherwise, if ssl is configured, then the application is accessible via https://localhost:8585, on the host machine.

Note: general convention implements port 443 for ssl.

Execution

Both the web-interface, and the programmatic-api, have corresponding unit tests which can be reviewed, and implemented.

Web Interface

The web-interface , or GUI implementation, allow users to implement the following sessions:

  • data_new: store the provided dataset(s), within the implemented sql database.
  • data_append: append additional dataset(s), to an existing representation (from an earlier data_new session), within the implemented sql database.
  • model_generate: using previous stored dataset(s) (from an earlier data_new, or data_append session), generate a corresponding model into the implemented nosql datastore.
  • model_predict: using a previous stored model (from an earlier model_predict session), from the implemented nosql datastore, along with user supplied values, generate a corresponding prediction.

When using the web-interface, it is important to ensure the csv, xml, or json file(s), representing the corresponding dataset(s), are properly formatted. Dataset(s) poorly formatted will fail to create respective json dataset representation(s). Subsequently, the dataset(s) will not succeed being stored into corresponding database tables; therefore, no model, or prediction can be made.

The following are acceptable syntax:

Note: each dependent variable value (for JSON datasets), is an array (square brackets), since each dependent variable may have multiple observations.

As mentioned earlier, the web application can be accessed after subsequent vagrant up command, followed by using a browser referencing localhost:8080 (or https://localhost:5050, with ssl), on the host machine.

Programmatic Interface

The programmatic-interface, or set of API, allow users to implement the following sessions:

  • data_new: store the provided dataset(s), within the implemented sql database.
  • data_append: append additional dataset(s), to an existing representation (from an earlier data_new session), within the implemented sql database.
  • model_generate: using previous stored dataset(s) (from an earlier data_new, or data_append session), generate a corresponding model into the implemented nosql datastore.
  • model_predict: using a previous stored model (from an earlier model_predict session), from the implemented nosql datastore, along with user supplied values, generate a corresponding prediction.

A post request, can be implemented in python, as follows:

import requests

endpoint_url = 'http://localhost:8080/load-data'
headers = {'Content-Type': 'application/json'}

requests.post(endpoint_url, headers=headers, data=json_string_here)

Note: the above post request, can be implemented in a different language, respectively.

Note: various data attributes can be nested in above POST request.

About

Web-interface, and programmatic API for classification and regression predictions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 45.8%
  • JavaScript 24.5%
  • HTML 12.2%
  • Puppet 9.8%
  • Pascal 3.8%
  • CSS 1.8%
  • Other 2.1%