diff --git a/abl/data/evaluation/__init__.py b/abl/data/evaluation/__init__.py index b20da2c..3816941 100644 --- a/abl/data/evaluation/__init__.py +++ b/abl/data/evaluation/__init__.py @@ -1,5 +1,5 @@ from .base_metric import BaseMetric from .reasoning_metric import ReasoningMetric -from .symbol_metric import SymbolMetric +from .symbol_accuracy import SymbolAccuracy -__all__ = ["BaseMetric", "ReasoningMetric", "SymbolMetric"] +__all__ = ["BaseMetric", "ReasoningMetric", "SymbolAccuracy"] diff --git a/abl/data/evaluation/symbol_metric.py b/abl/data/evaluation/symbol_accuracy.py similarity index 98% rename from abl/data/evaluation/symbol_metric.py rename to abl/data/evaluation/symbol_accuracy.py index ed65947..568fd02 100644 --- a/abl/data/evaluation/symbol_metric.py +++ b/abl/data/evaluation/symbol_accuracy.py @@ -6,7 +6,7 @@ from ..structures import ListData from .base_metric import BaseMetric -class SymbolMetric(BaseMetric): +class SymbolAccuracy(BaseMetric): """ A metrics class for evaluating symbol-level accuracy. diff --git a/docs/Examples/HED.rst b/docs/Examples/HED.rst index 9a4c262..a0a907e 100644 --- a/docs/Examples/HED.rst +++ b/docs/Examples/HED.rst @@ -32,7 +32,7 @@ model. from examples.models.nn import SymbolNet from abl.learning import ABLModel, BasicNN from examples.hed.reasoning import HedKB, HedReasoner - from abl.data.evaluation import ReasoningMetric, SymbolMetric + from abl.data.evaluation import ReasoningMetric, SymbolAccuracy from abl.utils import ABLLogger, print_log from examples.hed.bridge import HedBridge @@ -259,7 +259,7 @@ Building Evaluation Metrics Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. -Specifically, we use ``SymbolMetric`` and ``ReasoningMetric``, which are +Specifically, we use ``SymbolAccuracy`` and ``ReasoningMetric``, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively. @@ -267,7 +267,7 @@ respectively. .. code:: ipython3 # Set up metrics - metric_list = [SymbolMetric(prefix="hed"), ReasoningMetric(kb=kb, prefix="hed")] + metric_list = [SymbolAccuracy(prefix="hed"), ReasoningMetric(kb=kb, prefix="hed")] Bridge Learning and Reasoning ----------------------------- diff --git a/docs/Examples/HWF.rst b/docs/Examples/HWF.rst index 9c59ca4..595b505 100644 --- a/docs/Examples/HWF.rst +++ b/docs/Examples/HWF.rst @@ -30,7 +30,7 @@ machine learning model. from examples.models.nn import SymbolNet from abl.learning import ABLModel, BasicNN from abl.reasoning import KBBase, Reasoner - from abl.data.evaluation import ReasoningMetric, SymbolMetric + from abl.data.evaluation import ReasoningMetric, SymbolAccuracy from abl.utils import ABLLogger, print_log from abl.bridge import SimpleBridge @@ -353,14 +353,14 @@ Building Evaluation Metrics Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. -Specifically, we use ``SymbolMetric`` and ``ReasoningMetric``, which are +Specifically, we use ``SymbolAccuracy`` and ``ReasoningMetric``, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively. .. code:: ipython3 - metric_list = [SymbolMetric(prefix="hwf"), ReasoningMetric(kb=kb, prefix="hwf")] + metric_list = [SymbolAccuracy(prefix="hwf"), ReasoningMetric(kb=kb, prefix="hwf")] Bridge Learning and Reasoning ----------------------------- diff --git a/docs/Examples/MNISTAdd.rst b/docs/Examples/MNISTAdd.rst index 2d1f30a..3f69b38 100644 --- a/docs/Examples/MNISTAdd.rst +++ b/docs/Examples/MNISTAdd.rst @@ -28,7 +28,7 @@ machine learning model. from examples.models.nn import LeNet5 from abl.learning import ABLModel, BasicNN from abl.reasoning import KBBase, Reasoner - from abl.data.evaluation import ReasoningMetric, SymbolMetric + from abl.data.evaluation import ReasoningMetric, SymbolAccuracy from abl.utils import ABLLogger, print_log from abl.bridge import SimpleBridge @@ -300,14 +300,14 @@ Building Evaluation Metrics Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. -Specifically, we use ``SymbolMetric`` and ``ReasoningMetric``, which are +Specifically, we use ``SymbolAccuracy`` and ``ReasoningMetric``, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively. .. code:: ipython3 - metric_list = [SymbolMetric(prefix="mnist_add"), ReasoningMetric(kb=kb, prefix="mnist_add")] + metric_list = [SymbolAccuracy(prefix="mnist_add"), ReasoningMetric(kb=kb, prefix="mnist_add")] Bridge Learning and Reasoning ----------------------------- diff --git a/docs/Intro/Basics.rst b/docs/Intro/Basics.rst index bac8708..baebbd9 100644 --- a/docs/Intro/Basics.rst +++ b/docs/Intro/Basics.rst @@ -26,7 +26,7 @@ It first features class ``ListData`` (derived from base class ``BaseDataElement``), which defines the data structures used in Abductive Learning, and comprises common data operations like insertion, deletion, retrieval, slicing, etc. Additionally, a series of Evaluation -Metrics, including class ``SymbolMetric`` and ``ReasoningMetric`` (both +Metrics, including class ``SymbolAccuracy`` and ``ReasoningMetric`` (both specialized metrics derived from base class ``BaseMetric``), outline methods for evaluating model quality from a data perspective. diff --git a/docs/Intro/Evaluation.rst b/docs/Intro/Evaluation.rst index dfad61d..b8679e5 100644 --- a/docs/Intro/Evaluation.rst +++ b/docs/Intro/Evaluation.rst @@ -15,7 +15,7 @@ In this section, we will look at how to build evaluation metrics. .. code:: python # Import necessary modules - from abl.data.evaluation import BaseMetric, SymbolMetric, ReasoningMetric + from abl.data.evaluation import BaseMetric, SymbolAccuracy, ReasoningMetric ABL-Package seperates the evaluation process from model training and testing as an independent class, ``BaseMetric``. The training and testing processes are implemented in the ``BaseBridge`` class, so metrics are used by this class and its sub-classes. After building a ``bridge`` with a list of ``BaseMetric`` instances, these metrics will be used by the ``bridge.valid`` method to evaluate the model performance during training and testing. @@ -25,11 +25,11 @@ To customize our own metrics, we need to inherit from ``BaseMetric`` and impleme - The ``compute_metrics`` method uses all the information saved in ``self.results`` to calculate and return a dict that holds the evaluation results. Besides, we can assign a ``str`` to the ``prefix`` argument of the ``__init__`` function. This string is automatically prefixed to the output metric names. For example, if we set ``prefix="mnist_add"``, the output metric name will be ``character_accuracy``. -We provide two basic metrics, namely ``SymbolMetric`` and ``ReasoningMetric``, which are used to evaluate the accuracy of the machine learning model's predictions and the accuracy of the final reasoning results, respectively. Using ``SymbolMetric`` as an example, the following code shows how to implement a custom metrics. +We provide two basic metrics, namely ``SymbolAccuracy`` and ``ReasoningMetric``, which are used to evaluate the accuracy of the machine learning model's predictions and the accuracy of the final reasoning results, respectively. Using ``SymbolAccuracy`` as an example, the following code shows how to implement a custom metrics. .. code:: python - class SymbolMetric(BaseMetric): + class SymbolAccuracy(BaseMetric): def __init__(self, prefix: Optional[str] = None) -> None: # prefix is used to distinguish different metrics super().__init__(prefix) diff --git a/docs/Intro/Quick-Start.rst b/docs/Intro/Quick-Start.rst index b6e9412..215f2e8 100644 --- a/docs/Intro/Quick-Start.rst +++ b/docs/Intro/Quick-Start.rst @@ -107,13 +107,13 @@ Read more about `building the reasoning part `_. Building Evaluation Metrics --------------------------- -ABL-Package provides two basic metrics, namely ``SymbolMetric`` and ``ReasoningMetric``, which are used to evaluate the accuracy of the machine learning model's predictions and the accuracy of the ``logic_forward`` results, respectively. +ABL-Package provides two basic metrics, namely ``SymbolAccuracy`` and ``ReasoningMetric``, which are used to evaluate the accuracy of the machine learning model's predictions and the accuracy of the ``logic_forward`` results, respectively. .. code:: python - from abl.data.evaluation import ReasoningMetric, SymbolMetric + from abl.data.evaluation import ReasoningMetric, SymbolAccuracy - metric_list = [SymbolMetric(prefix="mnist_add"), ReasoningMetric(kb=kb, prefix="mnist_add")] + metric_list = [SymbolAccuracy(prefix="mnist_add"), ReasoningMetric(kb=kb, prefix="mnist_add")] Read more about `building evaluation metrics `_ diff --git a/examples/hed/hed.ipynb b/examples/hed/hed.ipynb index 6c9489b..bc649da 100644 --- a/examples/hed/hed.ipynb +++ b/examples/hed/hed.ipynb @@ -26,7 +26,7 @@ "from examples.models.nn import SymbolNet\n", "from abl.learning import ABLModel, BasicNN\n", "from examples.hed.reasoning import HedKB, HedReasoner\n", - "from abl.data.evaluation import ReasoningMetric, SymbolMetric\n", + "from abl.data.evaluation import ReasoningMetric, SymbolAccuracy\n", "from abl.utils import ABLLogger, print_log\n", "from examples.hed.bridge import HedBridge" ] @@ -335,7 +335,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. Specifically, we use `SymbolMetric` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively." + "Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. Specifically, we use `SymbolAccuracy` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively." ] }, { @@ -345,7 +345,7 @@ "outputs": [], "source": [ "# Set up metrics\n", - "metric_list = [SymbolMetric(prefix=\"hed\"), ReasoningMetric(kb=kb, prefix=\"hed\")]" + "metric_list = [SymbolAccuracy(prefix=\"hed\"), ReasoningMetric(kb=kb, prefix=\"hed\")]" ] }, { diff --git a/examples/hwf/hwf.ipynb b/examples/hwf/hwf.ipynb index 65e7481..56ef943 100644 --- a/examples/hwf/hwf.ipynb +++ b/examples/hwf/hwf.ipynb @@ -27,7 +27,7 @@ "from examples.models.nn import SymbolNet\n", "from abl.learning import ABLModel, BasicNN\n", "from abl.reasoning import KBBase, Reasoner\n", - "from abl.data.evaluation import ReasoningMetric, SymbolMetric\n", + "from abl.data.evaluation import ReasoningMetric, SymbolAccuracy\n", "from abl.utils import ABLLogger, print_log\n", "from abl.bridge import SimpleBridge" ] @@ -434,7 +434,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. Specifically, we use `SymbolMetric` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively." + "Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. Specifically, we use `SymbolAccuracy` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively." ] }, { @@ -443,7 +443,7 @@ "metadata": {}, "outputs": [], "source": [ - "metric_list = [SymbolMetric(prefix=\"hwf\"), ReasoningMetric(kb=kb, prefix=\"hwf\")]" + "metric_list = [SymbolAccuracy(prefix=\"hwf\"), ReasoningMetric(kb=kb, prefix=\"hwf\")]" ] }, { diff --git a/examples/hwf/main.py b/examples/hwf/main.py index 83161ad..b6264a6 100644 --- a/examples/hwf/main.py +++ b/examples/hwf/main.py @@ -10,7 +10,7 @@ from examples.hwf.datasets import get_dataset from examples.models.nn import SymbolNet from abl.learning import ABLModel, BasicNN from abl.reasoning import KBBase, GroundKB, Reasoner -from abl.data.evaluation import ReasoningMetric, SymbolMetric +from abl.data.evaluation import ReasoningMetric, SymbolAccuracy from abl.utils import ABLLogger, print_log from abl.bridge import SimpleBridge @@ -152,7 +152,7 @@ def main(): ) ### Building Evaluation Metrics - metric_list = [SymbolMetric(prefix="hwf"), ReasoningMetric(kb=kb, prefix="hwf")] + metric_list = [SymbolAccuracy(prefix="hwf"), ReasoningMetric(kb=kb, prefix="hwf")] ### Bridge Learning and Reasoning bridge = SimpleBridge(model, reasoner, metric_list) diff --git a/examples/mnist_add/main.py b/examples/mnist_add/main.py index e00c7fd..0bf4a35 100644 --- a/examples/mnist_add/main.py +++ b/examples/mnist_add/main.py @@ -9,7 +9,7 @@ from examples.mnist_add.datasets import get_dataset from examples.models.nn import LeNet5 from abl.learning import ABLModel, BasicNN from abl.reasoning import KBBase, GroundKB, PrologKB, Reasoner -from abl.data.evaluation import ReasoningMetric, SymbolMetric +from abl.data.evaluation import ReasoningMetric, SymbolAccuracy from abl.utils import ABLLogger, print_log from abl.bridge import SimpleBridge @@ -117,7 +117,7 @@ def main(): ) ### Building Evaluation Metrics - metric_list = [SymbolMetric(prefix="mnist_add"), ReasoningMetric(kb=kb, prefix="mnist_add")] + metric_list = [SymbolAccuracy(prefix="mnist_add"), ReasoningMetric(kb=kb, prefix="mnist_add")] ### Bridge Learning and Reasoning bridge = SimpleBridge(model, reasoner, metric_list) diff --git a/examples/mnist_add/mnist_add.ipynb b/examples/mnist_add/mnist_add.ipynb index aed35b4..d23af63 100644 --- a/examples/mnist_add/mnist_add.ipynb +++ b/examples/mnist_add/mnist_add.ipynb @@ -26,7 +26,7 @@ "from examples.models.nn import LeNet5\n", "from abl.learning import ABLModel, BasicNN\n", "from abl.reasoning import KBBase, Reasoner\n", - "from abl.data.evaluation import ReasoningMetric, SymbolMetric\n", + "from abl.data.evaluation import ReasoningMetric, SymbolAccuracy\n", "from abl.utils import ABLLogger, print_log\n", "from abl.bridge import SimpleBridge" ] @@ -122,7 +122,7 @@ }, { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgMAAAD1CAYAAADNj/Z6AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAKUklEQVR4nO3df6zVdR3H8XPuDy4iCHcRUnKRQIFkOFHzV+Z0maVhM5dZyzY1JWCUbmk/tkwrXWXRQB0xayVUarOcthhmFJpL5GflYgTiryyV3wgIXrjnnv6x/kh4fy+de++58H48/n2d+z3ff+7hyXe7n1OuVqvVEgCQVkO9bwAAqC8xAADJiQEASE4MAEByYgAAkhMDAJCcGACA5MQAACQnBgAguaauvvADDZf15H0AXfC7zgfqfQsHzWcH1F/RZ4cnAwCQnBgAgOTEAAAkJwYAIDkxAADJiQEASE4MAEByYgAAkhMDAJCcGACA5MQAACQnBgAgOTEAAMmJAQBITgwAQHJiAACSEwMAkJwYAIDkxAAAJCcGACA5MQAAyYkBAEhODABAcmIAAJITAwCQnBgAgOTEAAAkJwYAIDkxAADJiQEASE4MAEByYgAAkhMDAJCcGACA5MQAACQnBgAgOTEAAMmJAQBIrqneNwBAbg2DBoV7+Z1H99KdHNiLlw4L9/ahneHetCv+v/foezeGe2Xt+nCvlScDAJCcGACA5MQAACQnBgAgOTEAAMmJAQBITgw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QEASE4MAEByYgAAkhMDAJCcGACA5MQAACQnBgAgOTEAAMmJAQBITgwAQHLlarVarfdNAAD148kAACQnBgAgOTEAAMmJAQBITgwAQHJiAACSEwMAkJwYAIDkxAAAJPdvx8SA9zSwVzUAAAAASUVORK5CYII=", "text/plain": [ "
" ] @@ -380,7 +380,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. Specifically, we use `SymbolMetric` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively." + "Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. Specifically, we use `SymbolAccuracy` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively." ] }, { @@ -389,7 +389,7 @@ "metadata": {}, "outputs": [], "source": [ - "metric_list = [SymbolMetric(prefix=\"mnist_add\"), ReasoningMetric(kb=kb, prefix=\"mnist_add\")]" + "metric_list = [SymbolAccuracy(prefix=\"mnist_add\"), ReasoningMetric(kb=kb, prefix=\"mnist_add\")]" ] }, { @@ -420,7 +420,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -432,13 +432,6 @@ "bridge.train(train_data, loops=5, segment_size=1/3, save_interval=1, save_dir=weights_dir)\n", "bridge.test(test_data)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/examples/zoo/main.py b/examples/zoo/main.py index 76f39af..59f2e2c 100644 --- a/examples/zoo/main.py +++ b/examples/zoo/main.py @@ -8,7 +8,7 @@ import openml from abl.learning import ABLModel from abl.reasoning import KBBase, Reasoner -from abl.data.evaluation import ReasoningMetric, SymbolMetric +from abl.data.evaluation import ReasoningMetric, SymbolAccuracy from abl.bridge import SimpleBridge from abl.utils.utils import confidence_dist from abl.utils import ABLLogger, print_log @@ -182,7 +182,7 @@ train_data = transform_tab_data(X_unlabel, y_unlabel) # %% # Set up metrics -metric_list = [SymbolMetric(prefix="zoo"), ReasoningMetric(kb=kb, prefix="zoo")] +metric_list = [SymbolAccuracy(prefix="zoo"), ReasoningMetric(kb=kb, prefix="zoo")] # %% [markdown] # ### Bridge Machine Learning and Logic Reasoning diff --git a/examples/zoo/zoo.ipynb b/examples/zoo/zoo.ipynb index 7a85644..a16ff87 100644 --- a/examples/zoo/zoo.ipynb +++ b/examples/zoo/zoo.ipynb @@ -25,7 +25,7 @@ "from abl.learning import ABLModel\n", "from examples.zoo.kb import ZooKB\n", "from abl.reasoning import Reasoner\n", - "from abl.data.evaluation import ReasoningMetric, SymbolMetric\n", + "from abl.data.evaluation import ReasoningMetric, SymbolAccuracy\n", "from abl.utils import ABLLogger, print_log, confidence_dist\n", "from abl.bridge import SimpleBridge" ] @@ -276,7 +276,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. Specifically, we use `SymbolMetric` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively." + "Next, we set up evaluation metrics. These metrics will be used to evaluate the model performance during training and testing. Specifically, we use `SymbolAccuracy` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model’s predictions and the accuracy of the final reasoning results, respectively." ] }, { @@ -285,7 +285,7 @@ "metadata": {}, "outputs": [], "source": [ - "metric_list = [SymbolMetric(prefix=\"zoo\"), ReasoningMetric(kb=kb, prefix=\"zoo\")]" + "metric_list = [SymbolAccuracy(prefix=\"zoo\"), ReasoningMetric(kb=kb, prefix=\"zoo\")]" ] }, {