Package net.sf.tweety.machinelearning
Class TrainingSet<S extends Observation,T extends Category>
- java.lang.Object
 - 
- java.util.AbstractCollection<E>
 - 
- java.util.AbstractSet<E>
 - 
- java.util.HashSet<Pair<S,T>>
 - 
- net.sf.tweety.machinelearning.TrainingSet<S,T>
 
 
 
 
 
- 
- Type Parameters:
 S- The type of the observations.T- The type of the categories.
- All Implemented Interfaces:
 java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<Pair<S,T>>,java.util.Collection<Pair<S,T>>,java.util.Set<Pair<S,T>>
public class TrainingSet<S extends Observation,T extends Category> extends java.util.HashSet<Pair<S,T>>
A set of observations together with their category.- Author:
 - Matthias Thimm
 - See Also:
 - Serialized Form
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUIDFor serialization. 
- 
Constructor Summary
Constructors Constructor Description TrainingSet() 
- 
Method Summary
Modifier and Type Method Description booleanadd(S obs, T cat)Adds the specified elements as a pair to this set if it is not already present.java.util.Collection<T>getCategories()Returns the collection of categories present in this training set.TrainingSet<S,T>getObservations(T cat)Returns all observations of the given category.static TrainingSet<DefaultObservation,DoubleCategory>loadLibsvmTrainingFile(java.io.File file)Loads a training file in LIBSVM syntaxlibsvm.svm_problemtoLibsvmProblem()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, remove, size, spliterator 
- 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString 
 - 
 
 - 
 
- 
- 
Field Detail
- 
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
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 observationcat- the category of the observation.- Returns:
 - see above.
 
 
- 
getCategories
public java.util.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.
 
 
- 
loadLibsvmTrainingFile
public static TrainingSet<DefaultObservation,DoubleCategory> loadLibsvmTrainingFile(java.io.File file) throws java.lang.NumberFormatException, java.io.IOException
Loads a training file in LIBSVM syntax- Parameters:
 file- some file- Returns:
 - a training set.
 - Throws:
 java.io.IOException- if some IO exception occurs.java.lang.NumberFormatException- if the format of the file is not valid.
 
 - 
 
 -