Class NominalStats
java.lang.Object
es.uam.eps.ir.ranksys.core.util.Stats
es.uam.eps.ir.relison.links.data.letor.NominalStats
public class NominalStats
extends es.uam.eps.ir.ranksys.core.util.Stats
Statistics values for nominal features.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.Long>counterCounts the number of values for each nominal value.private it.unimi.dsi.fastutil.doubles.Double2IntMapindexMaps doubles to integers.private java.util.List<java.lang.Double>listMaps integers to doubles.private intnumValuesNumber of different values for the attribute. -
Constructor Summary
Constructors Constructor Description NominalStats()Constructor. -
Method Summary
Modifier and Type Method Description voidaccept(double value)voidcombine(es.uam.eps.ir.ranksys.core.util.Stats stats)longgetCount(double value)Obtains the number of elements for some nominal value.longgetCount(int idx)Obtains the number of times that the i-th nominal value has appeared in the collection.intgetNumValues()Obtains the number of different values for the feature.doublegetProportion(double value)Obtains the proportion of the examples which have the given nominal value for the corresponding parameter.doublegetProportion(int idx)Obtains the proportion of the examples which have the i-th nominal value for the corresponding parameter.doublegetValue(int idx)Obtains the value of the i-th nominal value.java.util.List<java.lang.Double>getValues()Obtains the different possible values for the features.intindexOfValue(double value)Obtains the index for some value.voidreset()
-
Field Details
-
counter
private final java.util.List<java.lang.Long> counterCounts the number of values for each nominal value. -
index
private final it.unimi.dsi.fastutil.doubles.Double2IntMap indexMaps doubles to integers. -
list
private final java.util.List<java.lang.Double> listMaps integers to doubles. -
numValues
private int numValuesNumber of different values for the attribute.
-
-
Constructor Details
-
NominalStats
public NominalStats()Constructor.
-
-
Method Details
-
accept
public void accept(double value)- Overrides:
acceptin classes.uam.eps.ir.ranksys.core.util.Stats
-
combine
public void combine(es.uam.eps.ir.ranksys.core.util.Stats stats)- Overrides:
combinein classes.uam.eps.ir.ranksys.core.util.Stats
-
reset
public void reset()- Overrides:
resetin classes.uam.eps.ir.ranksys.core.util.Stats
-
getNumValues
public int getNumValues()Obtains the number of different values for the feature.- Returns:
- the number of different values for the feature.
-
getValues
public java.util.List<java.lang.Double> getValues()Obtains the different possible values for the features.- Returns:
- the values for the features.
-
getValue
public double getValue(int idx)Obtains the value of the i-th nominal value.- Parameters:
idx- index for the value.- Returns:
- the value if it exists, NaN otherwise
-
indexOfValue
public int indexOfValue(double value)Obtains the index for some value.- Parameters:
value- the value.- Returns:
- the index if it exists, -1 otherwise.
-
getCount
public long getCount(int idx)Obtains the number of times that the i-th nominal value has appeared in the collection.- Parameters:
idx- the index of the nominal value.- Returns:
- the index of the nominal value.
-
getCount
public long getCount(double value)Obtains the number of elements for some nominal value.- Parameters:
value- the nominal value.- Returns:
- the numbe of elements for that value.
-
getProportion
public double getProportion(int idx)Obtains the proportion of the examples which have the i-th nominal value for the corresponding parameter.- Parameters:
idx- the index of the nominal value.- Returns:
- the corresponding proportion.
-
getProportion
public double getProportion(double value)Obtains the proportion of the examples which have the given nominal value for the corresponding parameter.- Parameters:
value- the nominal value.- Returns:
- the corresponding proportion, NaN if something failed.
-