Home

Awesome

Nyoka

Test Master Branch PyPI version codecov license Python <img src="https://raw.githubusercontent.com/softwareag/nyoka/master/docs/nyoka_logo.PNG" alt="nyoka_logo" height="200" style="float:right"/>

Overview

Nyoka is a Python library for comprehensive support of the latest PMML (PMML 4.4) standard. Using Nyoka, Data Scientists can export a large number of Machine Learning models from popular Python frameworks into PMML by either using any of the numerous included ready-to-use exporters or by creating their own exporter for specialized/individual model types by simply calling a sequence of constructors.

Besides about 500 Python classes which each cover a PMML tag and all constructor parameters/attributes as defined in the standard, Nyoka also provides an increasing number of convenience classes and functions that make the Data Scientist’s life easier for example by reading or writing any PMML file in one line of code from within your favorite Python environment.

Nyoka comes to you with the complete source code in Python, extended HTML documentation for the classes/functions, and a growing number of Jupyter Notebook tutorials that help you familiarize yourself with the way Nyoka supports you in using PMML as your favorite Data Science transport file format.

Read the documentation at Nyoka Documentation.

List of libraries and models supported by Nyoka :

Scikit-Learn (version <= 1.3.0):

Models -

Pre-Processing -

LightGBM:

XGBoost (version <= 1.7.6):

Statsmodels (version <= 0.14.0):

Prerequisites

Dependencies

nyoka requires:

Installation

You can install nyoka using:

pip install --upgrade nyoka

Usage

Nyoka contains seperate exporters for each library, e.g., scikit-learn, keras, xgboost etc.

libraryexporter
scikit-learnskl_to_pmml
xgboostxgboost_to_pmml
lightgbmlgbm_to_pmml
statsmodelsStatsmodelsToPmml & ExponentialSmoothingToPmml

Note - The support of keras is until 4.4.0 release of Nyoka.

The main module of Nyoka is nyoka. To use it for your model, you need to import the specific exporter from nyoka as -

from nyoka import skl_to_pmml, lgb_to_pmml #... so on

Note - If scikit-learn, xgboost and lightgbm model is used then the model should be used inside sklearn's Pipeline.

The workflow is as follows (For example, a Decision Tree Classifier with StandardScaler) -

For Statsmodels, pipeline is not required. The fitted model needs to be passed to the exporter.

import pandas as pd
from statsmodels.tsa.arima_model import ARIMA
from nyoka import StatsmodelsToPmml
sales_data = pd.read_csv('sales-cars.csv', index_col=0, parse_dates = True)
model = ARIMA(sales_data, order = (4, 1, 2))
result = model.fit()
StatsmodelsToPmml(result,"Sales_cars_ARIMA.pmml")

Examples

Example jupyter notebooks can be found in nyoka/examples. These files contain code to showcase how to use different exporters.

Nyoka Submodules

Nyoka contains one submodule called preprocessing. This module contains preprocessing classes implemented by Nyoka. Currently there is only one preprocessing class, which is Lag.

What is Lag? When to use it?

Lag is a preprocessing class implemented by Nyoka. When used inside scikit-learn's pipeline, it simply applies an aggregation function for the given features of the dataset by combining value number of previous records. It takes two arguments- aggregation and value.

The valid aggregation functions are - "min", "max", "sum", "avg", "median", "product" and "stddev".

To use Lag -

Uninstallation

pip uninstall nyoka

Support

You can ask questions at:


Please note that this project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.