Class SparseDyadRankingInstance
- java.lang.Object
-
- ai.libs.jaicore.ml.dyadranking.dataset.ADyadRankingInstance
-
- ai.libs.jaicore.ml.dyadranking.dataset.SparseDyadRankingInstance
-
- All Implemented Interfaces:
IAttributeArrayInstance,ILabeledInstance<IDyadRankingInstance>,INumericArrayInstance,IDyadRankingInstance,java.lang.Iterable<Dyad>,org.apache.commons.math3.ml.clustering.Clusterable
public class SparseDyadRankingInstance extends ADyadRankingInstance implements INumericArrayInstance
A dyad ranking instance implementation that assumes the same instance for all dyads contained in its ordering. It saves the instance and alternatives separately and contstructs dyads from them on request.
-
-
Constructor Summary
Constructors Constructor Description SparseDyadRankingInstance(ai.libs.jaicore.math.linearalgebra.Vector instance, java.util.List<ai.libs.jaicore.math.linearalgebra.Vector> alternatives)Construct a new sparse dyad ranking instance containing the given instance vector and ordering of alternatives.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)IAttributeValue<?>[]getAllAttributeValues()double[]getAsDoubleVector()Turns the instance into a double vector.IAttributeValue<java.lang.Double>getAttributeValue(int position)<T> IAttributeValue<T>getAttributeValueAtPosition(int position, java.lang.Class<T> type)Getter for the value of an attribute for the given position.DyadgetDyadAtPosition(int position)Get the dyad at the specified position in the ordering contained in this instance.intgetNumberOfAttributes()Getter for the number of attributes for the instance.SparseDyadRankingInstancegetTargetValue()Getter for the value of the target attribute.inthashCode()java.util.Iterator<Dyad>iterator()intlength()Get the number of dyads in the ranking.java.lang.StringtoString()-
Methods inherited from class ai.libs.jaicore.ml.dyadranking.dataset.ADyadRankingInstance
toMatrix
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ai.libs.jaicore.ml.core.dataset.INumericArrayInstance
getPoint
-
-
-
-
Constructor Detail
-
SparseDyadRankingInstance
public SparseDyadRankingInstance(ai.libs.jaicore.math.linearalgebra.Vector instance, java.util.List<ai.libs.jaicore.math.linearalgebra.Vector> alternatives)Construct a new sparse dyad ranking instance containing the given instance vector and ordering of alternatives.- Parameters:
instance- the instance for all of the alternativesalternatives- the ordering of alternatives that, when combined with the instances is an ordering of dyads
-
-
Method Detail
-
getAttributeValueAtPosition
public <T> IAttributeValue<T> getAttributeValueAtPosition(int position, java.lang.Class<T> type)
Description copied from interface:IAttributeArrayInstanceGetter for the value of an attribute for the given position.- Specified by:
getAttributeValueAtPositionin interfaceIAttributeArrayInstance- Parameters:
position- The position of the attribute within the instance.type- The type for which the attribute value shall be returned.- Returns:
- The attribute value for the position.
-
getTargetValue
public SparseDyadRankingInstance getTargetValue()
Description copied from interface:ILabeledInstanceGetter for the value of the target attribute.- Specified by:
getTargetValuein interfaceILabeledInstance<IDyadRankingInstance>- Returns:
- The value of the traget attribute.
-
getAsDoubleVector
public double[] getAsDoubleVector() throws ContainsNonNumericAttributesExceptionDescription copied from interface:INumericArrayInstanceTurns the instance into a double vector.- Specified by:
getAsDoubleVectorin interfaceINumericArrayInstance- Returns:
- The instance as a double vector.
- Throws:
ContainsNonNumericAttributesException- Thrown if the instance is to be converted into a double vector and still contains non-numeric attributes.
-
iterator
public java.util.Iterator<Dyad> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<Dyad>
-
getDyadAtPosition
public Dyad getDyadAtPosition(int position)
Description copied from interface:IDyadRankingInstanceGet the dyad at the specified position in the ordering contained in this instance.- Specified by:
getDyadAtPositionin interfaceIDyadRankingInstance- Parameters:
position- The position in the ordering for which to get the dyad- Returns:
- The dyad at the specified position
-
length
public int length()
Description copied from interface:IDyadRankingInstanceGet the number of dyads in the ranking.- Specified by:
lengthin interfaceIDyadRankingInstance- Returns:
- The number of dyads in the ranking.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getAllAttributeValues
public IAttributeValue<?>[] getAllAttributeValues()
- Specified by:
getAllAttributeValuesin interfaceIAttributeArrayInstance
-
getNumberOfAttributes
public int getNumberOfAttributes()
Description copied from interface:IAttributeArrayInstanceGetter for the number of attributes for the instance.- Specified by:
getNumberOfAttributesin interfaceIAttributeArrayInstance- Returns:
- Number of attributes
-
getAttributeValue
public IAttributeValue<java.lang.Double> getAttributeValue(int position)
- Specified by:
getAttributeValuein interfaceINumericArrayInstance
-
-