<jupyter_start><jupyter_text>Autoregressive Modelling in Sklearn In a lot of cases, traditional time series models work well, but there are many traditional machine learning algorithms that work very well on tabular datasets and it would be waste not to leverage their power for time-series forecast. To enable its use we developed SklearnWrapper  SklearnWrapperAllows you use Sklearn-API regressors as autoregressive models for time-series predictions. In terms of usage, there is one difference between the rest of the wrappers and SklearnWrapper. Since the model is provided by package user and we don't know parameters of the model ahead - usage of factory function get_sklearn_wrapper is needed. You can put any sklearn-compatible regressor to the function and it will return SklearnWrapper class<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('seaborn')
plt.rcParams['figure.figsize'] = [12, 6]
from hcrystalball.utils import get_sales_data

df = get_sales_data(n_dates=365*2, 
                    n_assortments=1, 
                    n_states=1, 
                    n_stores=1)
X, y = pd.DataFrame(index=df.index), df['Sales']
from hcrystalball.wrappers import get_sklearn_wrapper<jupyter_output><empty_output><jupyter_text>Sklearn's or sklearn's compatible regressorYou can provide any parameter for original regressor model. It doesn't need to be just Sklearn model, only Sklearn API is required. You define as first positional argument the wrapping class and than you can mix wrappers parameters (`clip_predictions_lower`) with wrapped class parameters(`n_estimators`)<jupyter_code>from sklearn.ensemble import RandomForestRegressor
model = get_sklearn_wrapper(RandomForestRegressor, n_estimators=100, clip_predictions_lower=0., random_state=42)
preds = (model.fit(X[:-10], y[:-10])
         .predict(X[-10:])
         .merge(y, left_index=True, right_index=True, how='outer')
         .tail(50)    
)
preds.plot(title=f"MAE:{(preds['Sales']-preds['sklearn']).abs().mean()}");<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07853658536585366, 'fraction_numerical': 0.011707317073170732, 'mean_word_length': 4.962209302325581, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '401795', 'license': 'MIT', 'n_tokens_mistral': 623, 'n_tokens_neox': 584, 'n_words': 208, 'path': 'docs/examples/tutorial/wrappers/02_ar_modelling_in_sklearn.ipynb', 'repo_name': 'pavelg087/hcrystalball', 'size': '2050'}