in orbit/template/ktr.py [0:0]
def _set_valid_response_attributes(self, training_meta):
num_of_observations = training_meta[TrainingMetaKeys.NUM_OF_OBS.value]
response = training_meta[TrainingMetaKeys.RESPONSE.value]
if self._seasonality:
max_seasonality = np.round(np.max(self._seasonality)).astype(int)
if num_of_observations < max_seasonality:
raise ModelException(
"Number of observations {} is less than max seasonality {}".format(
num_of_observations, max_seasonality
)
)
# get some reasonable offset to regularize response to make default priors scale-insensitive
if self._seasonality:
max_seasonality = np.round(np.max(self._seasonality)).astype(int)
self.response_offset = np.nanmean(response[:max_seasonality])
else:
self.response_offset = np.nanmean(response)
self.is_valid_response = ~np.isnan(response)
# [0] to convert tuple back to array
self.which_valid_response = np.where(self.is_valid_response)[0]
self.num_of_valid_response = len(self.which_valid_response)