<jupyter_start><jupyter_text>how to use the hyperparam_opt to optimize hyperparameters for a single location.This notebook will find the optimal hyperparameters for the SARIMA model from a solar insolance json data file. Import the necessary packages<jupyter_code>import geopandas as gp
import pandas as pd

import optuna
from statsmodels.tsa.statespace.sarimax import SARIMAX
import numpy as np
import sklearn
from sklearn.model_selection import TimeSeriesSplit
from sklearn.metrics import r2_score

from hyperparam_opt import *<jupyter_output><empty_output><jupyter_text>Input the filepath of the location data.<jupyter_code>#pick the location of the geojson
filename = 'NASA/POWER_Point_Monthly_Timeseries_1981_2020_046d1514N_122d8191W_LST.json'
# this section is to prepare the data
df = loadjson(filename)
df = rm13(df)
df = Prophet_preproc(df)
# extract the train, validation, and test data using time series splits
X_dict, y_dict = TSS(df)
# extract just the tain and validation data
y_train = y_dict['y_train']
y_val = y_dict['y_val']<jupyter_output><empty_output><jupyter_text>Find the optimal hyperparaters.<jupyter_code>#Use this code to optimize the hyperparameters


argfunction = lambda trial: objective(trial,y_train,y_val)
study = optuna.create_study(sampler=optuna.samplers.TPESampler(), direction='maximize')
study.optimize(argfunction, n_trials=50)
        #,y_train=y_train,y_val=y_val)

results = study.trials_dataframe()
results<jupyter_output><empty_output><jupyter_text>Save the results to a file location of your choosing.<jupyter_code>#load the results into a csv in the location of your choosing
results.to_csv('hyperparameters/SARIMAX_hyperparameter_results_kelso.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07064273306311523, 'fraction_numerical': 0.01563404748118124, 'mean_word_length': 7.470588235294118, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '571794', 'license': 'MIT', 'n_tokens_mistral': 589, 'n_tokens_neox': 554, 'n_words': 158, 'path': 'serf/working/hyperparam_opt_guide.ipynb', 'repo_name': 'Solar-Wind-ML-DIRECT-2022-Project/2022-Project-Repo', 'size': '1727'}