Skip to content

Commit b8da597

Browse files
0.14.10
1 parent 2edeaaf commit b8da597

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

makeSpot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
2-
rm -f dist/spotPython*; python -m build; python -m pip install dist/spotPython*.tar.gz
2+
rm -f dist/spotpython*; python -m build; python -m pip install dist/spotpython*.tar.gz
33
python -m mkdocs build

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ requires = [
66
build-backend = "setuptools.build_meta"
77

88
[project]
9-
name = "spotPython"
10-
version = "0.14.9"
9+
name = "spotpython"
10+
version = "0.14.10"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]
14-
description = "spotPython - Sequential Parameter Optimization in Python"
14+
description = "spotpython - Sequential Parameter Optimization in Python"
1515
readme = "README.md"
1616
license = { text="AGPL-3.0-or-later" }
1717
requires-python = ">=3.10"
@@ -57,8 +57,8 @@ dependencies = [
5757

5858
[project.urls]
5959
"Homepage" = "https://www.spotseven.de"
60-
Issues = "https://github.com/sequential-parameter-optimization/spotPython/issues"
61-
Repository = "https://github.com/sequential-parameter-optimization/spotPython"
60+
Issues = "https://github.com/sequential-parameter-optimization/spotpython/issues"
61+
Repository = "https://github.com/sequential-parameter-optimization/spotpython"
6262

6363
[tool.setuptools]
6464
include-package-data = true

src/spotPython/utils/convert.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy as np
33
import pandas as pd
44
from itertools import combinations
5+
import copy
56

67

78
def class_for_name(module_name, class_name) -> object:
@@ -208,3 +209,28 @@ def check_type(value):
208209
return "bool"
209210
else:
210211
return None
212+
213+
214+
def set_dataset_target_type(dataset, target="y"):
215+
"""Set the target column to 0 and 1.
216+
217+
Args:
218+
dataset (pd.DataFrame): The input dataset.
219+
target (str): The name of the target column. Default is "y".
220+
221+
Returns:
222+
pd.DataFrame: The dataset with the target column set to 0 and 1.
223+
224+
Examples:
225+
>>> from spotPython.utils.convert import set_dataset_target_type
226+
dataset = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9], "y": [True, False, True]})
227+
dataset = set_dataset_target_type(dataset)
228+
229+
230+
"""
231+
val = copy.deepcopy(dataset.iloc[0, -1])
232+
target_type = check_type(val)
233+
if target_type == "bool" or target_type == "str":
234+
# convert the target column to 0 and 1
235+
dataset[target] = dataset[target].astype(int)
236+
return dataset

0 commit comments

Comments
 (0)