<commit_before>
# sklearn-porter

[![Build Status](https://img.shields.io/travis/nok/sklearn-porter/master.svg)](https://travis-ci.org/nok/sklearn-porter)
[![Join the chat at https://gitter.im/nok/sklearn-porter](https://badges.gitter.im/nok/sklearn-porter.svg)](https://gitter.im/nok/sklearn-porter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nok/scikit-learn-model-porting/master/LICENSE.txt)

Module to port trained [scikit-learn](https://github.com/scikit-learn/scikit-learn) models to a low-level programming language like C, Java or JavaScript. It's recommended for limited embedded systems and critical applications where performance matters most.


## Target Algorithm Models

### Classification

The following matrix shows the portable classifier models:

<table>
    <tbody>
        <tr>
            <td width="32%"></td>
            <td align="center" width="17%"><strong>Example</strong></td>
            <td align="center" width="17%"><strong>C</strong></td>
            <td align="center" width="17%"><strong>Java</strong></td>
            <td align="center" width="17%"><strong>JavaScript</strong></td>
        </tr>
        <tr>
            <td><a href="http://scikit-learn.org/0.17/modules/generated/sklearn.tree.DecisionTreeClassifier.html">DecisionTreeClassifier</a></td>
            <td align="center"><a href="blob/master/examples/classifier/decisiontree_predict.py">X</a></td>
            <td align="center"></td>
            <td align="center">X</td>
            <td align="center">X</td>
        </tr>
        <tr>
            <td><a href="http://scikit-learn.org/0.17/modules/generated/sklearn.ensemble.AdaBoostClassifier.html">AdaBoostClassifier</a></td>
            <td align="center"><a href="blob/master/examples/classifier/adaboost_predict.py">X</a></td>
            <td align="center"></td>
            <td align="center">X</td>
            <td align="center">X</td>
        </tr>
        <tr>
            <td><a href="http://scikit-learn.org/0.17/modules/generated/sklearn.svm.LinearSVC.html">LinearSVC</a></td>
            <td align="center"><a href="blob/master/examples/classifier/linear_svc_predict.py">X</a></td>
            <td align="center"></td>
            <td align="center">X</td>
            <td align="center"></td>
        </tr>
    </tbody>
</table>

<!--
### ~~Regression~~
The following matrix shows the portable regression models:
-->


## Usage

Either you use the porter in your application as [imported module](#module) or you use it on the [command line](#cli). 


### Module

This example shows how you can port the decision tree model from the [official user guide](http://scikit-learn.org/0.17/modules/tree.html#classification) to the programming language Java:
<commit_msg>fix broken links<commit_after>
# sklearn-porter

[![Build Status](https://img.shields.io/travis/nok/sklearn-porter/master.svg)](https://travis-ci.org/nok/sklearn-porter)
[![Join the chat at https://gitter.im/nok/sklearn-porter](https://badges.gitter.im/nok/sklearn-porter.svg)](https://gitter.im/nok/sklearn-porter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nok/scikit-learn-model-porting/master/LICENSE.txt)

Module to port trained [scikit-learn](https://github.com/scikit-learn/scikit-learn) models to a low-level programming language like C, Java or JavaScript. It's recommended for limited embedded systems and critical applications where performance matters most.


## Target Algorithm Models

### Classification

The following matrix shows the portable classifier models:

<table>
    <tbody>
        <tr>
            <td width="32%"></td>
            <td align="center" width="17%"><strong>Example</strong></td>
            <td align="center" width="17%"><strong>C</strong></td>
            <td align="center" width="17%"><strong>Java</strong></td>
            <td align="center" width="17%"><strong>JavaScript</strong></td>
        </tr>
        <tr>
            <td><a href="http://scikit-learn.org/0.17/modules/generated/sklearn.tree.DecisionTreeClassifier.html">DecisionTreeClassifier</a></td>
            <td align="center"><a href="examples/classifier/decisiontree_predict.py">X</a></td>
            <td align="center"></td>
            <td align="center">X</td>
            <td align="center">X</td>
        </tr>
        <tr>
            <td><a href="http://scikit-learn.org/0.17/modules/generated/sklearn.ensemble.AdaBoostClassifier.html">AdaBoostClassifier</a></td>
            <td align="center"><a href="examples/classifier/adaboost_predict.py">X</a></td>
            <td align="center"></td>
            <td align="center">X</td>
            <td align="center">X</td>
        </tr>
        <tr>
            <td><a href="http://scikit-learn.org/0.17/modules/generated/sklearn.svm.LinearSVC.html">LinearSVC</a></td>
            <td align="center"><a href="examples/classifier/linear_svc_predict.py">X</a></td>
            <td align="center"></td>
            <td align="center">X</td>
            <td align="center"></td>
        </tr>
    </tbody>
</table>

<!--
### ~~Regression~~
The following matrix shows the portable regression models:
-->


## Usage

Either you use the porter in your application as [imported module](#module) or you use it on the [command line](#cli). 


### Module

This example shows how you can port the decision tree model from the [official user guide](http://scikit-learn.org/0.17/modules/tree.html#classification) to the programming language Java:

{'fraction_non_alphanumeric': 0.17324215325267403, 'fraction_numerical': 0.007715237594248641, 'mean_word_length': 3.2726591760299626, 'pattern_counts': {'":': 0, '<': 149, '<?xml version=': 0, '>': 149, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1579883', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1802, 'n_words': 326}