|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<DataPoint> net.sourceforge.openforecast.DataSet
public class DataSet
Represents a collection of data points. Data points are either observations of past data (including both the values of the independent variables and the observed value of the dependent variable), or forecasts or estimates of the dependent variable (for a given set of independent variable values).
Generally when trying to forecast future values you'll use two data sets. The first data set contains all of the observations, or historical data. This data set is used to help initialize the selected forecasting model, the details of which depend on the specific forecasting model. A second data set is then created and initialized with data points describing the values of the independent variables that are to be used to predict or forecast values of the dependent variable.
When defining any data set it is important to provide as much information as possible about the data. While on the surface it may seem trivial, the more information you can provide about a data set (such as whether it is a time-based series, the name of the independent variable representing time, the number of data points/periods in a year), the better the forecasting model will be able to model the data. This is because some models need this type of data to even be applicable.
Constructor Summary | |
---|---|
DataSet()
Constructs a new empty data set. |
|
DataSet(DataSet dataSet)
Copy constructor: constructs a new data set object by copying the given data set. |
|
DataSet(String timeVariable,
int periodsPerYear,
Collection<DataPoint> c)
Constructs a new time-based data set with the named time variable, the given number of data points in a year, and the given Collection of data points. |
Method Summary | |
---|---|
boolean |
add(DataPoint obj)
Adds the given data point object to this data set. |
boolean |
addAll(Collection<? extends DataPoint> c)
Adds a collection of data points to this data set. |
void |
clear()
Removes all of the data points from this data set. |
boolean |
contains(Object obj)
Returns true if this data set contains the given data point object; or false otherwise. |
boolean |
containsAll(Collection<?> c)
Returns true if this DataSet contains all of the DataPoints in the specified collection. |
boolean |
equals(DataSet dataSet)
Indicates whether some other DataSet is "equal to" this one. |
boolean |
equals(Object obj)
Indicates whether some other object, obj, is "equal to" this one. |
String[] |
getIndependentVariables()
Returns an ordered array of all independent variable names used in this data set. |
int |
getPeriodsPerYear()
Returns the number of periods - or data points - in a years worth of data for time-series data. |
String |
getTimeVariable()
Returns the time variable associated with this data set, or null if no time variable has been defined. |
int |
hashCode()
Returns the hash code value for this collection, based on the underlying Collection of DataPoints. |
boolean |
isEmpty()
Returns true if this data set contains no data points. |
Iterator<DataPoint> |
iterator()
Returns an iterator over the data points in this data set. |
boolean |
remove(Object obj)
Removes a single instance of the specified data point object from this data set, if it is present. |
boolean |
removeAll(Collection<?> c)
Not currently implemented - always throws UnsupportedOperationException. |
boolean |
retainAll(Collection<?> c)
Not currently implemented - always throws UnsupportedOperationException. |
void |
setPeriodsPerYear(int periodsPerYear)
Sets the number of periods - or data points - in a years worth of data for time-series data. |
void |
setTimeVariable(String timeVariable)
Sets the name of the time variable for this data set. |
int |
size()
Returns the number of data points in this data set. |
void |
sort(String independentVariable)
Sorts the given data set according to increasing value of the named independent variable. |
String |
toString()
Overrides the default toString method. |
Methods inherited from class java.util.AbstractCollection |
---|
toArray, toArray |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DataSet()
public DataSet(DataSet dataSet)
dataSet
- the data set to copy from to initialize the new data set.public DataSet(String timeVariable, int periodsPerYear, Collection<DataPoint> c)
timeVariable
- the name of the independent variable representing
time.periodsPerYear
- the number of periods - data points - in one years
worth of data.c
- a Collection of data points to initialize this data set with.setTimeVariable(java.lang.String)
,
setPeriodsPerYear(int)
,
addAll(java.util.Collection extends net.sourceforge.openforecast.DataPoint>)
Method Detail |
---|
public boolean add(DataPoint obj)
add
in interface Collection<DataPoint>
add
in class AbstractCollection<DataPoint>
obj
- the data point object to add to this set.
ClassCastException
- if the specified object does not implement
the DataPoint interface.
NullPointerException
- if the specified collection contains
one or more null elements.public boolean addAll(Collection<? extends DataPoint> c)
addAll
in interface Collection<DataPoint>
addAll
in class AbstractCollection<DataPoint>
c
- a collection of data points to add to this data set.
public void clear()
clear
in interface Collection<DataPoint>
clear
in class AbstractCollection<DataPoint>
public boolean isEmpty()
isEmpty
in interface Collection<DataPoint>
isEmpty
in class AbstractCollection<DataPoint>
public boolean contains(Object obj)
dataPoint.equals(dp)
returns true for some DataPoint
object, dp
, within the set of data points.
contains
in interface Collection<DataPoint>
contains
in class AbstractCollection<DataPoint>
obj
- the data point object to search for in this data set.
ClassCastException
- if the specified object does not implement
the DataPoint interface.
NullPointerException
- if the specified collection contains
one or more null elements.public boolean containsAll(Collection<?> c) throws ClassCastException, NullPointerException
containsAll
in interface Collection<DataPoint>
containsAll
in class AbstractCollection<DataPoint>
c
- collection to be checked for containment in this collection.
ClassCastException
- if the types of one or more elements in
the specified collection do not implement the DataPoint interface.
NullPointerException
- if the specified collection contains
one or more null elements.public boolean remove(Object obj)
remove
in interface Collection<DataPoint>
remove
in class AbstractCollection<DataPoint>
obj
- the data point object to remove from this data set.
ClassCastException
- if the specified object does not implement
the DataPoint interface.
NullPointerException
- if the specified collection contains
one or more null elements.public int size()
size
in interface Collection<DataPoint>
size
in class AbstractCollection<DataPoint>
public Iterator<DataPoint> iterator()
iterator
in interface Iterable<DataPoint>
iterator
in interface Collection<DataPoint>
iterator
in class AbstractCollection<DataPoint>
public void sort(String independentVariable)
independentVariable
- the name of the independent variable to
set by. The resulting data set will be sorted in increasing
value of this variable.public String[] getIndependentVariables()
public void setTimeVariable(String timeVariable)
timeVariable
- the name of the independent variable that represents
the time data component. For example, this may be something like
"t", "month", "period", "year", and so on.setPeriodsPerYear(int)
public String getTimeVariable()
null
if no time variable has been defined.
public void setPeriodsPerYear(int periodsPerYear)
In addition to setting the number of periods per year, you must also set the time variable otherwise any forecasting model will not be able to consider the potential effects of seasonality.
periodsPerYear
- the number of periods in a years worth of data.setTimeVariable(java.lang.String)
public int getPeriodsPerYear()
public boolean removeAll(Collection<?> c) throws UnsupportedOperationException
removeAll
in interface Collection<DataPoint>
removeAll
in class AbstractCollection<DataPoint>
c
- DataPoint objects to be removed from this collection.
UnsupportedOperationException
- if the removeAll method is not
supported by this collection.
ClassCastException
- if the types of one or more elements in the
specified DataSet are not DataPoint objects.
NullPointerException
- if the specified collection contains one
or more null elements.public boolean retainAll(Collection<?> c) throws UnsupportedOperationException
retainAll
in interface Collection<DataPoint>
retainAll
in class AbstractCollection<DataPoint>
c
- elements to be retained in this collection.
UnsupportedOperationException
- if the retainAll method is not
supported by this collection.
ClassCastException
- if the types of one or more elements in the
specified DataSet are not DataPoint objects.
NullPointerException
- if the specified collection contains one
or more null elements.public int hashCode()
hashCode
in interface Collection<DataPoint>
hashCode
in class Object
public boolean equals(Object obj)
equals(DataSet)
returns true; otherwise false.
equals
in interface Collection<DataPoint>
equals
in class Object
obj
- the reference object with which to compare.
equals(DataSet)
public boolean equals(DataSet dataSet)
dataSet
- the reference object with which to compare.
public String toString()
toString
in class AbstractCollection<DataPoint>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |