|
|
@ -28,52 +28,39 @@ class JumpModel(Model): |
|
|
|
'conv_del_max': 55000, |
|
|
|
'conv_del_max': 55000, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_model_type(self) -> (str, bool): |
|
|
|
|
|
|
|
model = 'jump' |
|
|
|
|
|
|
|
type_model = True |
|
|
|
|
|
|
|
return (model, type_model) |
|
|
|
|
|
|
|
|
|
|
|
def find_segment_center(self, dataframe: pd.DataFrame, start: int, end: int) -> int: |
|
|
|
def find_segment_center(self, dataframe: pd.DataFrame, start: int, end: int) -> int: |
|
|
|
data = dataframe['value'] |
|
|
|
data = dataframe['value'] |
|
|
|
segment = data[start: end] |
|
|
|
segment = data[start: end] |
|
|
|
segment_center_index = utils.find_pattern_center(segment, start, 'jump') |
|
|
|
segment_center_index = utils.find_pattern_center(segment, start, 'jump') |
|
|
|
return segment_center_index |
|
|
|
return segment_center_index |
|
|
|
|
|
|
|
|
|
|
|
def do_fit(self, dataframe: pd.DataFrame, labeled_segments: list, deleted_segments: list) -> None: |
|
|
|
def do_fit(self, dataframe: pd.DataFrame, labeled_segments: list, deleted_segments: list, learning_info: dict) -> None: |
|
|
|
data = utils.cut_dataframe(dataframe) |
|
|
|
data = utils.cut_dataframe(dataframe) |
|
|
|
data = data['value'] |
|
|
|
data = data['value'] |
|
|
|
confidences = [] |
|
|
|
window_size = self.state['WINDOW_SIZE'] |
|
|
|
convolve_list = [] |
|
|
|
self.ijumps = learning_info['segment_center_list'] |
|
|
|
correlation_list = [] |
|
|
|
self.model_jump = utils.get_av_model(learning_info['patterns_list']) |
|
|
|
jump_height_list = [] |
|
|
|
convolve_list = utils.get_convolve(self.ijumps, self.model_jump, data, window_size) |
|
|
|
jump_length_list = [] |
|
|
|
correlation_list = utils.get_correlation(self.ijumps, self.model_jump, data, window_size) |
|
|
|
patterns_list = [] |
|
|
|
|
|
|
|
pattern_timestamp = [] |
|
|
|
|
|
|
|
for segment in labeled_segments: |
|
|
|
|
|
|
|
confidence = utils.find_confidence(segment.data)[0] |
|
|
|
|
|
|
|
confidences.append(confidence) |
|
|
|
|
|
|
|
segment_cent_index = segment.center_index |
|
|
|
|
|
|
|
jump_height, jump_length = utils.find_parameters(segment.data, segment.start, 'jump') |
|
|
|
|
|
|
|
jump_height_list.append(jump_height) |
|
|
|
|
|
|
|
jump_length_list.append(jump_length) |
|
|
|
|
|
|
|
self.ijumps.append(segment_cent_index) |
|
|
|
|
|
|
|
pattern_timestamp.append(segment.pattern_timestamp) |
|
|
|
|
|
|
|
labeled_jump = utils.get_interval(data, segment_cent_index, self.state['WINDOW_SIZE']) |
|
|
|
|
|
|
|
labeled_jump = utils.subtract_min_without_nan(labeled_jump) |
|
|
|
|
|
|
|
patterns_list.append(labeled_jump) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.model_jump = utils.get_av_model(patterns_list) |
|
|
|
|
|
|
|
convolve_list = utils.get_convolve(self.ijumps, self.model_jump, data, self.state['WINDOW_SIZE']) |
|
|
|
|
|
|
|
correlation_list = utils.get_correlation(self.ijumps, self.model_jump, data, self.state['WINDOW_SIZE']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
del_conv_list = [] |
|
|
|
del_conv_list = [] |
|
|
|
delete_pattern_timestamp = [] |
|
|
|
delete_pattern_timestamp = [] |
|
|
|
for segment in deleted_segments: |
|
|
|
for segment in deleted_segments: |
|
|
|
segment_cent_index = segment.center_index |
|
|
|
segment_cent_index = segment.center_index |
|
|
|
delete_pattern_timestamp.append(segment.pattern_timestamp) |
|
|
|
delete_pattern_timestamp.append(segment.pattern_timestamp) |
|
|
|
deleted_jump = utils.get_interval(data, segment_cent_index, self.state['WINDOW_SIZE']) |
|
|
|
deleted_jump = utils.get_interval(data, segment_cent_index, window_size) |
|
|
|
deleted_jump = utils.subtract_min_without_nan(deleted_jump) |
|
|
|
deleted_jump = utils.subtract_min_without_nan(deleted_jump) |
|
|
|
del_conv_jump = scipy.signal.fftconvolve(deleted_jump, self.model_jump) |
|
|
|
del_conv_jump = scipy.signal.fftconvolve(deleted_jump, self.model_jump) |
|
|
|
if len(del_conv_jump): del_conv_list.append(max(del_conv_jump)) |
|
|
|
if len(del_conv_jump): del_conv_list.append(max(del_conv_jump)) |
|
|
|
|
|
|
|
|
|
|
|
self._update_fiting_result(self.state, confidences, convolve_list, del_conv_list) |
|
|
|
self._update_fiting_result(self.state, learning_info['confidence'], convolve_list, del_conv_list) |
|
|
|
self.state['JUMP_HEIGHT'] = float(min(jump_height_list, default = 1)) |
|
|
|
self.state['JUMP_HEIGHT'] = float(min(learning_info['pattern_height'], default = 1)) |
|
|
|
self.state['JUMP_LENGTH'] = int(max(jump_length_list, default = 1)) |
|
|
|
self.state['JUMP_LENGTH'] = int(max(learning_info['pattern_width'], default = 1)) |
|
|
|
|
|
|
|
|
|
|
|
def do_detect(self, dataframe: pd.DataFrame) -> list: |
|
|
|
def do_detect(self, dataframe: pd.DataFrame) -> list: |
|
|
|
data = utils.cut_dataframe(dataframe) |
|
|
|
data = utils.cut_dataframe(dataframe) |
|
|
|