prepare fix for joblib support in C# environment, related to #23
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import multiprocessing
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# os.environ["JOBLIB_DISABLE_SHARED_MEMORY"] = "1"
|
||||
|
||||
interpreter = r"A:\Arbeitsaufgaben\Delta-Barth\cs-wrapper\dopt.DeltaBarth\python\python.exe"
|
||||
intp_pth = Path(interpreter).resolve()
|
||||
|
||||
assert intp_pth.exists(), f"interpreter path seems not to exist: {intp_pth}"
|
||||
|
||||
# multiprocessing.set_executable(str(intp_pth))
|
||||
# setattr(sys, "frozen", True) # !! causes termination
|
||||
# sys.executable = str(intp_pth)
|
||||
setattr(sys, "executable", str(intp_pth))
|
||||
setattr(sys, "_base_executable", str(intp_pth))
|
||||
# multiprocessing.set_start_method("spawn", force=True)
|
||||
|
||||
|
||||
target = Path(r"A:\Arbeitsaufgaben\Delta-Barth\cs-wrapper\dopt.DeltaBarth")
|
||||
file = target / "executed.txt"
|
||||
file.touch()
|
||||
|
||||
@@ -8,6 +8,11 @@ from dataclasses import asdict
|
||||
from datetime import datetime as Datetime
|
||||
from typing import TYPE_CHECKING, Final, TypeAlias, cast
|
||||
|
||||
import joblib
|
||||
import joblib.externals
|
||||
import joblib.externals.loky
|
||||
import joblib.externals.loky.backend
|
||||
import joblib.externals.loky.backend.popen_loky_win32
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import scipy.stats
|
||||
@@ -291,18 +296,22 @@ def _process_sales(
|
||||
if len(train[train[SALES_FEAT] > 0]) >= (base_num_data_points_months + 10 * add_year):
|
||||
too_few_month_points = False
|
||||
|
||||
rand = RandomizedSearchCV(
|
||||
XGBRegressor(),
|
||||
params,
|
||||
scoring="neg_mean_absolute_error",
|
||||
cv=kfold,
|
||||
n_jobs=-1,
|
||||
n_iter=100,
|
||||
verbose=0,
|
||||
)
|
||||
rand.fit(
|
||||
X_train, y_train, eval_set=[(X_train, y_train), (X_test, y_test)], verbose=0
|
||||
)
|
||||
with joblib.parallel_config(backend="loky"):
|
||||
rand = RandomizedSearchCV(
|
||||
XGBRegressor(),
|
||||
params,
|
||||
scoring="neg_mean_absolute_error",
|
||||
cv=kfold,
|
||||
n_jobs=-1,
|
||||
n_iter=100,
|
||||
verbose=0,
|
||||
)
|
||||
rand.fit(
|
||||
X_train,
|
||||
y_train,
|
||||
eval_set=[(X_train, y_train), (X_test, y_test)],
|
||||
verbose=0,
|
||||
)
|
||||
y_pred = rand.best_estimator_.predict(X_test) # type: ignore
|
||||
|
||||
if len(np.unique(y_pred)) != 1:
|
||||
|
||||
Reference in New Issue
Block a user