Skip to content

Commit

Permalink
docs: fix spelling and style mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
tachyonicClock authored and hmgomes committed May 1, 2024
1 parent f1f2416 commit 95c72fb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
23 changes: 13 additions & 10 deletions src/capymoa/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _extract_moa_learner_CLI(learner):
A string representing the CLI command for creating the MOA learner.
"""

# Check if the base_learner is a MOAClassifie or a MOARegressor
# Check if the base_learner is a MOAClassifier or a MOARegressor
if isinstance(learner, MOAClassifier) or isinstance(learner, MOARegressor):
learner = _get_moa_creation_CLI(learner.moa_learner)

Expand Down Expand Up @@ -214,6 +214,8 @@ class SKClassifier(Classifier):
A word of caution: even compatible scikit-learn classifiers are not
necessarily designed for online learning and might require some tweaking
to work well in an online setting.
See also :class:`capymoa.base.SKRegressor` for scikit-learn regressors.
"""

sklearner: _SKClassifierMixin
Expand All @@ -224,7 +226,7 @@ def __init__(self, sklearner: _SKClassifierMixin, schema: Schema = None, random_
:param sklearner: A scikit-learn classifier object to wrap that must
implements ``partial_fit`` and ``predict``.
:param schema: Descibes the structure of the datastream.
:param schema: Describes the structure of the datastream.
:param random_seed: Random seed for reproducibility.
:raises ValueError: If the scikit-learn algorithm does not implement
``partial_fit`` or ``predict``.
Expand Down Expand Up @@ -346,21 +348,20 @@ def predict(self, instance):


class SKRegressor(Regressor):
"""A wrapper class for using scikit-learn classifiers in CapyMOA.
"""A wrapper class for using scikit-learn regressors in CapyMOA.
Some of scikit-learn's classifiers that are compatible with online learning
Some of scikit-learn's regressors that are compatible with online learning
have been wrapped and tested already in CapyMOA (See :mod:`capymoa.regressor`).
However, if you want to use a scikit-learn classifier that has not been
However, if you want to use a scikit-learn regressor that has not been
wrapped yet, you can use this class to wrap it yourself. This requires
that the scikit-learn classifier implements the ``partial_fit`` and
that the scikit-learn regressor implements the ``partial_fit`` and
``predict`` methods.
For example, the following code demonstrates how to use a scikit-learn
classifier in CapyMOA:
regressor in CapyMOA:
>>> from sklearn.linear_model import SGDRegressor
>>> from capymoa.base import SKClassifier
>>> from capymoa.datasets import Fried
>>> stream = Fried()
>>> sklearner = SGDRegressor(random_state=1)
Expand All @@ -381,9 +382,11 @@ class SKRegressor(Regressor):
y_value: 18.566, y_prediction: 3.8024999398093753
y_value: 12.107, y_prediction: 3.8708584184864403
A word of caution: even compatible scikit-learn classifiers are not
A word of caution: even compatible scikit-learn regressors are not
necessarily designed for online learning and might require some tweaking
to work well in an online setting.
See also :class:`capymoa.base.SKClassifier` for scikit-learn classifiers.
"""

sklearner: _SKRegressorMixin
Expand All @@ -394,7 +397,7 @@ def __init__(self, sklearner: _SKRegressorMixin, schema: Schema = None, random_s
:param sklearner: A scikit-learn classifier object to wrap that must
implements ``partial_fit`` and ``predict``.
:param schema: Descibes the structure of the datastream.
:param schema: Describes the structure of the datastream.
:param random_seed: Random seed for reproducibility.
:raises ValueError: If the scikit-learn algorithm does not implement
``partial_fit`` or ``predict``.
Expand Down
6 changes: 3 additions & 3 deletions src/capymoa/classifier/_passive_aggressive_classifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional, Dict, Union, Literal
from capymoa.base import SKClassifier
from sklearn.linear_model import (
PassiveAggressiveClassifier as skPassiveAggressiveClassifier,
PassiveAggressiveClassifier as _SKPassiveAggressiveClassifier,
)
from capymoa.stream._stream import Schema

Expand All @@ -28,7 +28,7 @@ class PassiveAggressiveClassifier(SKClassifier):
84.3
"""

sklearner: skPassiveAggressiveClassifier
sklearner: _SKPassiveAggressiveClassifier
"""The underlying scikit-learn object. See: :sklearn:`linear_model.PassiveAggressiveClassifier`"""

def __init__(
Expand Down Expand Up @@ -70,7 +70,7 @@ def __init__(
"""

super().__init__(
skPassiveAggressiveClassifier(
_SKPassiveAggressiveClassifier(
C=max_step_size,
fit_intercept=fit_intercept,
early_stopping=False,
Expand Down
6 changes: 3 additions & 3 deletions src/capymoa/classifier/_sgd_classifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional, Literal
from capymoa.base import SKClassifier
from sklearn.linear_model import (
SGDClassifier as skSGDClassifier,
SGDClassifier as _SKSGDClassifier,
)
from capymoa.stream._stream import Schema

Expand All @@ -25,7 +25,7 @@ class SGDClassifier(SKClassifier):
84.2
"""

sklearner: skSGDClassifier
sklearner: _SKSGDClassifier
"""The underlying scikit-learn object"""

def __init__(
Expand Down Expand Up @@ -86,7 +86,7 @@ def __init__(
"""

super().__init__(
skSGDClassifier(
_SKSGDClassifier(
loss=loss,
penalty=penalty,
alpha=alpha,
Expand Down
6 changes: 3 additions & 3 deletions src/capymoa/regressor/_passive_aggressive_regressor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from capymoa.base import SKRegressor
from sklearn.linear_model import (
PassiveAggressiveRegressor as skPassiveAggressiveRegressor,
PassiveAggressiveRegressor as _SKPassiveAggressiveRegressor,
)
from capymoa.stream._stream import Schema

Expand All @@ -27,7 +27,7 @@ class PassiveAggressiveRegressor(SKRegressor):
3.7...
"""

sklearner: skPassiveAggressiveRegressor
sklearner: _SKPassiveAggressiveRegressor
"""The underlying scikit-learn object. See: :sklearn:`linear_model.PassiveAggressiveRegressor`"""

def __init__(
Expand Down Expand Up @@ -60,7 +60,7 @@ def __init__(
"""

super().__init__(
skPassiveAggressiveRegressor(
_SKPassiveAggressiveRegressor(
C=max_step_size,
fit_intercept=fit_intercept,
early_stopping=False,
Expand Down

0 comments on commit 95c72fb

Please sign in to comment.