<commit_before>"""
Boston house prices example of usage for regression problems
A simple example of how to use gestalt
  1. Use custom wrapper for XGB
  2. Create a set of Base Classifiers
  3. Hyperparameter tune Base Classifiers (TODO)
  4. Run a stack ensemble

"""

from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split

########################################################################################################################
# Grab data and save base
data, target = load_boston(return_X_y=True)
train_x, test_x, target_x, target_y = train_test_split(data, target, test_size=0.1, random_state=42)

########################################################################################################################

# Test out Gestalt.
import pandas as pd
from sklearn.model_selection import KFold
from gestalt.stackers.stacking import GeneralisedStacking
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import log_loss

skf = KFold(n_splits=3, random_state=42, shuffle=True)
b_classifiers = [RandomForestRegressor(n_estimators=100, n_jobs=18, random_state=42)]

for stype in ['t', 'cv']:
    b_cancer = GeneralisedStacking(base_estimators=b_classifiers, estimator_type='classification', feval=log_loss,
                                   stack_type=stype, folds_strategy= skf)
    b_cancer.fit(pd.DataFrame(train_x), pd.DataFrame(target_x))<commit_msg>Fixing loss metric for regression<commit_after>"""
Boston house prices example of usage for regression problems
A simple example of how to use gestalt
  1. Use custom wrapper for XGB
  2. Create a set of Base Classifiers
  3. Hyperparameter tune Base Classifiers (TODO)
  4. Run a stack ensemble

"""

from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split

########################################################################################################################
# Grab data and save base
data, target = load_boston(return_X_y=True)
train_x, test_x, target_x, target_y = train_test_split(data, target, test_size=0.1, random_state=42)

########################################################################################################################

# Test out Gestalt.
import pandas as pd
from sklearn.model_selection import KFold
from gestalt.stackers.stacking import GeneralisedStacking
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error as mse

skf = KFold(n_splits=3, random_state=42, shuffle=True)
estimators = [RandomForestRegressor(n_estimators=100, n_jobs=18, random_state=42)]

for stype in ['t', 'cv']:
    b_cancer = GeneralisedStacking(base_estimators=estimators, estimator_type='regression', feval=mse,
                                   stack_type=stype, folds_strategy= skf)
    b_cancer.fit(pd.DataFrame(train_x), pd.DataFrame(target_x))
{'fraction_non_alphanumeric': 0.22865013774104684, 'fraction_numerical': 0.012396694214876033, 'mean_word_length': 6.3544303797468356, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '640168', 'n_tokens_mistral': 857, 'n_tokens_neox': 802, 'n_words': 227}