Пример #1
0
def static_k_semisynthetic_test_paper_2():
    console.write_header("Loading Native symbols")
    symbolClasses = loader.load_native_xls()
    console.write_header("Loading Foreign symbols")
    foreignClasses = loader.load_foreign_xls()

    util.global_variables.CLASS_NUM = len(symbolClasses)
    util.global_variables.CHAR_NUM = len(symbolClasses[0].learning_set[0].characteristicsValues)
    

    Clusterer().computeClusters(symbolClasses)

    paper2.compute(symbolClasses, foreignClasses)
Пример #2
0
def real_data():
    console.write_header("Loading Native symbols")
    symbolClasses = loader.load_native_xls()
    console.write_header("Loading Foreign symbols")
    foreignClasses = loader.load_foreign_xls()

    util.global_variables.CLASS_NUM = len(symbolClasses)
    util.global_variables.CHAR_NUM = len(symbolClasses[0].learning_set[0].characteristicsValues)
    
    for c in range(0, util.global_variables.CLASS_NUM):
        console.write_header("Computing Cluster Evaluation")
        best_k = ps.cluster_evaluation(util.global_variables.MAX_K_CLUS_EVALUATION, symbolClasses[c:c+1])
        util.global_variables.K = best_k[0]
        console.write_header("Computing Clusters with K:", str(util.global_variables.K))
        Clusterer().computeClusters(symbolClasses[c:c+1])
        
    console.write_header(" Synthetic Data Calculations")
    synth_calc.ambiguity_for_different_radiuses_real_data(symbolClasses[:], foreignClasses)
Пример #3
0
def synthetic_test_paper_2():
    # CREATE CHAR_NUM CHARACTERISTICS
    console.write_header("Creating Characteristics")
    characteristics = []
    data.generate_characteristic(characteristics)

    # CREATE CLASS_NUM SYMBOL CLASSES
    console.write_header(" Creating Symbol Classes")
    symbolClasses = []
    data.generate_symbol_classes(symbolClasses, characteristics)

    # CREATE CLOUD DISTORTION IN NATIVE SET
    console.write_header("Computing K cloud Distortion")
    Distorter().create_cluster_assessment_cloud(util.global_variables.K_CLOUD_DISTORTION,symbolClasses)
    #Distorter().create_k_clouds(util.global_variables.K_CLOUD_DISTORTION,symbolClasses)

    util.global_variables.K = 2

    Clusterer().computeClusters(symbolClasses[:])
    Plot3D().renderPlot(symbolClasses)

    util.global_variables.K = 1

    Clusterer().computeClusters(symbolClasses[:])
    Plot3D().renderPlot(symbolClasses)

    util.global_variables.K = 3

    Clusterer().computeClusters(symbolClasses[:])
    Plot3D().renderPlot(symbolClasses)
Пример #4
0
def semisynthetic_test_paper_1():
    console.write_header("Loading Native symbols")
    symbolClasses = loader.load_native_xls()
    console.write_header("Loading Foreign symbols")
    foreignClasses = loader.load_foreign_xls()

    util.global_variables.CLASS_NUM = len(symbolClasses)
    util.global_variables.CHAR_NUM = len(symbolClasses[0].learning_set[0].characteristicsValues)
           
    # CREATE ELLIPSOIDS AND CUBOIDS FOR EACH LEARNING SET
    console.write_header("Generating Convex and Compact Sets")
    membership = BasicMembership(symbolClasses, False)
    membership.shrink_objects(0)  # just to write to he file
    

    
    for i in range(0,5):
        # Check native
        membership.check_natives_ellipsoid_proper(symbolClasses[:],"foreign_REAL","foreign_REAL")
        membership.check_natives_cuboid_proper(symbolClasses[:],"foreign_REAL","foreign_REAL")  
        # Check foreign
        membership.check_foreign_ellipsoid(foreignClasses,      "foreign_REAL")
        membership.check_foreign_cuboids(foreignClasses,     "foreign_REAL")
        # Shrink
        if i != 4:
            membership.shrink_objects(5)
Пример #5
0
def grouping_assessment():
    # CREATE CHAR_NUM CHARACTERISTICS
    console.write_header("Creating Characteristics")
    characteristics = []
    data.generate_characteristic(characteristics)
    
    # CREATE CLASS_NUM SYMBOL CLASSES
    console.write_header(" Creating Symbol Classes")
    symbolClasses = []
    data.generate_symbol_classes(symbolClasses, characteristics)
    
    console.write_header("Computing K cloud Distortion")
    #Distorter().create_k_clouds(util.global_variables.K_CLOUD_DISTORTION,symbolClasses)
    Distorter().create_non_homogeneus_cloud(symbolClasses)
    console.write_header("Computing Cluster Evaluation")
    ps.cluster_evaluation(util.global_variables.MAX_K_CLUS_EVALUATION,symbolClasses)
Пример #6
0
def semisynthetic_test_paper_2():
    console.write_header("Loading Native symbols")
    symbolClasses = loader.load_native_xls()
    console.write_header("Loading Foreign symbols")
    foreignClasses = loader.load_foreign_xls()

    util.global_variables.CLASS_NUM = len(symbolClasses)
    util.global_variables.CHAR_NUM = len(symbolClasses[0].learning_set[0].characteristicsValues)
    
    # COMPUTE CLUSTER EVALUATION
    for c in range(0, util.global_variables.CLASS_NUM):
        console.write_header("Computing Cluster Evaluation")
        best_k = ps.cluster_evaluation(util.global_variables.MAX_K_CLUS_EVALUATION, symbolClasses[c:c+1])
        util.global_variables.K = best_k[0]
        console.write_header("Computing Clusters with K:", str(util.global_variables.K))
        Clusterer().computeClusters(symbolClasses[c:c+1])

    paper2.compute(symbolClasses, foreignClasses)
Пример #7
0
def full_test():
    # CREATE CHAR_NUM CHARACTERISTICS
    console.write_header("Creating Characteristics")
    characteristics = []
    data.generate_characteristic(characteristics)
    
    # CREATE CLASS_NUM SYMBOL CLASSES
    console.write_header(" Creating Symbol Classes")
    symbolClasses = []
    data.generate_symbol_classes(symbolClasses, characteristics)
    
    console.write_header("Computing Homogeneous Distortion")
    Distorter().create_homogeneus_cloud(symbolClasses)

    for c in range(0, util.global_variables.CLASS_NUM):
        console.write_header("Computing Cluster Evaluation")
        best_k = ps.cluster_evaluation(util.global_variables.MAX_K_CLUS_EVALUATION, symbolClasses[c:c+1])
        util.global_variables.K = best_k[0]
        console.write_header("Computing Clusters with K:", str(util.global_variables.K))
        Clusterer().computeClusters(symbolClasses[c:c+1])

    console.write_header("Creating Non Homogeneous Foreign")
    foreignClassesNonHomo = f_creator.create_non_homogeneous_foreign(symbolClasses)
    console.write_header("Creating Homogeneous Foreign")
    foreignClassesHomo = f_creator.create_homogeneous_foreign(symbolClasses, characteristics)
    console.write_header(" Synthetic Data Calculations")
    synth_calc.ambiguity_for_different_radiuses(symbolClasses[:], foreignClassesHomo, foreignClassesNonHomo)
Пример #8
0
def synthetic_homo_native():
    # CREATE CHAR_NUM CHARACTERISTICS
    console.write_header("Creating Characteristics")
    characteristics = []
    data.generate_characteristic(characteristics)
    
    # CREATE CLASS_NUM SYMBOL CLASSES
    console.write_header(" Creating Symbol Classes")
    symbolClasses = []
    data.generate_symbol_classes(symbolClasses, characteristics)
    
    # Distortion
    console.write_header("Computing Homogeneous Distortion")
    Distorter().create_homogeneus_cloud(symbolClasses)
    # Clustering
    console.write_header("Computing Clusters")
    Clusterer().computeClusters(symbolClasses[:util.global_variables.CLASS_NUM])
    # Plot3D
    console.write_header(" Displaying Plot")
    Plot3D().renderPlot(symbolClasses[:util.global_variables.CLASS_NUM])
    # Generating Foreign classes
    console.write_header("Creating Non Homogeneous Foreign")
    foreignClassesNonHomo = f_creator.create_non_homogeneous_foreign(symbolClasses)
    console.write_header("Creating Homogeneous Foreign")
    foreignClassesHomo = f_creator.create_homogeneous_foreign(symbolClasses, characteristics)
    # Radiuses 
    console.write_header(" Synthetic Data Calculations")
    synth_calc.ambiguity_for_different_radiuses(symbolClasses[:], foreignClassesHomo, foreignClassesNonHomo)
Пример #9
0
def synthetic_test_paper_1():
    # CREATE CHAR_NUM CHARACTERISTICS
    console.write_header("Creating Characteristics")
    characteristics = []
    data.generate_characteristic(characteristics)
    
    # CREATE CLASS_NUM SYMBOL CLASSES
    console.write_header(" Creating Symbol Classes")
    symbolClasses = []
    data.generate_symbol_classes(symbolClasses, characteristics)

    # DISTORTION (UNIFORM)
    console.write_header("Computing Homogeneous Distortion")
    Distorter().create_homogeneus_cloud(symbolClasses)
    
    # FOREIGN HOMOGENEOUS
    console.write_header("Creating Homogeneous Foreign")
    foreignClassesHomo = f_creator.create_homogeneous_foreign(symbolClasses, characteristics)
    
    # FOREIGN NON-HOMOGENEOUS
    console.write_header("Creating Non Homogeneous Foreign")
    foreignClassesNonHomo = f_creator.create_non_homogeneous_foreign(symbolClasses)

    # CREATE ELLIPSOIDS AND CUBOIDS FOR EACH LEARNING SET
    console.write_header("Generating Convex and Compact Sets")
    membership = BasicMembership(symbolClasses)
    membership.shrink_objects(0)  # just to write to he file
        
    plot = Plot2D()
    plot.renderPlot(symbolClasses, membership, ObjectType.ELLIPSOID)
    plot.renderPlot(symbolClasses, membership, ObjectType.CUBOID)
    
    for i in range(0,5):
        # Check native
        membership.check_natives_ellipsoid_proper(symbolClasses[:],"foreign_homo","foreign_non_homo")
        membership.check_natives_cuboid_proper(symbolClasses[:],"foreign_homo","foreign_non_homo") 
        # Check foreign
        membership.check_foreign_ellipsoid(foreignClassesHomo,      "foreign_homo")
        membership.check_foreign_ellipsoid(foreignClassesNonHomo,   "foreign_non_homo")
        membership.check_foreign_cuboids(foreignClassesHomo,        "foreign_homo")
        membership.check_foreign_cuboids(foreignClassesNonHomo,     "foreign_non_homo")
        # Shrink
        if i != 4:
            membership.shrink_objects(5)
            plot.renderPlot(symbolClasses, membership, ObjectType.ELLIPSOID)
            plot.renderPlot(symbolClasses, membership, ObjectType.CUBOID)
Пример #10
0
import util.console as console
import sys
# CHECK ARGUMENTS
console.parse_argv(sys.argv[1:])

import util.global_variables 
import test_templates as tests

# RUN CONFIGS
console.write_header("Run configuration")
console.print_config()

'''
    Native symbols: synthetic; homogeneous; 
    Foreign symbols: synthetic; homogeneous and non-homogeneous
'''
if util.global_variables.TEST_TYPE == util.global_variables.TestType.SYNTHETIC_HOMO_NATIVE:
    tests.synthetic_homo_native()

if util.global_variables.TEST_TYPE == util.global_variables.TestType.GROUPING_ASSESSMENT:
    tests.grouping_assessment()

if util.global_variables.TEST_TYPE == util.global_variables.TestType.FULL:
    tests.full_test()
    
if util.global_variables.TEST_TYPE == util.global_variables.TestType.REAL_DATA:
    tests.real_data()

if util.global_variables.TEST_TYPE == util.global_variables.TestType.REAL_DATA_STATIC_K:
    tests.real_data_static_k()