def test_data_identifiers(self): pp = pre_processor.PreProcessor(whitelist=['Brazil'], data_identifiers=['new_cases']) data = pp.pre_process() len_data = len(data['Brazil']) assert len_data == 1 pp = pre_processor.PreProcessor(whitelist=['Brazil']) data = pp.pre_process(['new_cases']) len_data = len(data['Brazil']) assert len_data == 1
def __init__(self, dataset=None, identifier=None): self.defaults() if dataset == None: pp = pre_processor.PreProcessor(self.file) self.dataset = pp.pre_process() else: self.dataset = dataset
eventFileReady = threading.Event() event_ticker_timeout = threading.Event() # Create a Ticker instance tick_obj = ticker.Ticker(tick_event=eventGoGetData, dt=dt, timeout=timeOut, tick_timeout_event=event_ticker_timeout) # Creates an AcquisitionSystem instance ASys = acquisition.AcquisitionSystem(sampling_funcs=samplingFunctions, maxRowsPerFile=maxCacheSize, channel_names=ch_names) # Creates a PreProcessor instance PrePross = pre_processor.PreProcessor(pre_process_func, channel_names=ch_names) # Create a Watchdog instance Watchdog = watchdog.Watchdog(ASys, PrePross, tick_obj, event_ticker_timeout) # Define threads ticker_thread = threading.Thread(name='Ticker', target=tick_obj.run) Acq_thread = threading.Thread(name='Acquisition', target=ASys.run, args=(eventGoGetData, eventFileReady, event_ticker_timeout), kwargs={'verbose': True}) PreProcess_thread = threading.Thread(name='Pre-Processor', target=PrePross.run,
class FrameSeperator(object): """This class do the separating video into frames""" # create the object of pre_processor module pre_processor_obj = pre_processor.PreProcessor() # create object of frame detail operation class(not the output dict) ops_obj = ops.DictOps() # create the object of the output dict output_ops_obj = output_ops.OutputDictOps() # constructor def __init__(self): pass def catch_video(self, video_location): """first method get call from GUI""" # change the progress bar values container.component[1]['value'] = 10 container.component[0].update_idletasks() # get the video cap = cv2.VideoCapture(video_location) # get frame rate # fps = cap.get(cv2.CAP_PROP_FPS) # method call self.seperator(cap) # method def seperator(self, cap): """This method do separation task""" if not cap.isOpened(): print('ERROR FILE NOT FOUND OR WRONG CODEC USED!') # get first frame of the video as 1 frame_position = 1 while cap.isOpened(): ret, frame = cap.read() if ret: # get timestamp of current frame time_stamp = cap.get(cv2.CAP_PROP_POS_MSEC) / 1000 # sent frame to pre-processing self.pre_processor_obj.pre_processing(frame, frame_position, time_stamp) # track frame position frame_position += 1 # condition for hard stop the separating to frames if cv2.waitKey(1) & 0xFF == ord('q'): break else: # method call - to print just frame details(not output dict) self.iterate_different_frame_timestamp() print("################################################") # get frame info to variable output_visual_info = self.ops_obj.get_visual_info() # pass frame details to creat output visual info dict visual_output = self.output_ops_obj.create_dict( output_visual_info) print( "-----------------------Write To Doc-------------------------" ) doc_ops.write_to_doc_method(visual_output) print( "-----------------------Write To Doc-------------------------" ) # change the progress bar values container.component[1]['value'] = 50 container.component[0].update_idletasks() break cap.release() # method def iterate_different_frame_timestamp(self): """Iterate selected frame's details""" # method call - to print just frame details(not output dict) self.ops_obj.view_dict()
def test_whitelist(self): pp = pre_processor.PreProcessor(whitelist=['Brazil']) data = pp.pre_process() len_data = len(data) assert len_data == 1
def test_blacklist(self): pp = pre_processor.PreProcessor(blacklist=['Brazil']) data = pp.pre_process() assert 'Brazil' not in data.keys()
#print(self.Pi, self.ki, self.x0, self.sigma_Pi, self.sigma_ki, self.sigma_x0) def plot_prediction(self): plt.clf() future_dates = range( len(self.X) + self.future_prediction - self.add_future_days) plt.scatter(self.X[:len(self.X) - self.add_future_days], self.y[:len(self.X) - self.add_future_days], label=self.identifier) y_pred = self.model(future_dates, self.Pi, self.ki, self.x0) upper_lim = [ self.model(i, self.Pi + self.sigma_Pi, self.ki, self.x0) for i in future_dates ] lower_lim = [ self.model(i, self.Pi - self.sigma_Pi, self.ki, self.x0) for i in future_dates ] plt.plot(future_dates, y_pred) plt.fill_between(future_dates, lower_lim, upper_lim, alpha=0.4) plt.legend() plt.show() if (__name__ == "__main__"): total_regressor = TotalLogisticRegressor() pp = pre_processor.PreProcessor(total_regressor.file, filter_date=True) total_regressor.dataset = pp.pre_process() total_regressor.identifier = 'total_deaths' total_regressor.run() total_regressor.plot_prediction()
import pre_processor as pp #import oneVSAllSVM as OVA #import oneVSOneSVM as OVO # import oneVSAllSVM as OVA # import oneVSOne as OVO processor = pp.PreProcessor() processor.condense() processor.extract_stats() processor.condense_3d(60) # ova = OVA.OneVSAllSVM() # ova.run() # # ovo = OVO.OneVSOneSVM() # ovo.run() # # # #