Skip to content

Commit cbfe48a

Browse files
0.14.22
1 parent 4d46a8d commit cbfe48a

5 files changed

Lines changed: 25 additions & 24 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotpython"
10-
version = "0.14.21"
10+
version = "0.14.22"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/data/friedman.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class FriedmanDriftDataset:
66
"""Friedman Drift Dataset."""
77

8-
def __init__(self, n_samples=100, change_point1=50, change_point2=75, seed=None, constant=False):
8+
def __init__(self, n_samples=100, change_point1=50, change_point2=75, seed=None, constant=False) -> None:
99
"""Constructor for the Friedman Drift Dataset.
1010
1111
Args:
@@ -16,7 +16,7 @@ def __init__(self, n_samples=100, change_point1=50, change_point2=75, seed=None,
1616
constant (bool): If True, only the first feature is set to 1 and all others are set to 0.
1717
1818
Returns:
19-
None
19+
None (None): None
2020
2121
Examples:
2222
>>> from spotPython.data.friedman import FriedmanDriftDataset

src/spotPython/hyperparameters/values.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,31 +1466,31 @@ def update_fun_control_with_hyper_num_cat_dicts(fun_control, num_dict, cat_dict,
14661466
fun_control["core_model_hyper_dict"][key].update({"upper": len(fle) - 1})
14671467

14681468

1469-
def get_core_model_from_name(core_model_name):
1469+
def get_core_model_from_name(core_model_name) -> object:
14701470
"""
1471-
Returns the core model name and instance from a core model name.
1471+
Returns the river core model name and instance from a core model name.
14721472
14731473
Args:
14741474
core_model_name (str): The name of the core model.
14751475
14761476
Returns:
1477-
Tuple: The core model name and instance.
1477+
(str, object): The core model name and instance.
14781478
"""
14791479
core_model_module = core_model_name.split(".")[0]
14801480
coremodel = core_model_name.split(".")[1]
14811481
core_model_instance = getattr(getattr(river, core_model_module), coremodel)
14821482
return coremodel, core_model_instance
14831483

14841484

1485-
def get_prep_model(prepmodel_name):
1485+
def get_prep_model(prepmodel_name) -> object:
14861486
"""
1487-
Get the preprocessing model from the name.
1487+
Get the river preprocessing model from the name.
14881488
14891489
Args:
14901490
prepmodel_name (str): The name of the preprocessing model.
14911491
14921492
Returns:
1493-
river.preprocessing: The preprocessing model.
1493+
river.preprocessing (object): The river preprocessing model.
14941494
14951495
"""
14961496
if prepmodel_name == "None":
@@ -1500,15 +1500,15 @@ def get_prep_model(prepmodel_name):
15001500
return prepmodel
15011501

15021502

1503-
def get_metric_sklearn(metric_name):
1503+
def get_metric_sklearn(metric_name) -> object:
15041504
"""
1505-
Returns the metric from the metric name.
1505+
Returns the sklearn metric from the metric name.
15061506
15071507
Args:
15081508
metric_name (str): The name of the metric.
15091509
15101510
Returns:
1511-
sklearn.metrics: The metric from the metric name.
1511+
sklearn.metrics (object): The sklearn metric.
15121512
"""
15131513
metric_sklearn = getattr(sklearn.metrics, metric_name)
15141514
return metric_sklearn

src/spotPython/plot/xai.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def get_attributions(
585585
baseline=None,
586586
abs_attr=True,
587587
n_rel=5,
588-
):
588+
) -> pd.DataFrame:
589589
"""Get the attributions of a neural network.
590590
591591
Args:
@@ -603,7 +603,7 @@ def get_attributions(
603603
The number of relevant features. Defaults to 5.
604604
605605
Returns:
606-
pd.DataFrame: A DataFrame with the attributions.
606+
pd.DataFrame (object): A DataFrame with the attributions.
607607
"""
608608
try:
609609
fun_control["data_set"].names
@@ -673,7 +673,7 @@ def get_attributions(
673673
return df
674674

675675

676-
def plot_attributions(df, attr_method="IntegratedGradients"):
676+
def plot_attributions(df, attr_method="IntegratedGradients") -> None:
677677
"""
678678
Plot the attributions of a neural network.
679679
@@ -696,7 +696,7 @@ def plot_attributions(df, attr_method="IntegratedGradients"):
696696
plt.show()
697697

698698

699-
def is_square(n):
699+
def is_square(n) -> bool:
700700
"""Check if a number is a square number.
701701
702702
Args:
@@ -714,7 +714,7 @@ def is_square(n):
714714
return n == int(math.sqrt(n)) ** 2
715715

716716

717-
def get_layer_conductance(spot_tuner, fun_control, layer_idx):
717+
def get_layer_conductance(spot_tuner, fun_control, layer_idx) -> np.ndarray:
718718
"""
719719
Compute the average layer conductance attributions for a specified layer in the model.
720720

src/spotPython/utils/convert.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,17 @@ def sort_by_kth_and_return_indices(array, k) -> list:
182182
return sorted_indices
183183

184184

185-
def check_type(value):
185+
def check_type(value) -> str:
186186
"""Check the type of the input value and return the type as a string.
187187
188188
Args:
189189
value (object): The input value.
190190
191191
Returns:
192-
str: The type of the input value as a string.
193-
Possible values are "int", "float", "str", "bool", or None.
194-
Checks for numpy types as well, i.e., np.integer, np.floating, np.str_, np.bool_.
192+
str:
193+
The type of the input value as a string.
194+
Possible values are "int", "float", "str", "bool", or None.
195+
Checks for numpy types as well, i.e., np.integer, np.floating, np.str_, np.bool_.
195196
196197
Examples:
197198
>>> from spotPython.utils.convert import check_type
@@ -211,16 +212,16 @@ def check_type(value):
211212
return None
212213

213214

214-
def set_dataset_target_type(dataset, target="y"):
215+
def set_dataset_target_type(dataset, target="y") -> pd.DataFrame:
215216
"""Set the target column to 0 and 1 for boolean and string values.
216217
217218
Args:
218219
dataset (pd.DataFrame): The input dataset.
219220
target (str): The name of the target column. Default is "y".
220221
221222
Returns:
222-
pd.DataFrame: The dataset with boolean and string target column
223-
values set to 0 and 1.
223+
pd.DataFrame:
224+
The dataset with boolean and string target column values set to 0 and 1.
224225
225226
Examples:
226227
>>> from spotPython.utils.convert import set_dataset_target_type

0 commit comments

Comments
 (0)