Optimize Objective Functions

minimize_objective[source]

minimize_objective(objective:Callable, param_names:List[str], param_ranges:List[Tuple[float, float]], ts:array, score_f:Callable=__mean_absolute_error)

minimize_simple_smoothing[source]

minimize_simple_smoothing(ts:array, score_f=__mean_absolute_error)

ts_df = simulate_data.pandas_time_series()
alpha = minimize_simple_smoothing(ts=ts_df.time_series.to_numpy(),)
_, fig = smoothing.SINGLE(
    alpha,
    df=ts_df,
    ts_col='time_series',
)
x*=0.66 f(x*)=0.69

minimize_double_smoothing[source]

minimize_double_smoothing(ts:array, score_f=__mean_absolute_error)

ts_df = simulate_data.pandas_time_series()
res = minimize_double_smoothing(ts=ts_df.time_series.to_numpy(),)
res
x*=0.37, y*=1.00, f(x*,y*)=0.68
[0.3671860438647993, 1.0]
_, fig = smoothing.DOUBLE(
    res,
    df=ts_df,
    ts_col='time_series',
)
fig.show()
datafile = '../data/superstore_sales.csv'
url = "https://raw.githubusercontent.com/" + \
      "BigDataGal/Python-for-Data-Science/master/Superstore-Sales.csv"

if not path.isfile(datafile):
    with open(datafile, 'w') as file:
        r = requests.get(url)
        file.write(r.text)

df = pd.read_csv(
    datafile,
    index_col='Order Date',
    dtype={
        'Row ID': str,
        'Order ID': str,
    },
    parse_dates=['Order Date', 'Ship Date'],
)

df.columns = ['_'.join(x.lower().split(' ')) for x in df.columns]
dff = df.head(int(0.4 * len(df)))

minimize_simple_smoothing(dff.sales.to_numpy())
/opt/conda/lib/python3.8/site-packages/skopt/optimizer/optimizer.py:449: UserWarning:

The objective has been evaluated at this point before.

/opt/conda/lib/python3.8/site-packages/skopt/optimizer/optimizer.py:449: UserWarning:

The objective has been evaluated at this point before.

/opt/conda/lib/python3.8/site-packages/skopt/optimizer/optimizer.py:449: UserWarning:

The objective has been evaluated at this point before.

/opt/conda/lib/python3.8/site-packages/skopt/optimizer/optimizer.py:449: UserWarning:

The objective has been evaluated at this point before.

/opt/conda/lib/python3.8/site-packages/skopt/optimizer/optimizer.py:449: UserWarning:

The objective has been evaluated at this point before.

/opt/conda/lib/python3.8/site-packages/skopt/optimizer/optimizer.py:449: UserWarning:

The objective has been evaluated at this point before.

/opt/conda/lib/python3.8/site-packages/skopt/optimizer/optimizer.py:449: UserWarning:

The objective has been evaluated at this point before.

/opt/conda/lib/python3.8/site-packages/skopt/optimizer/optimizer.py:449: UserWarning:

The objective has been evaluated at this point before.

/opt/conda/lib/python3.8/site-packages/skopt/optimizer/optimizer.py:449: UserWarning:

The objective has been evaluated at this point before.

x*=0.00 f(x*)=1562.20
0.0
_, fig = smoothing.SINGLE(1., df=dff.copy(), ts_col='sales')
fig.show()
del sma(**args):
    
    ar
    
    
    
    
  File "<ipython-input-57-5e41ba70a8bc>", line 1
    del sma(**args):
                   ^
SyntaxError: invalid syntax