Browse Source

[MNT] resolve comments in Learning.rst

pull/1/head
Gao Enhao 1 year ago
parent
commit
56d066c604
2 changed files with 6 additions and 11 deletions
  1. +4
    -9
      docs/Intro/Learning.rst
  2. +2
    -2
      docs/Intro/Quick-Start.rst

+ 4
- 9
docs/Intro/Learning.rst View File

@@ -10,18 +10,13 @@
Learning Part
=============

``ABLModel`` class serves as a unified interface to all machine learning models. Its constructor, the ``__init__`` method, takes a singular argument, ``base_model``. This argument denotes the fundamental machine learning model, which must implement the ``fit`` and ``predict`` methods.
Learnig part is constructed by first defining a base machine learning model and then wrap it into an instance of ``ABLModel`` class.

.. code:: python

class ABLModel:
def __init__(self, base_model: Any) -> None:
if not (hasattr(base_model, "fit") and hasattr(base_model, "predict")):
raise NotImplementedError("The base_model should implement fit and predict methods.")
The flexibility of ABL package allows the base model to be any machine learning model conforming to the scikit-learn style, which requires implementing the ``fit`` and ``predict`` methods, or a PyTorch-based neural network, provided it has defined the architecture and implemented the ``forward`` method.

self.base_model = base_model
Typically, base models are trained and make predictions on instance-level data, e.g. single images in the MNIST dataset, and therefore can not directly utilize sample-level data to train and predict, which is not suitable for most neural-symbolic tasks. ABL-Package provides the ``ABLModel`` to solve this problem. This class serves as a unified wrapper for all base models, which enables the learning part to train, test, and predict on sample-level data. The following two parts shows how to construct an ``ABLModel`` from a scikit-learn model and a PyTorch-based neural network, respectively.

All scikit-learn models satisify this requirements, so we can directly use the model to create an instance of ``ABLModel``. For example, we can customize our machine learning model by
For a scikit-learn model, we can directly use the model to create an instance of ``ABLModel``. For example, we can customize our machine learning model by

.. code:: python



+ 2
- 2
docs/Intro/Quick-Start.rst View File

@@ -75,7 +75,7 @@ Read more about `preparing datasets <Datasets.html>`_.
Building the Learning Part
--------------------------

Learnig part is constructed by first defining a base machine learning model and then wrap it into the ``ABLModel`` class.
Learnig part is constructed by first defining a base machine learning model and then wrap it into an instance of ``ABLModel`` class.
The flexibility of ABL package allows the base model to be any machine learning model conforming to the scikit-learn style, which requires implementing the ``fit`` and ``predict`` methods, or a PyTorch-based neural network, provided it has defined the architecture and implemented the ``forward`` method.
In the MNIST Addition example, we build a simple LeNet5 network as the base model.

@@ -113,7 +113,7 @@ Out:
Shape of pred_idx : (32,)
Shape of pred_prob : (32, 10)

Afterward, we wrap the scikit-learn style model, ``base_model``, into an instance of ``ABLModel``. This class serves as a unified wrapper for all base models, facilitating the learning part to train, test, and predict on instance-level data - such as equations in the MNIST Addition.
Afterward, we wrap the scikit-learn style model, ``base_model``, into an instance of ``ABLModel``. This class serves as a unified wrapper for all base models, facilitating the learning part to train, test, and predict on sample-level data - such as equations in the MNIST Addition task.

.. code:: python



Loading…
Cancel
Save