Ejemplo n.º 1
0
def test_multisurf_Multiplexer():
    """ Test MultiSURF on 6-bit Multiplexer """
    #New parameters
    options['algorithm'] = 'multisurf'
    Scores = MS.runMultiSURF(header, x, y, attr, var, distArray, options)
    print("MultiSURF + 6-bit Multiplexer ")
    print(str(Scores))
    #Check that score list is not empty
    assert Scores != None
    #Check that a score for all features is output
    assert len(Scores) == 6  #6-bit Multiplexer problem
    #Check that all scores fall between -1 and 1
    assert max(Scores) <= 1 and min(Scores) >= -1
    #Check that the address bits (indexed as features 0 and 1) have the top scores as expected.
    indexTopScore = Scores.index(max(Scores))
    assert indexTopScore == 0 or indexTopScore == 1
    Scores.pop(indexTopScore)
    indexTopScore = Scores.index(max(Scores))
    assert indexTopScore == 0
Ejemplo n.º 2
0
def test_multisurf_GWAS_Sim():
    """ Test MultiSURF on GWAS_Sim Missing Data"""
    #New parameters
    options['algorithm'] = 'multisurf'
    Scores = MS.runMultiSURF(header, x, y, attr, var, distArray, options)
    print("MultiSURF + GWAS_Sim MD ")
    print(str(Scores))
    #Check that score list is not empty
    assert Scores != None
    #Check that a score for all features is output
    assert len(Scores) == 20  #GWAS simulated dataset
    #Check that all scores fall between -1 and 1
    assert max(Scores) <= 1 and min(Scores) >= -1
    #Check that the address bits (indexed as features 0 and 1) have the top scores as expected.
    indexTopScore = Scores.index(max(Scores))
    assert indexTopScore == 18 or indexTopScore == 19
    Scores.pop(indexTopScore)
    indexTopScore = Scores.index(max(Scores))
    assert indexTopScore == 18
Ejemplo n.º 3
0
elif(algorithm == 'relieff'):
    import relieff as R
    print('Running Relieff')
    Scores = R.runReliefF(header,x,y,attr,var,distArray,options)

elif(algorithm == 'surf' or algorithm =='surfstar'):
    import surf as S
    print('Running SURF or SURF*')
    Scores = S.runSURF(header, x, y, attr, var, distArray, options)
    
elif(algorithm == 'multisurf' or algorithm == 'multisurfstar'):
    if(var['classType'] == 'multiclass'):
        import multisurf as MS
    print('Running MultiSURF or MultiSURF*')
    Scores = MS.runMultiSURF(header, x, y, attr, var, distArray, options)
#-----------------------------------------------------------------------------#
# create new data files of some number of top scored attributes
ordered_attr = io.createScoresFile(header, var, Scores, options,
                                   prog_start, turfpct, table, lost)

if(options['topattr'] > 0): 
    io.create_subset(header, x, y, options, ordered_attr)
if(options['testdata'] != None): 
    io.create_test_subset(tdata, options, ordered_attr)

if(V): 
    ctime = "[" + tm.strftime("%H:%M:%S") + "]"
    print(ctime + " Overall program time(sec) = " + str(tm.time() - prog_start))
###############################################################################
Ejemplo n.º 4
0
elif (algorithm == 'relieff'):
    import relieff as R
    print('Running Relieff')
    Scores = R.runReliefF(header, x, y, attr, var, distArray, options)

elif (algorithm == 'surf' or algorithm == 'surfstar'):
    import surf as S
    print('Running SURF or SURF*')
    Scores = S.runSURF(header, x, y, attr, var, distArray, options)

elif (algorithm == 'multisurf' or algorithm == 'multisurfstar'):
    if (var['classType'] == 'multiclass'):
        import multisurf as MS
    print('Running MultiSURF or MultiSURF*')
    Scores = MS.runMultiSURF(header, x, y, attr, var, distArray, options)
#-----------------------------------------------------------------------------#
# create new data files of some number of top scored attributes
ordered_attr = io.createScoresFile(header, var, Scores, options, prog_start,
                                   turfpct, table, lost)

if (options['topattr'] > 0):
    io.create_subset(header, x, y, options, ordered_attr)
if (options['testdata'] != None):
    io.create_test_subset(tdata, options, ordered_attr)

if (V):
    ctime = "[" + tm.strftime("%H:%M:%S") + "]"
    print(ctime + " Overall program time(sec) = " +
          str(tm.time() - prog_start))
###############################################################################