예제 #1
0
def test_surfstar_Multiplexer():
    """ Test SURF* on 6-bit Multiplexer """
    #New parameters
    options['algorithm'] = 'surfstar'
    Scores = S.runSURF(header, x, y, attr, var, distArray, options)
    print("SURF* + 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
예제 #2
0
def test_surfstar_GWAS_Sim():
    """ Test SURF* on GWAS_Sim Missing Data"""
    #New parameters
    options['algorithm'] = 'surfstar'
    Scores = S.runSURF(header, x, y, attr, var, distArray, options)
    print("SURF* + 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
예제 #3
0
        import multisurf as MS
        print('Running MultiSURF or MultiSURF* + TuRF')
        fun = MS.runMultiSURF
        
    Scores,x,var,lost,table = T.runTurf(header,x,y,attr,var,distArray,pct,iterations,fun,options,cmn)
    options['algorithm'] = algorithm + "-turf"

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)
예제 #4
0
파일: rebate.py 프로젝트: woshahua/ReBATE
    options['algorithm'] = algorithm + "-turf"

elif (algorithm == 'relieff'):
    import relieff as R
    Scores = R.runReliefF(header, x, y, attr, var, distArray, options)

elif (algorithm == 'multisurf'):
    if (var['classType'] == 'multiclass'):
        import mcms as MS
    else:
        import multisurf as MS
    Scores = MS.runMultiSURF(header, x, y, attr, var, distArray, options)

elif (algorithm == 'surf' or algorithm == 'surfstar'):
    import surf as S
    Scores = S.runSURF(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))
###############################################################################