Package moa.streams.filters
Class ReplacingMissingValuesFilter
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.streams.filters.AbstractStreamFilter
-
- moa.streams.filters.ReplacingMissingValuesFilter
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,MOAObject
,OptionHandler
,ExampleStream
,StreamFilter
public class ReplacingMissingValuesFilter extends AbstractStreamFilter
Replaces the missing values with another value according to the selected strategy. Available strategies for numerical attributes are: 1. Nothing: Does nothing (doesn't replace missing values) 2. LastKnownValue: Replaces with the last non missing value 3. Mean: Replaces with mean of the processed instances so far 4. Max: Replaces with maximum of the processed instances so far 5. Min: Replaces with minimum of the processed instances so far 6. Constant: Replaces with a constant value (default: zero) Available strategies for nominal attributes are: 1. Nothing: Does nothing (doesn't replace missing values) 2. LastKnownValue: Replaces with the last non missing value 3. Mode: Replaces with the mode of the processed instances so far (most frequent value) Beware of numerical strategies 2 to 5: if no previous non-missing values were processed, missing values will be replaced by 0.- Author:
- Manuel Martin Salvador <draxus@gmail.com>
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReplacingMissingValuesFilter.MapUtil
-
Field Summary
Fields Modifier and Type Field Description protected double[]
columnsStatistics
protected HashMap<Double,Integer>[]
frequencies
protected double[]
lastNominalValues
MultiChoiceOption
nominalReplacementStrategyOption
protected int
nominalSelectedStrategy
protected int
numAttributes
protected long[]
numberOfSamples
FloatOption
numericalConstantValueOption
protected int
numericalSelectedStrategy
MultiChoiceOption
numericReplacementStrategyOption
-
Fields inherited from class moa.streams.filters.AbstractStreamFilter
inputStream
-
Fields inherited from class moa.options.AbstractOptionHandler
config
-
-
Constructor Summary
Constructors Constructor Description ReplacingMissingValuesFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
getDescription(StringBuilder sb, int indent)
Returns a string representation of this object.InstancesHeader
getHeader()
Gets the header of this stream.String
getPurposeString()
Dictionary with option texts and objectsInstanceExample
nextInstance()
Gets the next example from this stream.protected void
restartImpl()
Restarts this filter.-
Methods inherited from class moa.streams.filters.AbstractStreamFilter
estimatedRemainingInstances, filterInstance, hasMoreInstances, isRestartable, prepareForUseImpl, restart, setInputStream
-
Methods inherited from class moa.options.AbstractOptionHandler
copy, getCLICreationString, getOptions, getPreparedClassOption, prepareClassOptions, prepareForUse, prepareForUse
-
Methods inherited from class moa.AbstractMOAObject
copy, measureByteSize, measureByteSize, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface moa.capabilities.CapabilitiesHandler
getCapabilities
-
Methods inherited from interface moa.streams.ExampleStream
defineImmutableCapabilities
-
Methods inherited from interface moa.MOAObject
measureByteSize
-
-
-
-
Field Detail
-
numericReplacementStrategyOption
public MultiChoiceOption numericReplacementStrategyOption
-
nominalReplacementStrategyOption
public MultiChoiceOption nominalReplacementStrategyOption
-
numericalConstantValueOption
public FloatOption numericalConstantValueOption
-
numAttributes
protected int numAttributes
-
columnsStatistics
protected double[] columnsStatistics
-
numberOfSamples
protected long[] numberOfSamples
-
lastNominalValues
protected double[] lastNominalValues
-
numericalSelectedStrategy
protected int numericalSelectedStrategy
-
nominalSelectedStrategy
protected int nominalSelectedStrategy
-
-
Method Detail
-
getPurposeString
public String getPurposeString()
Description copied from class:AbstractOptionHandler
Dictionary with option texts and objects- Specified by:
getPurposeString
in interfaceOptionHandler
- Overrides:
getPurposeString
in classAbstractOptionHandler
- Returns:
- the string with the purpose of this object
-
getHeader
public InstancesHeader getHeader()
Description copied from interface:ExampleStream
Gets the header of this stream. This is useful to know attributes and classes. InstancesHeader is an extension of weka.Instances.- Returns:
- the header of this stream
-
nextInstance
public InstanceExample nextInstance()
Description copied from interface:ExampleStream
Gets the next example from this stream.- Specified by:
nextInstance
in interfaceExampleStream
- Overrides:
nextInstance
in classAbstractStreamFilter
- Returns:
- the next example of this stream
-
getDescription
public void getDescription(StringBuilder sb, int indent)
Description copied from interface:MOAObject
Returns a string representation of this object. Used inAbstractMOAObject.toString
to give a string representation of the object.- Parameters:
sb
- the stringbuilder to add the descriptionindent
- the number of characters to indent
-
restartImpl
protected void restartImpl()
Description copied from class:AbstractStreamFilter
Restarts this filter. All instances that extends fromAbstractStreamFilter
must implementrestartImpl
.restart
usesrestartImpl
inAbstractStreamFilter
.- Specified by:
restartImpl
in classAbstractStreamFilter
-
-