<jupyter_start><jupyter_text>3. Baseline modelIn this notebook we define the Baseline model.It predicts the wind farm dependent average electricity production and aggregates predictions over all wind farms. The windfarms will be called zones.<jupyter_code>import sys
import pandas as pd
import numpy as np
from sklearn.metrics import mean_squared_error
sys.path.append("..")
# loading the dataset
data = pd.read_csv('../data/GEFCom2014Data/Wind/clean_data.csv', 
                    parse_dates= ['TIMESTAMP'],
                    index_col= 'TIMESTAMP' )<jupyter_output><empty_output><jupyter_text>Defining train and test set. The dataset consists of weather data from 01.01.2012 till 31.12.2013. The dataset is split at the date 01.07.2013, so the train set is the first 75% of the dataset, and the test set is the last 25% of the dataset.<jupyter_code>train = data[:'2013-07-01 00:00:00']
test = data['2013-07-01 01:00:00':]

test.head()<jupyter_output><empty_output><jupyter_text>RMSE of the baseline model, in every windfarm, and aggregated over all windfarms:<jupyter_code># zones(windfarms) 
zones = np.sort(train.ZONEID.unique()) 

# baseline predictions of all zones will be merged into one DataFrame to calculate the RMSE with respect to the observations of 
# all zones
df_results = pd.DataFrame(index = [zone for zone in zones] + ['TOTAL'],  columns = ['TESTSCORE','TRAINSCORE'])
df_results.loc['TOTAL'].TRAINSCORE = 0
df_results.loc['TOTAL'].TESTSCORE = 0

# loop over all zones
for zone in zones:

    # get train and test data of individual zones
    ytrain = train[train.ZONEID == zone].TARGETVAR
    ytest =  test[test.ZONEID == zone].TARGETVAR

    # baseline predictions for individual zone
    pred_train = np.ones(len(ytrain)) * np.mean(ytrain)
    pred_test = np.ones(len(ytest)) * np.mean(ytrain)
    
    df_results.loc[zone].TRAINSCORE = mean_squared_error(ytrain, pred_train, squared=False)
    df_results.loc[zone].TESTSCORE = mean_squared_error(ytest, pred_test, squared=False)

    df_results.loc['TOTAL'].TRAINSCORE += np.power(df_results.loc[zone].TRAINSCORE,2) * len(ytrain)/len(train)
    df_results.loc['TOTAL'].TESTSCORE += np.power(df_results.loc[zone].TESTSCORE,2) * len(ytest)/len(test)

df_results.loc['TOTAL'].TRAINSCORE = np.power(df_results.loc['TOTAL'].TRAINSCORE,.5)
df_results.loc['TOTAL'].TESTSCORE = np.power(df_results.loc['TOTAL'].TESTSCORE,.5)

df_results.index.set_names(['ZONE'], inplace=True)
df_results.to_csv(f'../results/Baseline_test.csv')

df_results<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12135539795114263, 'fraction_numerical': 0.02639873916469661, 'mean_word_length': 4.946135831381733, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '420237', 'license': 'MIT', 'n_tokens_mistral': 913, 'n_tokens_neox': 840, 'n_words': 212, 'path': 'notebooks/3_Baseline.ipynb', 'repo_name': 'christine-berlin/Capstone_WindPowerPredicting', 'size': '2538'}