def test_classif_simple(self):
     """ test the training of classif with expected F1 score close to one """
     data_train, labels_train = generate_data()
     data_test, labels_test = generate_data()
     for n in CLASSIFIER_NAMES:
         logging.info('created classifier: %s', n)
         clf = create_classifiers()[n]
         clf.fit(data_train, labels_train)
         self.classif_eval(clf, data_train, labels_train, data_test, labels_test)
Copyright (C) 2014-2018 Jiri Borovec <*****@*****.**>
"""

import logging
import os
import sys
import unittest

import numpy as np
from sklearn import metrics

sys.path.append(os.path.abspath(os.path.join('..', '..')))  # Add path to root
from imsegm.classification import create_classif_search_train_export, create_classifiers

CLASSIFIER_NAMES = create_classifiers().keys()


def generate_data(nb_samples=100, nb_classes=3, dim_features=4):
    """ generating separable features pace with specific number of classes,
    samples per class and feature dimension

    :param int nb_samples: number of samples per class
    :param int dim_features: dimension of feature space
    :param int nb_classes: number of classes
    :return tuple(list(int),ndarray): list(int), np.array<nb_samples, dim_fts>
    """
    labels = range(int(nb_classes))
    labels = list(labels) * nb_samples
    # noise around zero
    noise = np.random.rand(len(labels), dim_features) - 0.5
示例#3
0
Copyright (C) 2014-2018 Jiri Borovec <*****@*****.**>
"""

import os
import sys
import unittest
import logging

import numpy as np
from sklearn import metrics

sys.path.append(os.path.abspath(os.path.join('..', '..')))  # Add path to root
import imsegm.classification as seg_clf

CLASSIFIER_NAMES = seg_clf.create_classifiers().keys()


def generate_data(nb_samples=100, nb_classes=3, dim_fts=4):
    """ generating separable features pace with specific number of classes,
    samples per class and feature dimension

    :param nb_samples: int, number of samples per class
    :param dim_fts: int, dimension of feature space
    :param nb_classes: int, number of classes
    :return: [int], np.array<nb_samples, dim_fts>
    """
    labels = range(int(nb_classes))
    labels = list(labels) * nb_samples
    # noise around zero
    noise = np.random.rand(len(labels), dim_fts) - 0.5