<jupyter_start><jupyter_text>Load an experimental data<jupyter_code># Load an example dataset
from sklearn.datasets import load_diabetes

dataset = load_diabetes()
X = dataset.data
y = dataset.target<jupyter_output><empty_output><jupyter_text>Cross-validate an example regressor<jupyter_code>from helpers.regression.validation import cross_validate_regressor
from sklearn.linear_model import LinearRegression

# Initialize the regressor
regressor = LinearRegression()

# Define the regression options
metrics = ("mae", "eer", "r2_adj")
num_folds = 10
num_repetitions = 20

# Cross-validate the classifier
results = cross_validate_regressor(X, 
                                   y, 
                                   regressor, 
                                   metrics=metrics, 
                                   num_folds=num_folds, 
                                   num_repetitions=num_repetitions, 
                                   seed=seed)

print("-------------------------")
print("Cross-validation results:")
print("-------------------------")
print("")

for metric in metrics:
    metric_avg = float(np.mean(results[metric]))
    metric_std = float(np.std(results[metric]))
    print("{} = {:.2f} +- {:.2f}".format(metric, metric_avg, metric_std))<jupyter_output>-------------------------
Cross-validation results:
-------------------------

mae = 44.48 +- 3.56
eer = 0.17 +- 0.02
r2_adj = 0.30 +- 0.15
{'fraction_non_alphanumeric': 0.16619718309859155, 'fraction_numerical': 0.019014084507042252, 'mean_word_length': 2.0428265524625266, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '119988', 'license': 'MIT', 'n_tokens_mistral': 445, 'n_tokens_neox': 399, 'n_words': 85, 'path': 'notebooks/regression_notebook.ipynb', 'repo_name': 'BDALab/datascience_helpers', 'size': '1420'}