Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)