%! Author = alex
%! Date = 3/6/25

\section{Methodology}\label{sec:methodology}

% why did I select tft over other methods -> include examples of time series and why I belief a complex model could help
% you did I apply it
% implementation details


\subsection{Data Collection \& Preprocessing}\label{subsec:data_collection_preprocessing}
\subsubsection{Data Collection}\label{subsubsec:data_collection}
The dataset used in this work was collected by \textit{VivoSensMedical GmbH}, a medical technology company based in Leipzig, Germany,
specializing in fertility tracking devices and applications.
Each entry in the dataset is derived from temperature measurements recorded by the \textit{OvulaRing} wearable
device\cite{alexander_fertilitatsmonitoring_2014}, which continuously measures core body temperature every 5 minutes.
The sensor is worn intra-vaginally and is designed for extended use, requiring removal only for data synchronization.
This enables high-resolution, long-term temperature tracking, providing a detailed view of menstrual cycle patterns.

% add a few example cycles
% TODO: stats about dataset
The dataset used for training and evaluation consists of 45000 cycles,

In addition to raw temperature values, the dataset includes user-specific metadata, such as health status, weight, and age.
Users can also manually input time-dependent markers, indicating events such as menstruation, ovulation, and intercourse,
which serve as contextual features for the model.
While these additional data points can enhance predictive accuracy, it is important to note that they are self-reported
and may be subject to errors or biases.

\subsubsection{Data Preprocessing}\label{subsubsec:data_preprocessing}
Not all cycles in the dataset can be used for training.
Cycles that are too short are excluded, as they usually do not contain enough information to make reliable predictions.
Additionally, cycles that are too long are also excluded, as they might contain multiple ovulation events or
pregnancies, which would make the prediction task ambiguous.
\subsubsection{Feature Engineering}\label{subsubsec:feature_engineering}

%TODO: show that a model without marker context and one with them is trained, to show the impact of the markers

%TODO: show that for initial testing and fine tuning the dataset was reduced to 10% of size to speed up early impressions of performance
%TODO: show that initial feature set with only temperature as observable and only pregnancy "chance" as target
% did not show promise on small 10% dataset, so the features got extended
% show the modifications that were made to account for multi target prediction
% show, the mothod of circumventing the non-padding-implementation by using a dedicated feature
% show, that a different loss / temporal loss wheighting or position aware loss could help
% show, the problem of the model using its past targets, even though they are not observable and how I dealt with this -> explain and use exogenous
% introduce change of quantiles to single variable output and why, quantiles loss other than .5 was almost always just 0 or 1, so no significant predicitve quality in this, and this only makes predictions harder for model
% explain why class imablances are there, and what I did to counteract this, also explain, why special weighting is useful for something like the pregnancy risk prediction
% show the work that needed to be done for inference -> padding values for future observables


Notes for training:
 - one head 512 hidden size make very "smoothed" out curves, which result in ver conservative predictions

Intermediate training results:
- first full training:
 - first feature config with ov over and fertility did not show much promise, as it detected the ov too late, essentially when it was already over
 - either there is no patterns detectable in advance, or there are not enough features yet
 - soft of "soft ceiling" at 0.3 loss, many models get there quickly and then "bounce" around

\subsection{Time-Series Modeling Approach}\label{subsec:time-series_modeling_approach}
\subsubsection{Limitations of Traditional Time-Series Models}\label{subsubsec:limitations_of_traditional_time-series_models}
\subsubsection{Temporal Fusion Transformer}\label{subsubsec:temporal_fusion_transformer}
\subsubsection{Input \& Output Modeling}\label{subsubsec:input_output_modeling}

% build in the probability curve for the pregnancy chance

\subsection{Model Training}\label{subsec:model_training}
\subsubsection{Training Setup}\label{subsubsec:training_setup}
\subsubsection{Hyperparameter Tuning}\label{subsubsec:hyperparameter_tuning}
\subsubsection{Training Details}\label{subsubsec:training_details}

\subsection{Evaluation}\label{subsec:evaluation}
\subsubsection{Evaluation Metrics}\label{subsubsec:evaluation_metrics}
\subsubsection{Baseline Comparisons}\label{subsubsec:baseline_comparisons}
\subsubsection{Explainability \& Interpretability}\label{subsubsec:explainability_interpretability}
