Python/High_acquisition_rate_TSFRESH/unified_bib.py
def dynamic_tsfresh (total_data, mode='prototype'):
    ''' Function for ONLINE mode
    This function read the data from the acquisition module and executes a 
    dynamic and lighter version of TSFRESH.
    
    Parameters:
    ------
    output_id : int 
        identifier of the seed dataset
    
    extracted_names: list
    
    Returns: 
    -------
    dataframe #########################################################
        

    '''
        

    data = total_data[:,2:-1]
    info = total_data[:,0:2]
        
    # Normalizing
    scaler = MinMaxScaler()
    data = scaler.fit_transform(data)

    total_data = np.concatenate((info,data), axis=1)
      
    # ----------------------------------------------------------------- # 
    df = pd.DataFrame(total_data, columns= ['id','time'] + 
                        ['Sensor_' + str(x) for x in range(1,(total_data.shape[1]-1))])
    
    # Loading feature dictionary
    with open('Kernel/kind_to_fc_parameters.pkl', 'rb') as f:
        kind_to_fc_parameters = pickle.load(f)
    
    # Loading column names

    with open('Kernel/columns.pkl', 'rb') as f:
        original_columns = pickle.load(f)
    
    columns = []
    

    for i,x in enumerate(kind_to_fc_parameters):
        aux = pd.DataFrame(np.hstack((df.loc[:,:'time'].values,
                            df.loc[:,x].values.reshape((-1,1)))),
                            columns=['id','time',x])
        
        aux2 = tsfresh.extract_features(aux, column_id="id", column_sort="time",
                                        default_fc_parameters=kind_to_fc_parameters[x],#chunksize=24000, 
                                        n_jobs=0
                                        #disable_progressbar=True
                                        )
        for j in range(len(aux2.columns.tolist())):columns.append(aux2.columns.tolist()[j])

        if i == 0:
            extracted_features = np.array(aux2.values)
        else:
            extracted_features = np.hstack((extracted_features,aux2.values))

    final_features = pd.DataFrame(extracted_features,columns=columns)
    final_features = final_features[original_columns]

    return impute(final_features), extracted_features
 Function for ONLINE mode
    This function read the data from the acquisition module and executes a 
    dynamic and lighter version of TSFRESH.
    
    Parameters:
    ------
    output_id : int 
        identifier of the seed dataset
    
    extracted_names: list
    
    Returns: 
    -------
    dataframe #########################################################
        

    
Function for ONLINE mode
This function read the data from the acquisition module and executes a
dynamic and lighter version of TSFRESH.



output_id : int
identifier of the seed dataset

list



dataframe
Function for ONLINE mode This function read the data from the acquisition module and executes a dynamic and lighter version of TSFRESH . output_id : int identifier of the seed dataset list dataframe
def dynamic_tsfresh (total_data, mode='prototype'):
    data = total_data[:,2:-1]
    info = total_data[:,0:2]
    scaler = MinMaxScaler()
    data = scaler.fit_transform(data)
    total_data = np.concatenate((info,data), axis=1)
    df = pd.DataFrame(total_data, columns= ['id','time'] + 
                        ['Sensor_' + str(x) for x in range(1,(total_data.shape[1]-1))])
    with open('Kernel/kind_to_fc_parameters.pkl', 'rb') as f:
        kind_to_fc_parameters = pickle.load(f)
    with open('Kernel/columns.pkl', 'rb') as f:
        original_columns = pickle.load(f)
    columns = []
    for i,x in enumerate(kind_to_fc_parameters):
        aux = pd.DataFrame(np.hstack((df.loc[:,:'time'].values,
                            df.loc[:,x].values.reshape((-1,1)))),
                            columns=['id','time',x])
        aux2 = tsfresh.extract_features(aux, column_id="id", column_sort="time",
                                        default_fc_parameters=kind_to_fc_parameters[x],
                                        n_jobs=0
                                        )
        for j in range(len(aux2.columns.tolist())):columns.append(aux2.columns.tolist()[j])
        if i == 0:
            extracted_features = np.array(aux2.values)
        else:
            extracted_features = np.hstack((extracted_features,aux2.values))
    final_features = pd.DataFrame(extracted_features,columns=columns)
    final_features = final_features[original_columns]
    return impute(final_features), extracted_features
def dynamic_tsfresh ( total_data , mode = 'prototype' ) : data = total_data [ : , 2 : - 1 ] info = total_data [ : , 0 : 2 ] scaler = MinMaxScaler ( ) data = scaler . fit_transform ( data ) total_data = np . concatenate ( ( info , data ) , axis = 1 ) df = pd . DataFrame ( total_data , columns = [ 'id' , 'time' ] + [ 'Sensor_' + str ( x ) for x in range ( 1 , ( total_data . shape [ 1 ] - 1 ) ) ] ) with open ( 'Kernel/kind_to_fc_parameters.pkl' , 'rb' ) as f : kind_to_fc_parameters = pickle . load ( f ) with open ( 'Kernel/columns.pkl' , 'rb' ) as f : original_columns = pickle . load ( f ) columns = [ ] for i , x in enumerate ( kind_to_fc_parameters ) : aux = pd . DataFrame ( np . hstack ( ( df . loc [ : , : 'time' ] . values , df . loc [ : , x ] . values . reshape ( ( - 1 , 1 ) ) ) ) , columns = [ 'id' , 'time' , x ] ) aux2 = tsfresh . extract_features ( aux , column_id = "id" , column_sort = "time" , default_fc_parameters = kind_to_fc_parameters [ x ] , n_jobs = 0 ) for j in range ( len ( aux2 . columns . tolist ( ) ) ) : columns . append ( aux2 . columns . tolist ( ) [ j ] ) if i == 0 : extracted_features = np . array ( aux2 . values ) else : extracted_features = np . hstack ( ( extracted_features , aux2 . values ) ) final_features = pd . DataFrame ( extracted_features , columns = columns ) final_features = final_features [ original_columns ] return impute ( final_features ) , extracted_features
Function for ONLINE mode
This function read the data from the acquisition module and executes a
dynamic and lighter version of TSFRESH.
Function for ONLINE mode This function read the data from the acquisition module and executes a dynamic and lighter version of TSFRESH .
''' Function for ONLINE mode
    This function read the data from the acquisition module and executes a 
    dynamic and lighter version of TSFRESH.
    
    Parameters:
    ------
    output_id : int 
        identifier of the seed dataset
    
    extracted_names: list
    
    Returns: 
    -------
    dataframe #########################################################
        

    ''' # Normalizing # ----------------------------------------------------------------- #  # Loading feature dictionary # Loading column names #chunksize=24000,  #disable_progressbar=True
total_data
mode