<jupyter_start><jupyter_text>Split training set from 2010 to 2011 and test set from 2012 to 2013<jupyter_code>training_set_df = training_df[:'2012-01-01']
training_set_df.head()
training_set_df.tail()
test_set_df = training_df['2012-01-01':]
test_set_df.head()
test_set_df.tail()
X_training = training_set_df.drop(columns=['Weekly_Sales', 'Year', 'DayOfYear']).values
y_training = training_set_df['Weekly_Sales'].values
X_prediction = test_set_df.drop(columns=['Weekly_Sales', 'Year', 'DayOfYear']).values
y_prediction = test_set_df['Weekly_Sales'].values
X_training.shape, y_training.shape, X_prediction.shape, y_prediction.shape
from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X_training, y_training, test_size=0.33, random_state=0)
X_train.shape, y_train.shape, X_test.shape, y_test.shape
from sklearn.tree import DecisionTreeRegressor
from sklearn.model_selection import cross_val_score

dtr_regressor = DecisionTreeRegressor(max_depth=50, min_samples_leaf=200, random_state=0)
# cv_scores = cross_val_score(dtr_regressor, X_train, y_train, cv=10)
# max(cv_scores), min(cv_scores)
dtr_regressor = dtr_regressor.fit(X_train, y_train)
dtr_regressor.score(X_test, y_test)
future_pred = dtr_regressor.predict(X_prediction)
dtr_regressor.score(X_prediction, y_prediction)
from sklearn.ensemble import RandomForestRegressor

rfr_regressor = RandomForestRegressor(n_estimators=20, max_depth=100, min_samples_leaf=150, random_state=0)
rfr_regressor = rfr_regressor.fit(X_train, y_train)
rfr_regressor.score(X_test, y_test)
future_pred = rfr_regressor.predict(X_prediction)
rfr_regressor.score(X_prediction, y_prediction)
from sklearn.ensemble import GradientBoostingRegressor

gbr_regressor = GradientBoostingRegressor(n_estimators=20, max_depth=150, min_samples_leaf=150, random_state=0)
gbr_regressor = gbr_regressor.fit(X_train, y_train)
gbr_regressor.score(X_test, y_test)
future_pred = gbr_regressor.predict(X_prediction)
gbr_regressor.score(X_prediction, y_prediction)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1000971817298348, 'fraction_numerical': 0.03012633624878523, 'mean_word_length': 10.438888888888888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '561406', 'license': 'MIT', 'n_tokens_mistral': 853, 'n_tokens_neox': 776, 'n_words': 117, 'path': '.ipynb_checkpoints/retail_modeling-checkpoint.ipynb', 'repo_name': 'rafaelgarcia094/Retail_Dataset', 'size': '2058'}