程序包 weka.core
类 BinarySparseInstance
java.lang.Object
weka.core.Instance
weka.core.SparseInstance
weka.core.BinarySparseInstance
- 所有已实现的接口:
Serializable
,Copyable
,RevisionHandler
Class for storing a binary-data-only instance as a sparse vector. A
sparse instance only requires storage for those attribute values
that are non-zero. Since the objective is to reduce storage
requirements for datasets with large numbers of default values,
this also includes nominal attributes -- the first nominal value
(i.e. that which has index 0) will not require explicit storage, so
rearrange your nominal attribute value orderings if
necessary. Missing values are not supported, and will be treated as
1 (true).
- 版本:
- $Revision: 1.13 $
- 另请参阅:
-
构造器概要
构造器构造器说明BinarySparseInstance
(double weight, double[] attValues) Constructor that generates a sparse instance from the given parameters.BinarySparseInstance
(double weight, int[] indices, int maxNumValues) Constructor that inititalizes instance variable with given values.BinarySparseInstance
(int numAttributes) Constructor of an instance that sets weight to one, all values to 1, and the reference to the dataset to null.BinarySparseInstance
(Instance instance) Constructor that generates a sparse instance from the given instance.BinarySparseInstance
(SparseInstance instance) Constructor that copies the info from the given instance. -
方法概要
修饰符和类型方法说明copy()
Produces a shallow copy of this instance.Returns the revision string.static void
Main method for testing this class.mergeInstance
(Instance inst) Merges this instance with the given instance and returns the result.void
replaceMissingValues
(double[] array) Does nothing, since we don't support missing values.void
setValue
(int attIndex, double value) Sets a specific value in the instance to the given value (internal floating-point format).void
setValueSparse
(int indexOfIndex, double value) Sets a specific value in the instance to the given value (internal floating-point format).double[]
Returns the values of each attribute as an array of doubles.toString()
Returns the description of one instance in sparse format.double
value
(int attIndex) Returns an instance's attribute value in internal format.final double
valueSparse
(int indexOfIndex) Returns an instance's attribute value in internal format.从类继承的方法 weka.core.SparseInstance
attributeSparse, index, isMissing, locateIndex, numAttributes, numValues
从类继承的方法 weka.core.Instance
attribute, classAttribute, classIndex, classIsMissing, classValue, dataset, deleteAttributeAt, enumerateAttributes, equalHeaders, hasMissingValue, insertAttributeAt, isMissing, isMissingSparse, isMissingValue, missingValue, numClasses, relationalValue, relationalValue, setClassMissing, setClassValue, setClassValue, setDataset, setMissing, setMissing, setValue, setValue, setValue, setWeight, stringValue, stringValue, toString, toString, value, weight
-
构造器详细资料
-
BinarySparseInstance
Constructor that generates a sparse instance from the given instance. Reference to the dataset is set to null. (ie. the instance doesn't have access to information about the attribute types)- 参数:
instance
- the instance from which the attribute values and the weight are to be copied
-
BinarySparseInstance
Constructor that copies the info from the given instance. Reference to the dataset is set to null. (ie. the instance doesn't have access to information about the attribute types)- 参数:
instance
- the instance from which the attribute info is to be copied
-
BinarySparseInstance
public BinarySparseInstance(double weight, double[] attValues) Constructor that generates a sparse instance from the given parameters. Reference to the dataset is set to null. (ie. the instance doesn't have access to information about the attribute types)- 参数:
weight
- the instance's weightattValues
- a vector of attribute values
-
BinarySparseInstance
public BinarySparseInstance(double weight, int[] indices, int maxNumValues) Constructor that inititalizes instance variable with given values. Reference to the dataset is set to null. (ie. the instance doesn't have access to information about the attribute types)- 参数:
weight
- the instance's weightindices
- the indices of the given values in the full vectormaxNumValues
- the maximium number of values that can be stored
-
BinarySparseInstance
public BinarySparseInstance(int numAttributes) Constructor of an instance that sets weight to one, all values to 1, and the reference to the dataset to null. (ie. the instance doesn't have access to information about the attribute types)- 参数:
numAttributes
- the size of the instance
-
-
方法详细资料
-
copy
Produces a shallow copy of this instance. The copy doesn't have access to a dataset.- 指定者:
copy
在接口中Copyable
- 覆盖:
copy
在类中SparseInstance
- 返回:
- the shallow copy
-
mergeInstance
Merges this instance with the given instance and returns the result. Dataset is set to null.- 覆盖:
mergeInstance
在类中SparseInstance
- 参数:
inst
- the instance to be merged with this one- 返回:
- the merged instances
-
replaceMissingValues
public void replaceMissingValues(double[] array) Does nothing, since we don't support missing values.- 覆盖:
replaceMissingValues
在类中SparseInstance
- 参数:
array
- containing the means and modes
-
setValue
public void setValue(int attIndex, double value) Sets a specific value in the instance to the given value (internal floating-point format). Performs a deep copy of the vector of attribute values before the value is set.- 覆盖:
setValue
在类中SparseInstance
- 参数:
attIndex
- the attribute's indexvalue
- the new attribute value (If the corresponding attribute is nominal (or a string) then this is the new value's index as a double).
-
setValueSparse
public void setValueSparse(int indexOfIndex, double value) Sets a specific value in the instance to the given value (internal floating-point format). Performs a deep copy of the vector of attribute values before the value is set.- 覆盖:
setValueSparse
在类中SparseInstance
- 参数:
indexOfIndex
- the index of the attribute's indexvalue
- the new attribute value (If the corresponding attribute is nominal (or a string) then this is the new value's index as a double).
-
toDoubleArray
public double[] toDoubleArray()Returns the values of each attribute as an array of doubles.- 覆盖:
toDoubleArray
在类中SparseInstance
- 返回:
- an array containing all the instance attribute values
-
toString
Returns the description of one instance in sparse format. If the instance doesn't have access to a dataset, it returns the internal floating-point values. Quotes string values that contain whitespace characters.- 覆盖:
toString
在类中SparseInstance
- 返回:
- the instance's description as a string
-
value
public double value(int attIndex) Returns an instance's attribute value in internal format.- 覆盖:
value
在类中SparseInstance
- 参数:
attIndex
- the attribute's index- 返回:
- the specified value as a double (If the corresponding attribute is nominal (or a string) then it returns the value's index as a double).
-
valueSparse
public final double valueSparse(int indexOfIndex) Returns an instance's attribute value in internal format. Does exactly the same thing as value() if applied to an Instance.- 覆盖:
valueSparse
在类中Instance
- 参数:
indexOfIndex
- the index of the attribute's index- 返回:
- the specified value as a double (If the corresponding attribute is nominal (or a string) then it returns the value's index as a double).
-
main
Main method for testing this class.- 参数:
options
- the command line options - ignored
-
getRevision
Returns the revision string.- 指定者:
getRevision
在接口中RevisionHandler
- 覆盖:
getRevision
在类中SparseInstance
- 返回:
- the revision
-