Skip to content

Commit 8a126c7

Browse files
Pranav ChoudharyPranav Choudhary
authored andcommitted
clean up docstrings
1 parent e4b7644 commit 8a126c7

2 files changed

Lines changed: 30 additions & 49 deletions

File tree

pyaptamer/aptanet/_feature_classifier.py

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,25 @@ class AptaNetClassifier(ClassifierMixin, BaseEstimator):
5050
eps : float, default=1e-08
5151
Epsilon value for numerical stability in the optimizer.
5252
weight_decay : float, default=0.0
53-
L2 regularisation (weight decay) applied by the optimizer. Increasing
54-
this value helps prevent the neural network from overfitting.
53+
L2 regularization penalty applied by the optimizer.
5554
n_estimators : int, default=300
56-
Number of trees in the ``RandomForestClassifier`` used for feature
57-
selection. Ignored when a custom ``estimator`` is provided.
55+
Number of trees in the `RandomForestClassifier` used for feature
56+
selection. Ignored when a custom `estimator` is provided.
5857
max_depth : int or None, default=9
59-
Maximum depth of each tree in the ``RandomForestClassifier`` used for
60-
feature selection. Ignored when a custom ``estimator`` is provided.
58+
Maximum depth of each tree in the `RandomForestClassifier` used for
59+
feature selection. Ignored when a custom `estimator` is provided.
6160
optimizer : torch.optim.Optimizer class, default=torch.optim.RMSprop
62-
PyTorch optimizer class to use for training the neural network.
61+
Optimizer class passed to skorch for neural network training.
6362
device : str or None, default=None
64-
Device string passed to skorch (e.g. ``"cpu"``, ``"cuda"``,
65-
``"cuda:1"``). When ``None``, the device is selected automatically:
66-
``"cuda"`` if a GPU is available, otherwise ``"cpu"``.
63+
Device string for skorch (e.g. `"cpu"`, `"cuda"`, `"cuda:1"`).
64+
If `None`, uses `"cuda"` when a GPU is available, else `"cpu"`.
6765
estimator : sklearn estimator or None, default=None
68-
Estimator used for feature selection via ``SelectFromModel``. When
69-
``None``, a ``RandomForestClassifier`` with ``n_estimators`` and
70-
``max_depth`` is used.
66+
Estimator passed to `SelectFromModel`. If `None`, uses a
67+
`RandomForestClassifier` with `n_estimators` and `max_depth`.
7168
random_state : int or None, default=None
72-
Random seed for reproducibility. When set, both NumPy and Torch seeds
73-
are fixed.
69+
Seed for NumPy and Torch random generators.
7470
threshold : str or float, default="mean"
75-
Threshold passed to ``SelectFromModel`` (e.g. ``"mean"`` or a float).
71+
Feature-selection threshold passed to `SelectFromModel`.
7672
verbose : int, default=0
7773
Verbosity level for the underlying skorch neural net.
7874
@@ -280,29 +276,25 @@ class AptaNetRegressor(RegressorMixin, BaseEstimator):
280276
eps : float, default=1e-08
281277
Epsilon value for numerical stability in the optimizer.
282278
weight_decay : float, default=0.0
283-
L2 regularisation (weight decay) applied by the optimizer. Increasing
284-
this value helps prevent the neural network from overfitting.
279+
L2 regularization penalty applied by the optimizer.
285280
n_estimators : int, default=300
286-
Number of trees in the ``RandomForestRegressor`` used for feature
287-
selection. Ignored when a custom ``estimator`` is provided.
281+
Number of trees in the `RandomForestRegressor` used for feature
282+
selection. Ignored when a custom `estimator` is provided.
288283
max_depth : int or None, default=9
289-
Maximum depth of each tree in the ``RandomForestRegressor`` used for
290-
feature selection. Ignored when a custom ``estimator`` is provided.
284+
Maximum depth of each tree in the `RandomForestRegressor` used for
285+
feature selection. Ignored when a custom `estimator` is provided.
291286
optimizer : torch.optim.Optimizer class, default=torch.optim.RMSprop
292-
PyTorch optimizer class to use for training the neural network.
287+
Optimizer class passed to skorch for neural network training.
293288
device : str or None, default=None
294-
Device string passed to skorch (e.g. ``"cpu"``, ``"cuda"``,
295-
``"cuda:1"``). When ``None``, the device is selected automatically:
296-
``"cuda"`` if a GPU is available, otherwise ``"cpu"``.
289+
Device string for skorch (e.g. `"cpu"`, `"cuda"`, `"cuda:1"`).
290+
If `None`, uses `"cuda"` when a GPU is available, else `"cpu"`.
297291
estimator : sklearn estimator or None, default=None
298-
Estimator used for feature selection via ``SelectFromModel``. When
299-
``None``, a ``RandomForestRegressor`` with ``n_estimators`` and
300-
``max_depth`` is used.
292+
Estimator passed to `SelectFromModel`. If `None`, uses a
293+
`RandomForestRegressor` with `n_estimators` and `max_depth`.
301294
random_state : int or None, default=None
302-
Random seed for reproducibility. When set, both NumPy and Torch seeds
303-
are fixed.
295+
Seed for NumPy and Torch random generators.
304296
threshold : str or float, default="mean"
305-
Threshold passed to ``SelectFromModel`` (e.g. ``"mean"`` or a float).
297+
Feature-selection threshold passed to `SelectFromModel`.
306298
verbose : int, default=0
307299
Verbosity level for the underlying skorch neural net.
308300
"""

pyaptamer/benchmarking/_base.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,13 @@ class Benchmarking:
4747
- "test" = mean of cross_validate(...)[f"test_{metric}"]
4848
4949
raw_results_ : pd.DataFrame or None
50-
Per-fold scores produced by :meth:`run` when ``return_raw=True``.
50+
Per-fold scores, populated after every :meth:`run` call.
5151
5252
- Index: pandas.MultiIndex with three levels
5353
- level 0 "estimator": estimator name
5454
- level 1 "metric": evaluator name
5555
- level 2 "fold": fold index (0-based)
5656
- Columns: ["train", "test"] (both floats)
57-
- Cell values: raw per-fold scores, directly compatible with
58-
``sktime``'s ``Evaluator`` for Friedman tests and Critical
59-
Difference diagrams.
6057
6158
Example
6259
-------
@@ -123,11 +120,7 @@ def _to_df(self, results):
123120
return pd.DataFrame(records, index=index, columns=["train", "test"])
124121

125122
def _to_raw_df(self, raw_results):
126-
"""Convert nested per-fold results to a raw DataFrame.
127-
128-
The resulting DataFrame is directly compatible with ``sktime``'s
129-
``Evaluator`` class for Friedman tests and Critical Difference diagrams.
130-
"""
123+
"""Convert nested per-fold results to a raw DataFrame."""
131124
records = []
132125
index = []
133126

@@ -151,14 +144,10 @@ def run(self, return_raw=False):
151144
Parameters
152145
----------
153146
return_raw : bool, default=False
154-
If ``False`` (default), returns only a summary DataFrame with
155-
mean scores across folds.
156-
157-
If ``True``, returns a tuple ``(summary, raw)`` where ``raw`` is
158-
a per-fold DataFrame with a three-level MultiIndex
159-
``(estimator, metric, fold)``. The ``raw`` DataFrame is directly
160-
compatible with ``sktime``'s ``Evaluator`` class for Friedman
161-
tests and Critical Difference diagrams.
147+
If `False` (default), returns only the summary DataFrame.
148+
If `True`, also returns `raw_results_` as the second element
149+
of a tuple, containing per-fold scores keyed by
150+
``(estimator, metric, fold)``.
162151
163152
Returns
164153
-------

0 commit comments

Comments
 (0)