def compareTwoSets(self, listOfSets, otherListOfSets,
                       comparisonMethodConfig):
        # type: (object, object, object) -> SetsComparisonResult
        """Copares all of sets in the list (each with each) using comparison method
        defined in <code>comparisonMethodConfig</code>
        :param ID - unique ID of this sets comparison 
        :return SetsComparisonResult object"""
        print "Comparing {} fuzzy sets against each other".format(
            len(listOfSets))
        numberOfSets = len(listOfSets)
        similarityCalculatorWrapper = SimilarityCalculatorFacade()
        setsComparisonResultBuilder = SetsComparisonResultBuilder(listOfSets, otherListOfSets) \
            .withConfig(comparisonMethodConfig)
        for i in range(numberOfSets):
            for j in range(i, len(otherListOfSets)):
                A = listOfSets[i]
                B = otherListOfSets[j]
                result = similarityCalculatorWrapper.calculateSimilarityFromParsedConfig(
                    A, B, comparisonMethodConfig)
                setsComparisonResultBuilder.withResultEntry((i, j), result)

        return setsComparisonResultBuilder.build()
class MethodsComparator(object):
    """Class that compares two sets using N similarity measures"""
    def __init__(self):
        self.similarityCalculatorWrapper = SimilarityCalculatorFacade()

    def compareTwoSetsUsingMultipleMethods(self, A, B,
                                           listOfMethodsConfigurations):
        """
        Compare two sets using N similarity calculation methods
        :param A: first fuzzy set
        :param B: second fuzzy set
        :param listOfMethodsConfigurations: list of configurations of Similarity Calculators
        :return: MethodsComparisonResult object representing result
        """
        resultBuilder = MethodsComparisonResultBuilder(
            A, B, listOfMethodsConfigurations)
        for index, config in enumerate(listOfMethodsConfigurations):
            result = self.similarityCalculatorWrapper.calculateSimilarityFromParsedConfig(
                A, B, config)
            resultBuilder.addResultEntry(index, result)

        return resultBuilder.build()
from fuzzyfacades.similarity_calculator_wrapper import SimilarityCalculatorFacade
from utils import fileparser
from comparators.resultprocessors.setscomparison.console_comparison_result_processor import ConsoleComparisonResultProcessor
from comparators.resultprocessors.setscomparison.result_processor_factory import ResultProcessorFactory
from comparators.sets_comparator import SetsComparator

# Script that calculate similarity of N sets using method defined in confifuration passed as separate file
DEFAULT_SETS_FILE_NAME = "sets.txt"

DEFAULT_CONFIG_FILE_NAME = "config.txt"

DEFAULT_RESULT_FILE_NAME = 'comparison-result.xlsx'

configurationParser = ConfigurationParser()

similarityCalculatorWrapper = SimilarityCalculatorFacade()

resultProcessorFactory = ResultProcessorFactory()

setsComparator = SetsComparator()

parser = argparse.ArgumentParser(
    description=
    'Tool for calculating similarity between number of sets using one similarity method'
    +
    'Sets must be defined in file, each set in separate line, each set element followed by blank character. '
    +
    'This script uses configuration defined in first line of configuration file.'
)
parser.add_argument(
    '-s',
 def __init__(self):
     self.similarityCalculatorWrapper = SimilarityCalculatorFacade()
Esempio n. 5
0
A = [
    0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.45, 0.4,
    0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0.0
]
B = [
    0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 0.9, 0.8, 0.7, 0.6,
    0.5, 0.4, 0.3, 0.2, 0.1, 0.0
]

similarity = minkowksiSimilarityMeasure.calculateSimilarity(
    A, B, configuration)
print "Similarity: {}".format(similarity)

from fuzzyfacades.similarity_calculator_wrapper import SimilarityCalculatorFacade

similarityCalculatorFacade = SimilarityCalculatorFacade()
A = [0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3]
B = [0.0, 0.10, 0.2, 0.31, 0.4, 0.55, 0.6]

similarityMethods = [{
    'method': 'minkowski',
    'r': 1
}, {
    'method': 'minkowski',
    'r': 2
}]

for method in similarityMethods:
    similarity = similarityCalculatorFacade \
        .calculateSimilarityFromRawConfig(A, B, method)
    print "Similarity for method {}: {}".format(method, similarity)