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<Pair<S,
,T>> Collection<Pair<S,
,T>> Set<Pair<S,
T>>
A set of observations together with their category.
- Author:
- Matthias Thimm
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds the specified elements as a pair to this set if it is not already present.Returns the collection of categories present in this training set.getObservations
(T cat) Returns all observations of the given category.loadLibsvmTrainingFile
(File file) Loads a training file in LIBSVM syntaxlibsvm.svm_problem
Returns a svm_problem (the data data model of libsvm) of this training set.Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, newHashSet, remove, size, spliterator, toArray, toArray
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toString
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
TrainingSet
public TrainingSet()Default Constructor
-
-
Method Details
-
add
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 observationcat
- the category of the observation.- Returns:
- see above.
-
getCategories
Returns the collection of categories present in this training set.- Returns:
- a set of categories.
-
getObservations
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.
-
loadLibsvmTrainingFile
public static TrainingSet<DefaultObservation,DoubleCategory> loadLibsvmTrainingFile(File file) throws NumberFormatException, IOException Loads a training file in LIBSVM syntax- Parameters:
file
- some file- Returns:
- a training set.
- Throws:
IOException
- if some IO exception occurs.NumberFormatException
- if the format of the file is not valid.
-