Skip to content

Commit 4a14d4b

Browse files
0.14.50
get core model for river / sklearn
1 parent 4facf89 commit 4a14d4b

9 files changed

Lines changed: 634 additions & 296 deletions

File tree

notebooks/00_spotPython_tests.ipynb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4409,6 +4409,41 @@
44094409
"data.frame.to_csv('~/data.csv', index=False)"
44104410
]
44114411
},
4412+
{
4413+
"cell_type": "markdown",
4414+
"metadata": {},
4415+
"source": [
4416+
"## Moons Data Set\n"
4417+
]
4418+
},
4419+
{
4420+
"cell_type": "code",
4421+
"execution_count": 2,
4422+
"metadata": {},
4423+
"outputs": [],
4424+
"source": [
4425+
"import pandas as pd\n",
4426+
"import numpy as np\n",
4427+
"from sklearn.model_selection import train_test_split\n",
4428+
"from sklearn.datasets import make_moons, make_circles, make_classification\n",
4429+
"n_features = 2\n",
4430+
"n_samples = 500\n",
4431+
"target_column = \"y\"\n",
4432+
"ds = make_moons(n_samples, noise=0.5, random_state=0)\n",
4433+
"X, y = ds\n",
4434+
"X_train, X_test, y_train, y_test = train_test_split(\n",
4435+
" X, y, test_size=0.3, random_state=42\n",
4436+
")\n",
4437+
"train = pd.DataFrame(np.hstack((X_train, y_train.reshape(-1, 1))))\n",
4438+
"test = pd.DataFrame(np.hstack((X_test, y_test.reshape(-1, 1))))\n",
4439+
"train.columns = [f\"x{i}\" for i in range(1, n_features+1)] + [target_column]\n",
4440+
"test.columns = [f\"x{i}\" for i in range(1, n_features+1)] + [target_column]\n",
4441+
"train.head()\n",
4442+
"# combine the training and test data and save to a csv file\n",
4443+
"data = pd.concat([train, test])\n",
4444+
"data.to_csv('moon.csv', index=False)"
4445+
]
4446+
},
44124447
{
44134448
"cell_type": "code",
44144449
"execution_count": null,

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.48"
10+
version = "0.14.50"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/fun/hypersklearn.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from spotPython.hyperparameters.values import (
77
generate_one_config_from_var_dict,
88
)
9-
from spotPython.sklearn.traintest import evaluate_cv, evaluate_model_oob, evaluate_hold_out
9+
from spotPython.sklearn.traintest import evaluate_cv, evaluate_model_oob, evaluate_hold_out, evaluate_model
1010
import logging
1111
from sklearn.metrics import mean_absolute_error
1212

@@ -139,7 +139,9 @@ def fun_sklearn(self, X: np.ndarray, fun_control: dict = None) -> np.ndarray:
139139
model = self.fun_control["core_model"](**config)
140140
try:
141141
eval_type = fun_control["eval"]
142-
if eval_type == "eval_oob_score":
142+
if eval_type == "eval_test":
143+
df_eval, _ = evaluate_model(model, self.fun_control)
144+
elif eval_type == "eval_oob_score":
143145
df_eval, _ = evaluate_model_oob(model, self.fun_control)
144146
elif eval_type == "train_cv":
145147
df_eval, _ = evaluate_cv(model, self.fun_control)

0 commit comments

Comments
 (0)