示例#1
0
def main():
    '''EDM package examples.
       df denotes a Pandas DataFrame.
       S and M denote dictionaries of Pandas DataFrames'''

    dataFiles = [ "TentMap_rEDM.csv",
                  "TentMapNoise_rEDM.csv",
                  "circle.csv",
                  "block_3sp.csv",
                  "sardine_anchovy_sst.csv" ]
    
    # Create map of module dataFiles pathnames in Files
    Files = {}

    for file in dataFiles:
        filename = "data/" + file
        if pkg_resources.resource_exists( EDM.__name__, filename ):
            Files[ file ] = \
            pkg_resources.resource_filename( EDM.__name__, filename )
        else :
            raise Exception( "examples.py: Failed to find data file " + \
                             file + " in EDM package" )

    # Note the path argument is empty "", file path is in Files{}
    df = EDM.EmbedDimension( "", Files[ "TentMap_rEDM.csv" ], None, "./", "",
                             "1 100", "201 500", 10, 1, 1,
                             "TentMap", "", False, False, 4 )
    
    df = EDM.PredictInterval( "", Files[ "TentMap_rEDM.csv" ], None, "./", "",
                              "1 100", "201 500", 10, 2, 1,
                              "TentMap", "", False, False, 4 );

    df = EDM.PredictNonlinear( "", Files[ "TentMapNoise_rEDM.csv" ], None,
                               "./", "", "1 100", "201 500", "", 2, 1, 0, 1,
                               "TentMap", "", False, False, 4 )
    
    # Tent map simplex : specify multivariable columns embedded = True
    df = EDM.Simplex( "", Files[ "block_3sp.csv" ], None, "./", "", 
                      "1 99", "100 198", 3, 1, 0, 1, 0,
                      "x_t y_t z_t", "x_t", True, False, True, True )

    # Tent map simplex : Embed column x_t to E=3, embedded = False
    df = EDM.Simplex( "", Files[ "block_3sp.csv" ], None, "./", "", 
                      "1 99", "100 195", 3, 1, 0, 1, 0,
                      "x_t", "x_t", False, False, True, True )

    M = EDM.Multiview( "", Files[ "block_3sp.csv" ], None, "./", "", 
                       "1 100", "101 198", 3, 1, 0, 1,
                       "x_t y_t z_t", "x_t", 0, 0, False, 4, True )

    # S-map circle : specify multivariable columns embedded = True
    S = EDM.SMap( "", Files[ "circle.csv" ], None, "./", "", 
                  "1 100", "101 198", 2, 1, 0, 1, 4, 0,
                  "x y", "x", "", "", True, False, True, True )
    
    df = EDM.CCM( "", Files[ "sardine_anchovy_sst.csv" ], None, "./", "", 
                  3, 0, 0, 1, "anchovy", "np_sst",
                  "10 70 10", 100, True, False, 0, True, True )
示例#2
0
    def test_multiview( self ):
        print ( "--- Multiview ---" )
        M = EDM.Multiview( "", self.Files[ "block_3sp.csv" ], None, "./", "", 
                           "1 100", "101 198", 0, 3, 1, 0, -1,
                           "x_t y_t z_t", "x_t", 0, 0, True, False, 4 )

        df_pred  = M['Predictions']
        df_combo = round( M['View'  ], 4 )
        
        # cppEDM and devPDM outputs are rounded to os.precision( 4 );
        dfv = EDM.ReadDataFrame( "", self.Files[ "Multiview_pred_valid.csv" ],
                                 noTime = True )
        dfc = EDM.ReadDataFrame( "", self.Files[ "Multiview_combos_valid.csv" ],
                                 noTime = True )

        # Validate predictions
        M1 = dfv.get('Predictions')
        M2 = round( df_pred.get('Predictions'), 4 ) 
        self.assertTrue( M1.equals( M2 ) )

        # Validate combinations
        self.assertTrue( dfc.equals( df_combo ) )
示例#3
0
def main():
    '''EDM package examples.
       df denotes a Pandas DataFrame.
       S and M denote dictionaries of Pandas DataFrames'''

    dataFiles = [ "TentMap_rEDM.csv",
                  "TentMapNoise_rEDM.csv",
                  "circle.csv",
                  "block_3sp.csv",
                  "sardine_anchovy_sst.csv" ]
    
    # Create map of module dataFiles pathnames in Files
    Files = {}

    for file in dataFiles:
        filename = "data/" + file
        if pkg_resources.resource_exists( EDM.__name__, filename ):
            Files[ file ] = \
            pkg_resources.resource_filename( EDM.__name__, filename )
        else :
            raise Exception( "examples.py: Failed to find data file " + \
                             file + " in EDM package" )

    # Note the path argument is empty "", file path is in Files{}
    df = EDM.EmbedDimension( pathIn = "", dataFile = Files["TentMap_rEDM.csv"],
                             lib = "1 100", pred = "201 500", maxE = 10,
                             Tp = 1, tau = -1, exclusionRadius = 0,
                             columns = "TentMap", target = "TentMap",
                             validLib = [], numThreads = 4 )
    
    df = EDM.PredictInterval( pathIn = "", dataFile = Files["TentMap_rEDM.csv"],
                              lib = "1 100", pred = "201 500", maxTp = 10,
                              E = 2, tau = -1, exclusionRadius = 0,
                              columns = "TentMap", target = "TentMap",
                              validLib = [], numThreads = 4 );

    df = EDM.PredictNonlinear( pathIn = "",
                               dataFile = Files[ "TentMapNoise_rEDM.csv" ],
                               lib = "1 100", pred = "201 500", E = 2,
                               Tp = 1, knn = 0, tau = -1,
                               columns = "TentMap", target = "TentMap",
                               validLib = [], numThreads = 4 )
    
    # Tent map simplex : specify multivariable columns embedded = True
    S = EDM.Simplex( pathIn = "", dataFile = Files[ "block_3sp.csv" ],
                     lib = "1 99", pred = "100 198", E = 3, Tp = 1,
                     knn = 0, tau = -1, exclusionRadius = 0,
                     columns = "x_t y_t z_t", target = "x_t",
                     embedded = True, showPlot = True,
                     validLib = [], generateSteps = 0, parameterList = False )

    # Tent map simplex : Embed column x_t to E=3, embedded = False
    S = EDM.Simplex( pathIn = "", dataFile = Files[ "block_3sp.csv" ],
                     lib = "1 99", pred = "100 198", E = 3, Tp = 1,
                     knn = 0, tau = -1, exclusionRadius = 0,
                     columns = "x_t y_t z_t", target = "x_t",
                     embedded = False, showPlot = True,
                     validLib = [], generateSteps = 0, parameterList = False )

    M = EDM.Multiview( pathIn = "", dataFile = Files[ "block_3sp.csv" ],
                       lib = "1 100", pred = "101 198",
                       D = 0, E = 3, Tp = 1, knn = 0, tau = -1,
                       multiview = 0, exclusionRadius = 0,
                       columns = "x_t y_t z_t", target = "x_t",
                       trainLib = True, excludeTarget = False,
                       numThreads = 4, showPlot = True )

    # S-map circle : specify multivariable columns embedded = True
    S = EDM.SMap( pathIn = "", dataFile = Files[ "circle.csv" ], 
                  lib = "1 100", pred = "101 198",
                  E = 2, Tp = 1, knn = 0, tau = -1,
                  theta = 4, exclusionRadius = 0,
                  columns = "x y", target = "x",
                  solver = None, embedded = True,
                  validLib = [], generateSteps = 0, parameterList = False )
    
    CM = EDM.CCM( pathIn = "", dataFile = Files[ "sardine_anchovy_sst.csv" ],
                  E = 3, Tp = 0, knn = 0, tau = -1, exclusionRadius = 0,
                  columns = "anchovy", target = "np_sst",
                  libSizes = "10 70 10", sample = 100, random = True,
                  replacement = False, seed = 0, includeData = False,
                  parameterList = False, verbose = False, showPlot = True )