Python/High_acquisition_rate_TSFRESH/unified_bib.py
def TSFRESH_Extraction(D_S_parameters):
    ''' Function to extract features of the time series using
    TSFRESH method
    
    Parameters:
    ------
    D_S_parameters : dictionary, with the following items
        'FinalTarget': np.array
            targets of the entire dataset
        'M_N_groups': int
            number of groups
        'ID': int
            identifier for the dataset
        'N_IDs': int
            number of time series
    
    
    Returns: 
    -------
    list
        a list of string with the name of the extracted features by TSFRESH
        
    '''
    
    print('             ')
    print('TSFRESH Control Output')
    print('----------------------------------')
    
    #Changing Work Folder
    
    add_path2 = "/Kernel/"
    add_path3 = "/.Recovery/"
    base_path = os.getcwd()
    working_path = os.getcwd()
    Kernel_path = working_path + add_path2
    Recovery_path = working_path + add_path3
        
    # Now change to Kernel directory
    
    os.chdir( Kernel_path )
    
    ###______________________________________________________________________###
    ###                         Feature Extraction                           ###

    #E_N_groups = np.load('E_N_groups.npy')
    P_N_groups = D_S_parameters['M_N_groups']
    
    for i in range(P_N_groups):
        
        Data = np.genfromtxt('Data_' + str(i) + '.csv', delimiter=',')
        data = pd.DataFrame(Data, columns= ['id','time'] + ['Sensor_' + str(x) for x in range(1,(Data.shape[1]-1))])
        
        Data_extracted_features = extract_features(data,column_id = "id", column_sort="time",n_jobs=4,disable_progressbar=True)
        extracted_names = list(Data_extracted_features.columns)
        np.savetxt('Data_Features_' + str(i) + '.csv', Data_extracted_features.values, delimiter=',')
        
    #for i in range(E_N_groups):

    
    #    data = pd.DataFrame(np.genfromtxt('Eminence_' + str(i) + '.csv', delimiter=','), 
    #                        columns= ['id','time','sensor_1','sensor_2','sensor_3','sensor_4',
    #                                            'sensor_5','sensor_6','sensor_7'])
    #    extracted_features = extract_features(data, column_id = "id", column_sort="time")
    #    np.savetxt('Eminence_Features_' + str(i) + '.csv', extracted_features, delimiter=',')
    
    # Now change to Recovery directory
    
    os.chdir( Recovery_path )
    
    np.save('extracted_names.npy',extracted_names)
    
    # Now change back to base directory
    
    os.chdir( base_path )
    
    print("Number of Extracted Features: {}".format(len(extracted_names)))
    
    return extracted_names
 Function to extract features of the time series using
    TSFRESH method
    
    Parameters:
    ------
    D_S_parameters : dictionary, with the following items
        'FinalTarget': np.array
            targets of the entire dataset
        'M_N_groups': int
            number of groups
        'ID': int
            identifier for the dataset
        'N_IDs': int
            number of time series
    
    
    Returns: 
    -------
    list
        a list of string with the name of the extracted features by TSFRESH
        
    
Function to extract features of the time series using
TSFRESH method







list
a list of string with the name of the extracted features by TSFRESH
Function to extract features of the time series using TSFRESH method list a list of string with the name of the extracted features by TSFRESH
def TSFRESH_Extraction(D_S_parameters):
    print('             ')
    print('TSFRESH Control Output')
    print('----------------------------------')
    add_path2 = "/Kernel/"
    add_path3 = "/.Recovery/"
    base_path = os.getcwd()
    working_path = os.getcwd()
    Kernel_path = working_path + add_path2
    Recovery_path = working_path + add_path3
    os.chdir( Kernel_path )
    P_N_groups = D_S_parameters['M_N_groups']
    for i in range(P_N_groups):
        Data = np.genfromtxt('Data_' + str(i) + '.csv', delimiter=',')
        data = pd.DataFrame(Data, columns= ['id','time'] + ['Sensor_' + str(x) for x in range(1,(Data.shape[1]-1))])
        Data_extracted_features = extract_features(data,column_id = "id", column_sort="time",n_jobs=4,disable_progressbar=True)
        extracted_names = list(Data_extracted_features.columns)
        np.savetxt('Data_Features_' + str(i) + '.csv', Data_extracted_features.values, delimiter=',')
    os.chdir( Recovery_path )
    np.save('extracted_names.npy',extracted_names)
    os.chdir( base_path )
    print("Number of Extracted Features: {}".format(len(extracted_names)))
    return extracted_names
def TSFRESH_Extraction ( D_S_parameters ) : print ( '             ' ) print ( 'TSFRESH Control Output' ) print ( '----------------------------------' ) add_path2 = "/Kernel/" add_path3 = "/.Recovery/" base_path = os . getcwd ( ) working_path = os . getcwd ( ) Kernel_path = working_path + add_path2 Recovery_path = working_path + add_path3 os . chdir ( Kernel_path ) P_N_groups = D_S_parameters [ 'M_N_groups' ] for i in range ( P_N_groups ) : Data = np . genfromtxt ( 'Data_' + str ( i ) + '.csv' , delimiter = ',' ) data = pd . DataFrame ( Data , columns = [ 'id' , 'time' ] + [ 'Sensor_' + str ( x ) for x in range ( 1 , ( Data . shape [ 1 ] - 1 ) ) ] ) Data_extracted_features = extract_features ( data , column_id = "id" , column_sort = "time" , n_jobs = 4 , disable_progressbar = True ) extracted_names = list ( Data_extracted_features . columns ) np . savetxt ( 'Data_Features_' + str ( i ) + '.csv' , Data_extracted_features . values , delimiter = ',' ) os . chdir ( Recovery_path ) np . save ( 'extracted_names.npy' , extracted_names ) os . chdir ( base_path ) print ( "Number of Extracted Features: {}" . format ( len ( extracted_names ) ) ) return extracted_names
Function to extract features of the time series using
TSFRESH method
Function to extract features of the time series using TSFRESH method
''' Function to extract features of the time series using
    TSFRESH method
    
    Parameters:
    ------
    D_S_parameters : dictionary, with the following items
        'FinalTarget': np.array
            targets of the entire dataset
        'M_N_groups': int
            number of groups
        'ID': int
            identifier for the dataset
        'N_IDs': int
            number of time series
    
    
    Returns: 
    -------
    list
        a list of string with the name of the extracted features by TSFRESH
        
    ''' #Changing Work Folder # Now change to Kernel directory ###______________________________________________________________________### ###                         Feature Extraction                           ### #E_N_groups = np.load('E_N_groups.npy') #for i in range(E_N_groups): #    data = pd.DataFrame(np.genfromtxt('Eminence_' + str(i) + '.csv', delimiter=','),  #                        columns= ['id','time','sensor_1','sensor_2','sensor_3','sensor_4', #                                            'sensor_5','sensor_6','sensor_7']) #    extracted_features = extract_features(data, column_id = "id", column_sort="time") #    np.savetxt('Eminence_Features_' + str(i) + '.csv', extracted_features, delimiter=',') # Now change to Recovery directory # Now change back to base directory
D_S_parameters