.. sklearn-fab documentation master file, created by
   sphinx-quickstart on Wed Jun 12 10:53:05 2019.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

sklearn-fab Reference V\ |release|
==================================

.. Contents:: Contents
    :local:
    :depth: 2

Overview
--------

What is sklearn-fab?
~~~~~~~~~~~~~~~~~~~~
sklearn-fab is a scikit-learn-compatible library using the FAB-engine
for regression and classification problems.

* Features:

  * follows the scikit-learn API conventions (can fit with *numpy* or *pandas* data)
  * utilizes highly configurable FAB/HME learners for Heterogeneous Mixture Learning applications
  * fits supervised binary tree models called FAB/HME models
  * offers a tool to visualize FAB/HME models

To learn more about FAB and the FAB-engine, refer to the FAB Reference.

sklearn-fab v\ |release| currently supports the following FAB-engine features:

* Supported learners:

  * Single target Bernoulli-gate Linear Regression component Learner (Bern/Rg)
  * Single target Bernoulli-gate Linear Classification component Learner (Bern/Cl)
  * Multi target Bernoulli-gate linear Classification component Learner (Bern/MCl)

* Supported initialization types:

  * random start

Quickstart
----------

Installation
~~~~~~~~~~~~

1. (Optional) Prepare Python3.8 environment

.. code-block::

        $ sudo yum install -y centos-release-scl-rh
        $ sudo yum install -y rh-python38-python rh-python38-python-pip rh-python38-python-devel
        $ source /opt/rh/rh-python38/enable

2. Extract the sklearn-fab-\ |release|\ .zip file into any directory

.. code-block::

        $ unzip sklearn-fab-1.1.0.zip

3. Install the required rpm packages

.. code-block::

        $ sudo yum install -y sklearn-fab-1.1.0/rpms/*.rpm

4. Install the required python packages

.. code-block::

        $ sudo pip install sklearn-fab-1.1.0/whls/*whl

Core Usage Example
~~~~~~~~~~~~~~~~~~

.. code-block::

    import logging
    from sklearn_fab import SklearnFABBernGateLinearRegressor
    from sklearn.datasets import load_boston

    # Display progress logs on stdout
    logging.basicConfig(level=logging.INFO)

    # Initialize estimator instance
    rg = SklearnFABBernGateLinearRegressor(tree_depth=3, shrink_threshold=2.0)

    # Execute estimator fit()
    rg.fit(load_boston().data[:-1], load_boston().target[:-1])

    # Execute estimator predict()
    rg.predict(load_boston().data[-1:])


API Reference
-------------

SklearnFABEstimators
~~~~~~~~~~~~~~~~~~~~

.. toctree::
   :maxdepth: 2

   estimators/sklearn_fab_bern_gate_linear_regressor.rst
   estimators/sklearn_fab_bern_gate_linear_classifier.rst
   estimators/sklearn_fab_bern_gate_softmax_classifier.rst

Model Objects
~~~~~~~~~~~~~

.. toctree::
   :maxdepth: 2

   model/sklearn_fab_tree.rst

Utilities
~~~~~~~~~

.. toctree::
   :maxdepth: 2

   utils/gate_tree_vis.rst
