Example #1
0
    def process_data(self, classification_dict):
        """
        Create and fill 3 list described in return section

        :param classification_dict: filled dictionary with min, max, avg classification probabilities, counter and class value
        :return: 3 list -> data (classification probabilities), Y (class values), metas (file names)
        """

        metas, data, Y = [], [], []

        for key, value in classification_dict.items():

            class_value = None
            tmp_data = []

            for x, y in value.items():
                tmp_data += [y[1], y[2], y[0] / float(y[3])]
                class_value = y[-1]

            if(class_value not in self.discrete_atributes):
                self.discrete_atributes.append(class_value)
                Y.append(self.discrete_atributes.index(class_value))
            else:
                Y.append(self.discrete_atributes.index(class_value))

            metas.append([key])
            data.append(tmp_data)

        return numpy.array(data), numpy.array(Y), numpy.array(metas)
Example #2
0
def lookup_from_function(class_var, bound, function):
    """
    Construct ClassifierByDataTable or ClassifierByLookupTable
    mirroring the given function.
    
    """
    lookup = lookup_from_bound(class_var, bound)
    if lookup:
        for i, attrs in enumerate(Orange.utils.counters.LimitedCounter([len(var.values) for var in bound])):
            lookup.lookup_table[i] = Orange.data.Value(class_var, function(attrs))
        return lookup
    else:
        dom = Orange.data.Domain(bound, class_var)
        data = Orange.data.Table(dom)
        for attrs in Orange.utils.counters.LimitedCounter([len(var.values) for var in dom.features]):
            data.append(Orange.data.Example(dom, attrs + [function(attrs)]))
        return LookupLearner(data)
Example #3
0
def lookup_from_function(class_var, bound, function):
    """
    Construct ClassifierByDataTable or ClassifierByLookupTable
    mirroring the given function.
    
    """
    lookup = lookup_from_bound(class_var, bound)
    if lookup:
        for i, attrs in enumerate(
                Orange.utils.counters.LimitedCounter(
                    [len(var.values) for var in bound])):
            lookup.lookup_table[i] = Orange.data.Value(class_var,
                                                       function(attrs))
        return lookup
    else:
        dom = Orange.data.Domain(bound, class_var)
        data = Orange.data.Table(dom)
        for attrs in Orange.utils.counters.LimitedCounter(
            [len(var.values) for var in dom.features]):
            data.append(Orange.data.Example(dom, attrs + [function(attrs)]))
        return LookupLearner(data)
Example #4
0
    def _get_data(self, dir_path):
        filecsv_list = []
        for root, dirs, files in os.walk(dir_path):
            for file in files:
                if os.path.splitext(file)[1] == '.csv':
                    filecsv_list.append(os.path.join(root, file))
        data = pd.DataFrame()
        for csv in filecsv_list:
            df_tmp = pd.read_csv(csv, header=0, encoding='utf-8')
            data = data.append(df_tmp, ignore_index=True)

        return data
Example #5
0
    if (firstLine != 1):
        arr = []
        i = 1
        for val in line.split(";"):
            if (i != 15):
                arr.append(float(val))
            elif (i == 15):
                l = int(val)
                leave.append(l)
                if (l == 0):
                    countL0 += 1
                else:
                    countL1 += 1
                countObj += 1
            i += 1
        data.append(arr)
    else:
        firstLine = 0

P = countL0 / countObj

file = open(paramFile, "r")
alg = file.readline().rstrip()
if (alg == "H"):
    Ncluster = int(file.readline())
    metric = file.readline().rstrip()
    link = file.readline().rstrip()
elif (alg == "K"):
    Ncluster = int(file.readline())
    initMeans = file.readline().rstrip()
    algMeans = file.readline().rstrip()