Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions pycaret/containers/models/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pycaret.internal.distributions import *
import pycaret.containers.base_container
import numpy as np

from packaging import version

class ClassifierContainer(ModelContainer):
"""
Expand Down Expand Up @@ -749,14 +749,22 @@ def __init__(self, globals_dict: dict) -> None:
pycaret.internal.cuml_wrappers.get_random_forest_classifier()
)

args = (
{
if not gpu_imported:
args = {
"random_state": globals_dict["seed"],
"n_jobs": globals_dict["n_jobs_param"],
}
if not gpu_imported
else {"seed": globals_dict["seed"]}
)
else:
import cuml
if version.parse(cuml.__version__) >= version.parse("0.19"):
args = {
"random_state": globals_dict["seed"],
}
else:
args = {
"seed": globals_dict["seed"]
}

tune_args = {}
tune_grid = {
"n_estimators": np_list_arange(10, 300, 10, inclusive=True),
Expand Down Expand Up @@ -1082,10 +1090,9 @@ def __init__(self, globals_dict: dict) -> None:
self.active = False
return

xgboost_version = tuple([int(x) for x in xgboost.__version__.split(".")])
if xgboost_version < (1, 1, 0):
if version.parse(xgboost.__version__) < version.parse("1.1.0"):
logger.warning(
f"Wrong xgboost version. Expected xgboost>=1.1.0, got xgboost=={xgboost_version}"
f"Wrong xgboost version. Expected xgboost>=1.1.0, got xgboost=={xgboost.__version__}"
)
self.active = False
return
Expand Down Expand Up @@ -1318,18 +1325,26 @@ def __init__(self, globals_dict: dict) -> None:
try:
lgb = LGBMClassifier(device="gpu")
lgb.fit(np.zeros((2, 2)), [0, 1])
is_gpu_enabled = True
is_gpu_enabled = "gpu"
del lgb
except LightGBMError:
is_gpu_enabled = False
if globals_dict["gpu_param"] == "force":
raise RuntimeError(
f"LightGBM GPU mode not available. Consult https://lightgbm.readthedocs.io/en/latest/GPU-Tutorial.html."
)

if is_gpu_enabled:
except:
try:
lgb = LGBMClassifier(device="cuda")
lgb.fit(np.zeros((2, 2)), [0, 1])
is_gpu_enabled = "cuda"
del lgb
except LightGBMError:
is_gpu_enabled = False
if globals_dict["gpu_param"] == "force":
raise RuntimeError(
f"LightGBM GPU mode not available. Consult https://lightgbm.readthedocs.io/en/latest/GPU-Tutorial.html."
)

if is_gpu_enabled=="gpu":
args["device"] = "gpu"

elif is_gpu_enabled=="cuda":
args["device"] = "cuda"

super().__init__(
id="lightgbm",
name="Light Gradient Boosting Machine",
Expand All @@ -1354,10 +1369,9 @@ def __init__(self, globals_dict: dict) -> None:
self.active = False
return

catboost_version = tuple([int(x) for x in catboost.__version__.split(".")])
if catboost_version < (0, 23, 2):
if version.parse(catboost.__version__) < version.parse("0.23.2"):
logger.warning(
f"Wrong catboost version. Expected catboost>=0.23.2, got catboost=={catboost_version}"
f"Wrong catboost version. Expected catboost>=0.23.2, got catboost=={catboost.__version__}"
)
self.active = False
return
Expand Down
56 changes: 35 additions & 21 deletions pycaret/containers/models/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pycaret.internal.distributions import *
import pycaret.containers.base_container
import numpy as np

from packaging import version

class RegressorContainer(ModelContainer):
"""
Expand Down Expand Up @@ -1121,14 +1121,22 @@ def __init__(self, globals_dict: dict) -> None:
pycaret.internal.cuml_wrappers.get_random_forest_regressor()
)

args = (
{
if not gpu_imported:
args = {
"random_state": globals_dict["seed"],
"n_jobs": globals_dict["n_jobs_param"],
}
if not gpu_imported
else {"seed": globals_dict["seed"]}
)
else:
import cuml
if version.parse(cuml.__version__) >= version.parse("0.19"):
args = {
"random_state": globals_dict["seed"],
}
else:
args = {
"seed": globals_dict["seed"]
}

tune_args = {}
tune_grid = {
"n_estimators": np_list_arange(10, 300, 10, inclusive=True),
Expand Down Expand Up @@ -1437,10 +1445,9 @@ def __init__(self, globals_dict: dict) -> None:
self.active = False
return

xgboost_version = tuple([int(x) for x in xgboost.__version__.split(".")])
if xgboost_version < (1, 1, 0):
if version.parse(xgboost.__version__) < version.parse("1.1.0"):
logger.warning(
f"Wrong xgboost version. Expected xgboost>=1.1.0, got xgboost=={xgboost_version}"
f"Wrong xgboost version. Expected xgboost>=1.1.0, got xgboost=={xgboost.__version__}"
)
self.active = False
return
Expand Down Expand Up @@ -1673,17 +1680,25 @@ def __init__(self, globals_dict: dict) -> None:
try:
lgb = LGBMRegressor(device="gpu")
lgb.fit(np.zeros((2, 2)), [0, 1])
is_gpu_enabled = True
is_gpu_enabled = "gpu"
del lgb
except LightGBMError:
is_gpu_enabled = False
if globals_dict["gpu_param"] == "force":
raise RuntimeError(
f"LightGBM GPU mode not available. Consult https://lightgbm.readthedocs.io/en/latest/GPU-Tutorial.html."
)

if is_gpu_enabled:
except:
try:
lgb = LGBMRegressor(device="cuda")
lgb.fit(np.zeros((2, 2)), [0, 1])
is_gpu_enabled = "cuda"
del lgb
except LightGBMError:
is_gpu_enabled = False
if globals_dict["gpu_param"] == "force":
raise RuntimeError(
f"LightGBM GPU mode not available. Consult https://lightgbm.readthedocs.io/en/latest/GPU-Tutorial.html."
)

if is_gpu_enabled=="gpu":
args["device"] = "gpu"
elif is_gpu_enabled=="cuda":
args["device"] = "cuda"

super().__init__(
id="lightgbm",
Expand All @@ -1709,10 +1724,9 @@ def __init__(self, globals_dict: dict) -> None:
self.active = False
return

catboost_version = tuple([int(x) for x in catboost.__version__.split(".")])
if catboost_version < (0, 23, 2):
if version.parse(catboost.__version__) < version.parse("0.23.2"):
logger.warning(
f"Wrong catboost version. Expected catboost>=0.23.2, got catboost=={catboost_version}"
f"Wrong catboost version. Expected catboost>=0.23.2, got catboost=={catboost.__version__}"
)
self.active = False
return
Expand Down
8 changes: 3 additions & 5 deletions pycaret/internal/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import plotly.express as px
import plotly.graph_objects as go
import scikitplot as skplt
from packaging import version

warnings.filterwarnings("ignore")

Expand Down Expand Up @@ -1011,16 +1012,13 @@ def highlight_max(s):
if use_gpu:
try:
from cuml import __version__

cuml_version = __version__
logger.info(f"cuml=={cuml_version}")

cuml_version = cuml_version.split(".")
cuml_version = (int(cuml_version[0]), int(cuml_version[1]))
except:
logger.warning(f"cuML not found")

if cuml_version is None or not cuml_version >= (0, 15):
if cuml_version is None or not version.parse(cuml_version) >= version.parse("0.15"):
message = f"cuML is outdated or not found. Required version is >=0.15, got {__version__}"
if use_gpu == "force":
raise ImportError(message)
Expand Down