Exemplo n.º 1
0
 def _train(self, x, labels):
     """Add the sampel points to the classes.
     
     labels -- Can be a list, tuple or array of labels (one for each data
         point) or a single label, in which case all input data is assigned
         to the same class (computationally this is more efficient).
     """
     if isinstance(labels, (list, tuple, numx.ndarray)):
         labels = numx.asarray(labels)
         for label in set(labels):
             x_label = numx.compress(labels == label, x, axis=0)
             self._add_samples(x_label, label)
     else:
         self._add_samples(x, labels)
Exemplo n.º 2
0
 def _train(self, x, labels):
     """Add the sampel points to the classes.
     
     labels -- Can be a list, tuple or array of labels (one for each data
         point) or a single label, in which case all input data is assigned
         to the same class (computationally this is more efficient).
     """
     if isinstance(labels, (list, tuple, numx.ndarray)):
         labels = numx.asarray(labels)
         for label in set(labels):
             x_label = numx.compress(labels == label, x, axis=0)
             self._add_samples(x_label, label)
     else:
         self._add_samples(x, labels)
Exemplo n.º 3
0
 def _train(self, x, labels):
     """Update the mean information for the different classes.
     
     :param x: The data.
     :type x: numpy.ndarray
     :param labels: Can be a list, tuple or array of labels (one for each data
         point) or a single label, in which case all input data is assigned
         to the same class (computationally this is more efficient).
     """
     if isinstance(labels, (list, tuple, numx.ndarray)):
         labels = numx.asarray(labels)
         for label in set(labels):
             x_label = numx.compress(labels == label, x, axis=0)
             self._update_mean(x_label, label)
     else:
         self._update_mean(x, labels)
Exemplo n.º 4
0
 def _train(self, x, labels):
     """
     :param x: Data
     :type x: numpy.ndarray
     :param labels: Can be a list, tuple or array of labels (one for each data point)
         or a single label, in which case all input data is assigned to
         the same class.
     """
     # if labels is a number, all x's belong to the same class
     if isinstance(labels, (list, tuple, numx.ndarray)):
         labels_ = numx.asarray(labels)
         # get all classes from cl
         for lbl in set(labels_):
             x_lbl = numx.compress(labels_ == lbl, x, axis=0)
             self._update_covs(x_lbl, lbl)
     else:
         self._update_covs(x, labels)
Exemplo n.º 5
0
 def _train(self, x, labels):
     """
     :Arguments:
       x
           data
       labels
           Can be a list, tuple or array of labels (one for each data point)
           or a single label, in which case all input data is assigned to
           the same class.
     """
     # if labels is a number, all x's belong to the same class
     if isinstance(labels, (list, tuple, numx.ndarray)):
         labels_ = numx.asarray(labels)
         # get all classes from cl
         for lbl in set(labels_):
             x_lbl = numx.compress(labels_ == lbl, x, axis=0)
             self._update_covs(x_lbl, lbl)
     else:
         self._update_covs(x, labels)