Package ai.libs.jaicore.ml.core.dataset
Class TimeSeriesDataset<L>
- java.lang.Object
-
- ai.libs.jaicore.ml.core.dataset.TimeSeriesDataset<L>
-
- All Implemented Interfaces:
AILabeledAttributeArrayDataset<TimeSeriesInstance<L>,L>,IDataset<TimeSeriesInstance<L>>,IOrderedDataset<TimeSeriesInstance<L>>,IOrderedLabeledAttributeArrayDataset<TimeSeriesInstance<L>,L>,java.lang.Iterable<TimeSeriesInstance<L>>,java.util.Collection<TimeSeriesInstance<L>>,java.util.List<TimeSeriesInstance<L>>
public class TimeSeriesDataset<L> extends java.lang.Object implements IOrderedLabeledAttributeArrayDataset<TimeSeriesInstance<L>,L>
Time Series Dataset.
-
-
Constructor Summary
Constructors Constructor Description TimeSeriesDataset(java.util.List<org.nd4j.linalg.api.ndarray.INDArray> valueMatrices, java.util.List<org.nd4j.linalg.api.ndarray.INDArray> timestampMatrices, org.nd4j.linalg.api.ndarray.INDArray targets, IAttributeType<L> targetType)Creates a TimeSeries dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int arg0, TimeSeriesInstance<L> arg1)booleanadd(TimeSeriesInstance<L> e)voidadd(org.nd4j.linalg.api.ndarray.INDArray valueMatrix, org.nd4j.linalg.api.ndarray.INDArray timestampMatrix)Add a time series variable to the dataset.booleanaddAll(int arg0, java.util.Collection<? extends TimeSeriesInstance<L>> arg1)booleanaddAll(java.util.Collection<? extends TimeSeriesInstance<L>> c)voidclear()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)IDataset<TimeSeriesInstance<L>>createEmpty()Creates an empty copy of the same structure (and same type).TimeSeriesInstance<L>get(int index)java.util.List<IAttributeType<?>>getAttributeTypes()Returns the list of attribute types.intgetFrequency(TimeSeriesInstance<L> instance)intgetNumberOfAttributes()Getter for the number of attributes (excluding target attribute).longgetNumberOfInstances()intgetNumberOfVariables()org.nd4j.linalg.api.ndarray.INDArraygetTargets()IAttributeType<L>getTargetType()Returns the attribute type of the target attribute.org.nd4j.linalg.api.ndarray.INDArraygetTimestamps(int index)org.nd4j.linalg.api.ndarray.INDArraygetTimestampsOrNull(int index)org.nd4j.linalg.api.ndarray.INDArraygetValues(int index)org.nd4j.linalg.api.ndarray.INDArraygetValuesOrNull(int index)intindexOf(java.lang.Object arg0)booleanisEmpty()booleanisMultivariate()booleanisUnivariate()java.util.Iterator<TimeSeriesInstance<L>>iterator()intlastIndexOf(java.lang.Object arg0)java.util.ListIterator<TimeSeriesInstance<L>>listIterator()java.util.ListIterator<TimeSeriesInstance<L>>listIterator(int arg0)TimeSeriesInstance<L>remove(int index)Removes the time series variable at a given index.booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)voidreplace(int index, org.nd4j.linalg.api.ndarray.INDArray valueMatrix, org.nd4j.linalg.api.ndarray.INDArray timestampMatrix)Replaces the time series variable at a given index with a new one.booleanretainAll(java.util.Collection<?> c)TimeSeriesInstance<L>set(int arg0, TimeSeriesInstance<L> arg1)intsize()java.util.List<TimeSeriesInstance<L>>subList(int arg0, int arg1)java.lang.Object[]toArray()<T> T[]toArray(T[] a)
-
-
-
Constructor Detail
-
TimeSeriesDataset
public TimeSeriesDataset(java.util.List<org.nd4j.linalg.api.ndarray.INDArray> valueMatrices, java.util.List<org.nd4j.linalg.api.ndarray.INDArray> timestampMatrices, org.nd4j.linalg.api.ndarray.INDArray targets, IAttributeType<L> targetType)Creates a TimeSeries dataset. Let `n` be the number of instances.- Parameters:
valueMatrices- Values for the time series variables. List of 2D-Arrays with shape `[n, ?]`.timestampMatrices- Timestamps for the time series variables. List of 2D-Arrays with shape `[n, ?]`. Or `null` if no timestamps exist for the corresponding time series variable. The shape of the `i`th index must be equal to the shape of the `i`th element of `valueMatrices`.targets- Target values for the instances.
-
-
Method Detail
-
add
public void add(org.nd4j.linalg.api.ndarray.INDArray valueMatrix, org.nd4j.linalg.api.ndarray.INDArray timestampMatrix)Add a time series variable to the dataset.- Parameters:
valueMatrix- Values for the time series variable to add. 2D-Arrays with shape `[n, ?]` where `n` is the number of instances of the dataset.timestampMatrix- Timestamps for the time series variable to add. 2D-Arrays with shape `[n, ?]` where `n` is the number of instances of the dataset. Or `null` if no timestamp exists for this time series variable.
-
remove
public TimeSeriesInstance<L> remove(int index)
Removes the time series variable at a given index.- Specified by:
removein interfacejava.util.List<L>- Parameters:
index-- Returns:
- Throws:
java.lang.IndexOutOfBoundsException
-
replace
public void replace(int index, org.nd4j.linalg.api.ndarray.INDArray valueMatrix, org.nd4j.linalg.api.ndarray.INDArray timestampMatrix)Replaces the time series variable at a given index with a new one.- Parameters:
index- Index of the time series varialbe to replace.valueMatrix- Values for the time series variable to add. 2D-Arrays with shape `[n, ?]` where `n` is the number of instances of the dataset.timestampMatrix- Timestamps for the time series variable to add. 2D-Arrays with shape `[n, ?]` where `n` is the number of instances of the dataset. Or `null` if no timestamp exists for this time series variable.- Throws:
java.lang.IndexOutOfBoundsException- Thrown if `numberOfInstances <= index`.
-
getTargets
public org.nd4j.linalg.api.ndarray.INDArray getTargets()
-
getNumberOfVariables
public int getNumberOfVariables()
-
getNumberOfInstances
public long getNumberOfInstances()
-
getValues
public org.nd4j.linalg.api.ndarray.INDArray getValues(int index)
-
getTimestamps
public org.nd4j.linalg.api.ndarray.INDArray getTimestamps(int index)
-
getValuesOrNull
public org.nd4j.linalg.api.ndarray.INDArray getValuesOrNull(int index)
-
getTimestampsOrNull
public org.nd4j.linalg.api.ndarray.INDArray getTimestampsOrNull(int index)
-
isEmpty
public boolean isEmpty()
-
isUnivariate
public boolean isUnivariate()
-
isMultivariate
public boolean isMultivariate()
-
get
public TimeSeriesInstance<L> get(int index)
- Specified by:
getin interfacejava.util.List<L>
-
iterator
public java.util.Iterator<TimeSeriesInstance<L>> iterator()
-
getNumberOfAttributes
public int getNumberOfAttributes()
Description copied from interface:AILabeledAttributeArrayDatasetGetter for the number of attributes (excluding target attribute).- Specified by:
getNumberOfAttributesin interfaceAILabeledAttributeArrayDataset<TimeSeriesInstance<L>,L>- Returns:
- The number of attributes.
-
getAttributeTypes
public java.util.List<IAttributeType<?>> getAttributeTypes()
Description copied from interface:AILabeledAttributeArrayDatasetReturns the list of attribute types.- Specified by:
getAttributeTypesin interfaceAILabeledAttributeArrayDataset<TimeSeriesInstance<L>,L>- Returns:
- The list of attribute types.
-
getTargetType
public IAttributeType<L> getTargetType()
Description copied from interface:AILabeledAttributeArrayDatasetReturns the attribute type of the target attribute.- Specified by:
getTargetTypein interfaceAILabeledAttributeArrayDataset<TimeSeriesInstance<L>,L>- Returns:
- The attribute type of the target attribute.
-
createEmpty
public IDataset<TimeSeriesInstance<L>> createEmpty()
Description copied from interface:IDatasetCreates an empty copy of the same structure (and same type).- Specified by:
createEmptyin interfaceIDataset<L>- Returns:
- The newly created dataset.
-
add
public boolean add(TimeSeriesInstance<L> e)
-
addAll
public boolean addAll(java.util.Collection<? extends TimeSeriesInstance<L>> c)
-
clear
public void clear()
-
contains
public boolean contains(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
size
public int size()
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
add
public void add(int arg0, TimeSeriesInstance<L> arg1)- Specified by:
addin interfacejava.util.List<L>
-
addAll
public boolean addAll(int arg0, java.util.Collection<? extends TimeSeriesInstance<L>> arg1)- Specified by:
addAllin interfacejava.util.List<L>
-
indexOf
public int indexOf(java.lang.Object arg0)
- Specified by:
indexOfin interfacejava.util.List<L>
-
lastIndexOf
public int lastIndexOf(java.lang.Object arg0)
- Specified by:
lastIndexOfin interfacejava.util.List<L>
-
listIterator
public java.util.ListIterator<TimeSeriesInstance<L>> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<L>
-
listIterator
public java.util.ListIterator<TimeSeriesInstance<L>> listIterator(int arg0)
- Specified by:
listIteratorin interfacejava.util.List<L>
-
set
public TimeSeriesInstance<L> set(int arg0, TimeSeriesInstance<L> arg1)
- Specified by:
setin interfacejava.util.List<L>
-
subList
public java.util.List<TimeSeriesInstance<L>> subList(int arg0, int arg1)
- Specified by:
subListin interfacejava.util.List<L>
-
getFrequency
public int getFrequency(TimeSeriesInstance<L> instance)
- Specified by:
getFrequencyin interfaceIDataset<L>
-
-