From 56d066c60457b10f3a7e6fbb76503b57bcf27f9d Mon Sep 17 00:00:00 2001 From: Gao Enhao Date: Wed, 13 Dec 2023 00:55:41 +0800 Subject: [PATCH] [MNT] resolve comments in Learning.rst --- docs/Intro/Learning.rst | 13 ++++--------- docs/Intro/Quick-Start.rst | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/docs/Intro/Learning.rst b/docs/Intro/Learning.rst index 66d644b..256e3f3 100644 --- a/docs/Intro/Learning.rst +++ b/docs/Intro/Learning.rst @@ -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 diff --git a/docs/Intro/Quick-Start.rst b/docs/Intro/Quick-Start.rst index e9b2968..3573eb5 100644 --- a/docs/Intro/Quick-Start.rst +++ b/docs/Intro/Quick-Start.rst @@ -75,7 +75,7 @@ Read more about `preparing datasets `_. 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