Class TrainingSet<S extends Observation,​T extends Category>

  • Type Parameters:
    S - The type of the observations.
    T - The type of the categories.
    All Implemented Interfaces:
    Serializable, Cloneable, Iterable<net.sf.tweety.commons.util.Pair<S,​T>>, Collection<net.sf.tweety.commons.util.Pair<S,​T>>, Set<net.sf.tweety.commons.util.Pair<S,​T>>

    public class TrainingSet<S extends Observation,​T extends Category>
    extends HashSet<net.sf.tweety.commons.util.Pair<S,​T>>
    A set of observations together with their category.
    Author:
    Matthias Thimm
    See Also:
    Serialized Form
    • Constructor Detail

      • TrainingSet

        public TrainingSet()
    • Method Detail

      • add

        public boolean add​(S obs,
                           T cat)
        Adds the specified elements as a pair to this set if it is not already present. More formally, adds the specified element e to this set if this set contains no element e2 such that (e==null ? e2==null : e.equals(e2)). If this set already contains the element, the call leaves the set unchanged and returns false.
        Parameters:
        obs - some observation
        cat - the category of the observation.
        Returns:
        see above.
      • getCategories

        public Collection<T> getCategories()
        Returns the collection of categories present in this training set.
        Returns:
        a set of categories.
      • getObservations

        public TrainingSet<S,​T> getObservations​(T cat)
        Returns all observations of the given category.
        Parameters:
        cat - a category
        Returns:
        all observations of the given category.
      • toLibsvmProblem

        public libsvm.svm_problem toLibsvmProblem()
        Returns a svm_problem (the data data model of libsvm) of this training set.
        Returns:
        a svm_problem (the data data model of libsvm) of this training set.