def check_C_testset(mss_id):
    
    import pylab
    import expenv
    import numpy
    from helper import Options
    from method_hierarchy_svm_new import Method
    #from method_augmented_svm_new import Method
    
    
    #costs = 10000 #[float(c) for c in numpy.exp(numpy.linspace(numpy.log(10), numpy.log(20000), 6))]
    costs = [float(c) for c in numpy.exp(numpy.linspace(numpy.log(0.4), numpy.log(10), 6))] 
    
    print costs
    
    mss = expenv.MultiSplitSet.get(mss_id)
    
    train = mss.get_train_data(-1)
    test = mss.get_eval_data(-1)
    
    au_roc = []
    au_prc = []
    
    for cost in costs:
        #create mock param object by freezable struct
        param = Options()
        param.kernel = "WeightedDegreeStringKernel"
        param.wdk_degree = 10
        param.transform = cost
        param.base_similarity = 1.0
        param.taxonomy = mss.taxonomy
        param.id = 666
    
        #param.cost = cost
        param.cost = 10000
        param.freeze()
    
        # train
        mymethod = Method(param)
        mymethod.train(train)
    
        assessment = mymethod.evaluate(test)
        
        au_roc.append(assessment.auROC)
        au_prc.append(assessment.auPRC)
        
        print assessment
        assessment.destroySelf()

    pylab.title("auROC")
    pylab.semilogx(costs, au_roc, "-o")
    
    pylab.show()
    pylab.figure()
    pylab.title("auPRC")
    pylab.semilogx(costs, au_prc, "-o")
    pylab.show()
    
    return (costs, au_roc, au_prc)
def main():
    
    
    print "starting debugging:"

    SPLIT_POINTER = -1

    from expenv import MultiSplitSet
    from helper import Options 
    
    
    # select dataset
    #multi_split_set = MultiSplitSet.get(387)
    #multi_split_set = MultiSplitSet.get(407)
    multi_split_set = MultiSplitSet.get(399)

    #dataset_name = multi_split_set.description

    
    # create mock param object by freezable struct
    param = Options()
    param.kernel = "WeightedDegreeRBFKernel" #"WeightedDegreeStringKernel"#"PolyKernel" 
    param.wdk_degree = 2
    param.cost = 1.0
    param.transform = 0.2
    param.base_similarity = 1.0
    param.taxonomy = multi_split_set.taxonomy
    param.id = 666
    
    flags= {}
    #flags["boosting"] = "ones"
    #flags["boosting"] = "L1"
    flags["boosting"] = "L2"
    #flags["boosting"] = "L2_reg"
    flags["signum"] = False
    flags["normalize_cost"] = True
    flags["all_positions"] = False
    
    flags["wdk_rbf_on"] = False
    
    param.flags = flags
    
    param.freeze()
    

    data_train = multi_split_set.get_train_data(SPLIT_POINTER)
    data_eval = multi_split_set.get_eval_data(SPLIT_POINTER)


    # train
    mymethod = Method(param)
    mymethod.train(data_train)


    assessment = mymethod.evaluate(data_eval)
    
    print assessment
    
    assessment.destroySelf()
Beispiel #3
0
def main():
    
    
    print "starting debugging:"

    SPLIT_POINTER = -1

    from expenv import MultiSplitSet
    from helper import Options 
    
    
    # select dataset
    #multi_split_set = MultiSplitSet.get(387)
    #multi_split_set = MultiSplitSet.get(407)
    multi_split_set = MultiSplitSet.get(399)

    #dataset_name = multi_split_set.description

    
    # create mock param object by freezable struct
    param = Options()
    param.kernel = "WeightedDegreeStringKernel"#"PolyKernel" 
    param.wdk_degree = 2
    param.cost = 1.0
    param.transform = 0.2
    param.base_similarity = 1
    param.taxonomy = multi_split_set.taxonomy
    param.id = 666
    
    flags= {}
    #flags["boosting"] = "ones"
    flags["boosting"] = "L1"
    #flags["boosting"] = "L2"
    #flags["boosting"] = "L2_reg"
    flags["signum"] = False
    flags["normalize_cost"] = True
    flags["all_positions"] = False
    flags["wdk_rbf_on"] = False
    
    param.flags = flags
    
    param.freeze()
    

    data_train = multi_split_set.get_train_data(SPLIT_POINTER)
    data_eval = multi_split_set.get_eval_data(SPLIT_POINTER)


    # train
    mymethod = Method(param)
    mymethod.train(data_train)


    assessment = mymethod.evaluate(data_eval)
    
    print assessment
    
    assessment.destroySelf()
Beispiel #4
0
def training_for_sigma(sigma):

    print "starting debugging:"


    from expenv import MultiSplitSet
        
    # select dataset
    multi_split_set = MultiSplitSet.get(393)

    SPLIT_POINTER = 1
    
    #create mock param object by freezable struct
    param = Options()
    param.kernel =  "WeightedDegreeStringKernel" #"WeightedDegreeRBFKernel" # #
    param.wdk_degree = 2
    param.cost = 1.0
    param.transform = 1.0 
    param.id = 666
    param.base_similarity = sigma
    param.degree = 2
    param.flags = {}
    
    param.flags["wdk_rbf_on"] = False   
    param.freeze()
    

    data_train = multi_split_set.get_train_data(SPLIT_POINTER)
    data_eval = multi_split_set.get_eval_data(SPLIT_POINTER)


    # train
    mymethod = Method(param)
    mymethod.train(data_train)

    print "training done"

    assessment = mymethod.evaluate(data_eval)
    
    print assessment
    
    assessment.destroySelf()



    return assessment.auROC
Beispiel #5
0
def main():
    
    
    print "starting debugging:"

    SPLIT_POINTER = 1

    from expenv import MultiSplitSet
    from helper import Options 
    
    
    # select dataset
    multi_split_set = MultiSplitSet.get(399)

    
    #create mock param object by freezable struct
    param = Options()
    param.kernel =  "WeightedDegreeRBFKernel" #"WeightedDegreeStringKernel"# #
    param.wdk_degree = 1
    param.cost = 1.0
    param.transform = 1.0
    param.sigma = 1.0
    param.id = 666
    param.base_similarity = 1
    param.degree = 2
    
    param.freeze()
    

    data_train = multi_split_set.get_train_data(SPLIT_POINTER)
    data_eval = multi_split_set.get_eval_data(SPLIT_POINTER)


    # train
    mymethod = Method(param)
    mymethod.train(data_train)

    print "training done"

    assessment = mymethod.evaluate(data_eval)
    
    print assessment
    
    assessment.destroySelf()
Beispiel #6
0
def training_for_sigma(sigma):

    print "starting debugging:"

    from expenv import MultiSplitSet

    # select dataset
    multi_split_set = MultiSplitSet.get(393)

    SPLIT_POINTER = 1

    #create mock param object by freezable struct
    param = Options()
    param.kernel = "WeightedDegreeStringKernel"  #"WeightedDegreeRBFKernel" # #
    param.wdk_degree = 2
    param.cost = 1.0
    param.transform = 1.0
    param.id = 666
    param.base_similarity = sigma
    param.degree = 2
    param.flags = {}

    param.flags["wdk_rbf_on"] = False
    param.freeze()

    data_train = multi_split_set.get_train_data(SPLIT_POINTER)
    data_eval = multi_split_set.get_eval_data(SPLIT_POINTER)

    # train
    mymethod = Method(param)
    mymethod.train(data_train)

    print "training done"

    assessment = mymethod.evaluate(data_eval)

    print assessment

    assessment.destroySelf()

    return assessment.auROC
Beispiel #7
0
def main():

    print "starting debugging:"

    SPLIT_POINTER = 1

    from expenv import MultiSplitSet
    from helper import Options

    # select dataset
    multi_split_set = MultiSplitSet.get(399)

    #create mock param object by freezable struct
    param = Options()
    param.kernel = "WeightedDegreeRBFKernel"  #"WeightedDegreeStringKernel"# #
    param.wdk_degree = 1
    param.cost = 1.0
    param.transform = 1.0
    param.sigma = 1.0
    param.id = 666
    param.base_similarity = 1
    param.degree = 2

    param.freeze()

    data_train = multi_split_set.get_train_data(SPLIT_POINTER)
    data_eval = multi_split_set.get_eval_data(SPLIT_POINTER)

    # train
    mymethod = Method(param)
    mymethod.train(data_train)

    print "training done"

    assessment = mymethod.evaluate(data_eval)

    print assessment

    assessment.destroySelf()
Beispiel #8
0
def check_C_testset(mss_id):

    import pylab
    import expenv
    import numpy
    from helper import Options
    from method_hierarchy_svm_new import Method
    #from method_augmented_svm_new import Method

    #costs = 10000 #[float(c) for c in numpy.exp(numpy.linspace(numpy.log(10), numpy.log(20000), 6))]
    costs = [
        float(c)
        for c in numpy.exp(numpy.linspace(numpy.log(0.4), numpy.log(10), 6))
    ]

    print costs

    mss = expenv.MultiSplitSet.get(mss_id)

    train = mss.get_train_data(-1)
    test = mss.get_eval_data(-1)

    au_roc = []
    au_prc = []

    for cost in costs:
        #create mock param object by freezable struct
        param = Options()
        param.kernel = "WeightedDegreeStringKernel"
        param.wdk_degree = 10
        param.transform = cost
        param.base_similarity = 1.0
        param.taxonomy = mss.taxonomy
        param.id = 666

        #param.cost = cost
        param.cost = 10000
        param.freeze()

        # train
        mymethod = Method(param)
        mymethod.train(train)

        assessment = mymethod.evaluate(test)

        au_roc.append(assessment.auROC)
        au_prc.append(assessment.auPRC)

        print assessment
        assessment.destroySelf()

    pylab.title("auROC")
    pylab.semilogx(costs, au_roc, "-o")

    pylab.show()
    pylab.figure()
    pylab.title("auPRC")
    pylab.semilogx(costs, au_prc, "-o")
    pylab.show()

    return (costs, au_roc, au_prc)