Skip to content

Commit

Permalink
Merge branch 'master' into update_versions_from_sktime
Browse files Browse the repository at this point in the history
  • Loading branch information
Yard1 authored Oct 10, 2022
2 parents 280513a + 021cafc commit 0f79eb8
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 26 deletions.
28 changes: 14 additions & 14 deletions pycaret/containers/models/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def __init__(self, experiment) -> None:
`sp` is hard coded to 1 irrespective of the `sp` value or whether
seasonality is detected or not.
"""
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -345,7 +345,7 @@ def __init__(self, experiment) -> None:
`sp` is hard coded to 1 irrespective of the `sp` value or whether
seasonality is detected or not.
"""
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -406,7 +406,7 @@ def __init__(self, experiment) -> None:
If sp = 1, this model is disabled.
If sp != 1, model is enabled even when seasonality is not detected.
"""
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -466,7 +466,7 @@ class PolyTrendContainer(TimeSeriesContainer):
model_type = TSModelTypes.BASELINE

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -518,7 +518,7 @@ class ArimaContainer(TimeSeriesContainer):
model_type = TSModelTypes.CLASSICAL

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
random.seed(experiment.seed)
np.random.seed(experiment.seed)
self.gpu_imported = False
Expand Down Expand Up @@ -759,7 +759,7 @@ class ExponentialSmoothingContainer(TimeSeriesContainer):
model_type = TSModelTypes.CLASSICAL

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -892,7 +892,7 @@ class CrostonContainer(TimeSeriesContainer):
model_type = TSModelTypes.CLASSICAL

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -937,7 +937,7 @@ class ETSContainer(TimeSeriesContainer):
model_type = TSModelTypes.CLASSICAL

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -1013,7 +1013,7 @@ class ThetaContainer(TimeSeriesContainer):
model_type = TSModelTypes.CLASSICAL

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -1100,7 +1100,7 @@ class TBATSContainer(TimeSeriesContainer):
model_type = TSModelTypes.CLASSICAL

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -1163,7 +1163,7 @@ class BATSContainer(TimeSeriesContainer):
model_type = TSModelTypes.CLASSICAL

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -1225,7 +1225,7 @@ class ProphetContainer(TimeSeriesContainer):
model_type = TSModelTypes.LINEAR

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down Expand Up @@ -1313,7 +1313,7 @@ class CdsDtContainer(TimeSeriesContainer):
model_type = None

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
self.seed = experiment.seed
np.random.seed(self.seed)

Expand Down Expand Up @@ -2749,7 +2749,7 @@ class EnsembleTimeSeriesContainer(TimeSeriesContainer):
model_type = "ensemble"

def __init__(self, experiment) -> None:
get_logger()
self.logger = get_logger()
np.random.seed(experiment.seed)
self.gpu_imported = False

Expand Down
40 changes: 33 additions & 7 deletions pycaret/internal/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,20 @@ def get_skopt(self):
def get_optuna(self):
import optuna

optuna_version = int(optuna.__version__[0])

if self.log:
return optuna.distributions.LogUniformDistribution(self.lower, self.upper)
return (
optuna.distributions.FloatDistribution(self.lower, self.upper, log=True)
if optuna_version >= 3
else optuna.distributions.LogUniformDistribution(self.lower, self.upper)
)
else:
return optuna.distributions.UniformDistribution(self.lower, self.upper)
return (
optuna.distributions.FloatDistribution(self.lower, self.upper)
if optuna_version >= 3
else optuna.distributions.UniformDistribution(self.lower, self.upper)
)

def get_hyperopt(self, label):
from hyperopt import hp
Expand Down Expand Up @@ -145,12 +155,22 @@ def get_skopt(self):
def get_optuna(self):
import optuna

optuna_version = int(optuna.__version__[0])

if self.log:
return optuna.distributions.IntLogUniformDistribution(
self.lower, self.upper
return (
optuna.distributions.IntDistribution(self.lower, self.upper, log=True)
if optuna_version >= 3
else optuna.distributions.IntLogUniformDistribution(
self.lower, self.upper
)
)
else:
return optuna.distributions.IntUniformDistribution(self.lower, self.upper)
return (
optuna.distributions.IntDistribution(self.lower, self.upper)
if optuna_version >= 3
else optuna.distributions.IntUniformDistribution(self.lower, self.upper)
)

def get_hyperopt(self, label):
from hyperopt import hp
Expand Down Expand Up @@ -256,8 +276,14 @@ def get_skopt(self):
def get_optuna(self):
import optuna

return optuna.distributions.DiscreteUniformDistribution(
self.lower, self.upper, self.q
optuna_version = int(optuna.__version__[0])

return (
optuna.distributions.FloatDistribution(self.lower, self.upper, step=self.q)
if optuna_version >= 3
else optuna.distributions.DiscreteUniformDistribution(
self.lower, self.upper, self.q
)
)

def get_hyperopt(self, label):
Expand Down
8 changes: 4 additions & 4 deletions pycaret/internal/plots/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ def plot_predictions_with_confidence(
if isinstance(upper_interval.index, pd.PeriodIndex)
else upper_interval.index
)
upper_bound = go.Scattergl(
upper_bound = go.Scatter(
name=f"Prediction Interval | {model_label}", # Changed since we use only 1 legend
x=x,
y=upper_interval,
Expand All @@ -784,7 +784,7 @@ def plot_predictions_with_confidence(
if isinstance(preds.index, pd.PeriodIndex)
else preds.index
)
mean = go.Scattergl(
mean = go.Scatter(
name=f"Forecast | {model_label}",
x=x,
y=preds,
Expand All @@ -799,7 +799,7 @@ def plot_predictions_with_confidence(
if isinstance(data.index, pd.PeriodIndex)
else data.index
)
original = go.Scattergl(
original = go.Scatter(
name="Original",
x=x,
y=data,
Expand All @@ -813,7 +813,7 @@ def plot_predictions_with_confidence(
if isinstance(lower_interval.index, pd.PeriodIndex)
else lower_interval.index
)
lower_bound = go.Scattergl(
lower_bound = go.Scatter(
name="Lower Interval",
x=x,
y=lower_interval,
Expand Down
2 changes: 1 addition & 1 deletion requirements-optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tune-sklearn>=0.2.1; python_version < '3.10' or platform_system != 'Windows'
protobuf<4.0.0; python_version < '3.10' or platform_system != 'Windows' # broken in Ray <1.13
ray[tune]>=1.0.0; python_version < '3.10' or platform_system != 'Windows'
hyperopt>=0.2.7
optuna>=2.2.0
optuna>=3.0.0
scikit-optimize>=0.9.0

# MLOps
Expand Down

0 comments on commit 0f79eb8

Please sign in to comment.