|
|
@ -28,7 +28,7 @@ class JumpModel(Model): |
|
|
|
'conv_del_max': 55000, |
|
|
|
'conv_del_max': 55000, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def do_fit(self, dataframe: pd.DataFrame, segments: list) -> None: |
|
|
|
def do_fit(self, dataframe: pd.DataFrame, labeled_segments: list, deleted_segments: list) -> None: |
|
|
|
data = utils.cut_dataframe(dataframe) |
|
|
|
data = utils.cut_dataframe(dataframe) |
|
|
|
data = data['value'] |
|
|
|
data = data['value'] |
|
|
|
confidences = [] |
|
|
|
confidences = [] |
|
|
@ -36,70 +36,31 @@ class JumpModel(Model): |
|
|
|
jump_height_list = [] |
|
|
|
jump_height_list = [] |
|
|
|
jump_length_list = [] |
|
|
|
jump_length_list = [] |
|
|
|
patterns_list = [] |
|
|
|
patterns_list = [] |
|
|
|
for segment in segments: |
|
|
|
for segment in labeled_segments: |
|
|
|
if segment['labeled']: |
|
|
|
confidence = utils.find_confidence(segment.data) |
|
|
|
segment_from_index = segment.get('from') |
|
|
|
confidences.append(confidence) |
|
|
|
segment_to_index = segment.get('to') |
|
|
|
segment_cent_index, jump_height, jump_length = utils.find_parameters(segment.data, segment.start, 'jump') |
|
|
|
segment_data = segment.get('data') |
|
|
|
jump_height_list.append(jump_height) |
|
|
|
confidence = utils.find_confidence(segment_data) |
|
|
|
jump_length_list.append(jump_length) |
|
|
|
confidences.append(confidence) |
|
|
|
self.ijumps.append(segment_cent_index) |
|
|
|
segment_cent_index, jump_height, jump_length = utils.find_parameters(segment_data, segment_from_index, 'jump') |
|
|
|
labeled_jump = utils.get_interval(data, segment_cent_index, self.state['WINDOW_SIZE']) |
|
|
|
jump_height_list.append(jump_height) |
|
|
|
labeled_jump = utils.subtract_min_without_nan(labeled_jump) |
|
|
|
jump_length_list.append(jump_length) |
|
|
|
patterns_list.append(labeled_jump) |
|
|
|
self.ijumps.append(segment_cent_index) |
|
|
|
|
|
|
|
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) |
|
|
|
self.model_jump = utils.get_av_model(patterns_list) |
|
|
|
convolve_list = utils.get_convolve(self.ijumps, self.model_jump, data, self.state['WINDOW_SIZE']) |
|
|
|
convolve_list = utils.get_convolve(self.ijumps, self.model_jump, data, self.state['WINDOW_SIZE']) |
|
|
|
|
|
|
|
|
|
|
|
del_conv_list = [] |
|
|
|
del_conv_list = [] |
|
|
|
for segment in segments: |
|
|
|
for segment in deleted_segments: |
|
|
|
if segment['deleted']: |
|
|
|
segment_cent_index = utils.find_parameters(segment.data, segment.start, 'jump')[0] |
|
|
|
segment_from_index = segment.get('from') |
|
|
|
deleted_jump = utils.get_interval(data, segment_cent_index, self.state['WINDOW_SIZE']) |
|
|
|
segment_to_index = segment.get('to') |
|
|
|
deleted_jump = utils.subtract_min_without_nan(deleted_jump) |
|
|
|
segment_data = segment.get('data') |
|
|
|
del_conv_jump = scipy.signal.fftconvolve(deleted_jump, self.model_jump) |
|
|
|
segment_cent_index = utils.find_parameters(segment_data, segment_from_index, 'jump')[0] |
|
|
|
if len(del_conv_jump): del_conv_list.append(max(del_conv_jump)) |
|
|
|
deleted_jump = utils.get_interval(data, segment_cent_index, self.state['WINDOW_SIZE']) |
|
|
|
|
|
|
|
deleted_jump = utils.subtract_min_without_nan(labeled_jump) |
|
|
|
self._update_fiting_result(self.state, confidences, convolve_list, del_conv_list) |
|
|
|
del_conv_jump = scipy.signal.fftconvolve(deleted_jump, self.model_jump) |
|
|
|
self.state['JUMP_HEIGHT'] = float(min(jump_height_list, default = 1)) |
|
|
|
del_conv_list.append(max(del_conv_jump)) |
|
|
|
self.state['JUMP_LENGTH'] = int(max(jump_length_list, default = 1)) |
|
|
|
|
|
|
|
|
|
|
|
if len(confidences) > 0: |
|
|
|
|
|
|
|
self.state['confidence'] = float(min(confidences)) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.state['confidence'] = 1.5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(convolve_list) > 0: |
|
|
|
|
|
|
|
self.state['convolve_max'] = float(max(convolve_list)) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.state['convolve_max'] = self.state['WINDOW_SIZE'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(convolve_list) > 0: |
|
|
|
|
|
|
|
self.state['convolve_min'] = float(min(convolve_list)) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.state['convolve_min'] = self.state['WINDOW_SIZE'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(jump_height_list) > 0: |
|
|
|
|
|
|
|
self.state['JUMP_HEIGHT'] = float(min(jump_height_list)) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.state['JUMP_HEIGHT'] = 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(jump_length_list) > 0: |
|
|
|
|
|
|
|
self.state['JUMP_LENGTH'] = int(max(jump_length_list)) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.state['JUMP_LENGTH'] = 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(del_conv_list) > 0: |
|
|
|
|
|
|
|
self.state['conv_del_min'] = float(min(del_conv_list)) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.state['conv_del_min'] = self.state['WINDOW_SIZE'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(del_conv_list) > 0: |
|
|
|
|
|
|
|
self.state['conv_del_max'] = float(max(del_conv_list)) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.state['conv_del_max'] = self.state['WINDOW_SIZE'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|