Package adams.data.instance
Class Instance
- java.lang.Object
-
- adams.data.container.AbstractDataContainer<InstancePoint>
-
- adams.data.instance.Instance
-
- All Implemented Interfaces:
adams.core.CloneHandler
,adams.core.Mergeable<adams.data.container.DataContainer>
,adams.core.UniqueIDHandler
,adams.data.container.DataContainer<InstancePoint>
,adams.data.id.IDHandler
,adams.data.id.MutableIDHandler
,adams.data.NotesHandler
,adams.data.report.MutableReportHandler<adams.data.report.Report>
,adams.data.report.ReportHandler<adams.data.report.Report>
,adams.data.spreadsheet.SpreadSheetSupporter
,Serializable
,Comparable
,Iterable<InstancePoint>
,Collection<InstancePoint>
public class Instance extends adams.data.container.AbstractDataContainer<InstancePoint> implements adams.data.report.MutableReportHandler<adams.data.report.Report>, adams.data.NotesHandler, adams.data.spreadsheet.SpreadSheetSupporter
Stores values from weka.core.Instance objects, with X being the attribute index (integer) and Y being the internal value (double).- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static adams.data.container.DataPointComparator
m_Comparator
the default comparator.protected weka.core.Instances
m_DatasetHeader
a reference to the dataset the data was obtained from.protected adams.data.Notes
m_Notes
the notes for the chromatogram.protected adams.data.report.Report
m_Report
the automatically generated report.static String
REPORT_ADDITIONAL_PREFIX
the key prefix in the report for the additional attributes.static String
REPORT_CLASS
the key in the report for the class.static String
REPORT_DATASET
the key in the report for the dataset name.static String
REPORT_DB_ID
the key in the report for the database ID.static String
REPORT_DISPLAY_ID
the key in the report for the display ID.static String
REPORT_ID
the key in the report for the ID.static String
REPORT_ROW
the key in the report for the row in the dataset.
-
Constructor Summary
Constructors Constructor Description Instance()
Initializes the sequence.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assign(adams.data.container.DataContainer<InstancePoint> other)
Obtains the stored variables from the other data point, but not the actual data points.void
clear()
Removes all the points and report and nulls the header reference.adams.data.container.DataPointComparator<InstancePoint>
getComparator()
Returns the comparator in use.weka.core.Instances
getDatasetHeader()
Returns the header of the underlying dataset.adams.data.Notes
getNotes()
Returns the currently stored notes.adams.data.report.Report
getReport()
Returns the report.boolean
hasDatasetHeader()
Returns whether a header of a dataset is available.boolean
hasReport()
Checks whether a report is present.adams.data.container.DataPointComparator<InstancePoint>
newComparator()
Returns the comparator in use.InstancePoint
newPoint()
Returns a new instance of a sequence point.protected adams.data.report.Report
newReport()
Creates an empty report.void
set(weka.core.Instance inst)
Clears the container and adds the data from the weka.core.Instance (internal values).void
set(weka.core.Instance inst, int index, int[] additional, adams.core.Range range, HashSet<Integer> attTypes)
Clears the container and adds the data from the weka.core.Instance (internal values).void
setID(String value)
Sets the ID of the sequence.void
setReport(adams.data.report.Report value)
Sets a new report.double[]
toDoubleArray()
Returns the y values as double array.weka.core.Instance
toInstance()
Generates a weka instance, if a dataset header is available.adams.data.spreadsheet.SpreadSheet
toSpreadSheet()
Returns the content as spreadsheet.-
Methods inherited from class adams.data.container.AbstractDataContainer
add, addAll, compareTo, compareToData, compareToHeader, contains, containsAll, ensureCapacity, equals, equalsData, equalsHeader, getClone, getHeader, getID, getUniqueID, hashCode, isEmpty, iterator, mergeWith, modifiedListener, newInstance, remove, removeAll, retainAll, size, toArray, toArray, toList, toList, toString, toTreeSet, toTreeSet, trimToSize
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Field Detail
-
REPORT_DATASET
public static final String REPORT_DATASET
the key in the report for the dataset name.- See Also:
- Constant Field Values
-
REPORT_DB_ID
public static final String REPORT_DB_ID
the key in the report for the database ID.- See Also:
- Constant Field Values
-
REPORT_ID
public static final String REPORT_ID
the key in the report for the ID.- See Also:
- Constant Field Values
-
REPORT_DISPLAY_ID
public static final String REPORT_DISPLAY_ID
the key in the report for the display ID.- See Also:
- Constant Field Values
-
REPORT_CLASS
public static final String REPORT_CLASS
the key in the report for the class.- See Also:
- Constant Field Values
-
REPORT_ROW
public static final String REPORT_ROW
the key in the report for the row in the dataset.- See Also:
- Constant Field Values
-
REPORT_ADDITIONAL_PREFIX
public static final String REPORT_ADDITIONAL_PREFIX
the key prefix in the report for the additional attributes.- See Also:
- Constant Field Values
-
m_Comparator
protected static adams.data.container.DataPointComparator m_Comparator
the default comparator.
-
m_DatasetHeader
protected weka.core.Instances m_DatasetHeader
a reference to the dataset the data was obtained from.
-
m_Report
protected adams.data.report.Report m_Report
the automatically generated report.
-
m_Notes
protected adams.data.Notes m_Notes
the notes for the chromatogram.
-
-
Method Detail
-
setID
public void setID(String value)
Sets the ID of the sequence.- Specified by:
setID
in interfaceadams.data.id.MutableIDHandler
- Overrides:
setID
in classadams.data.container.AbstractDataContainer<InstancePoint>
- Parameters:
value
- the new ID
-
newComparator
public adams.data.container.DataPointComparator<InstancePoint> newComparator()
Returns the comparator in use.- Specified by:
newComparator
in interfaceadams.data.container.DataContainer<InstancePoint>
- Returns:
- the comparator to use
-
getComparator
public adams.data.container.DataPointComparator<InstancePoint> getComparator()
Returns the comparator in use.- Specified by:
getComparator
in interfaceadams.data.container.DataContainer<InstancePoint>
- Returns:
- the comparator in use
-
newPoint
public InstancePoint newPoint()
Returns a new instance of a sequence point.- Specified by:
newPoint
in interfaceadams.data.container.DataContainer<InstancePoint>
- Returns:
- the new sequence point
-
newReport
protected adams.data.report.Report newReport()
Creates an empty report.- Returns:
- the empty report
-
clear
public void clear()
Removes all the points and report and nulls the header reference.- Specified by:
clear
in interfaceCollection<InstancePoint>
- Overrides:
clear
in classadams.data.container.AbstractDataContainer<InstancePoint>
- See Also:
m_DatasetHeader
-
assign
public void assign(adams.data.container.DataContainer<InstancePoint> other)
Obtains the stored variables from the other data point, but not the actual data points.- Specified by:
assign
in interfaceadams.data.container.DataContainer<InstancePoint>
- Overrides:
assign
in classadams.data.container.AbstractDataContainer<InstancePoint>
- Parameters:
other
- the data point to get the values from
-
hasDatasetHeader
public boolean hasDatasetHeader()
Returns whether a header of a dataset is available.- Returns:
- true if a header is available
-
getDatasetHeader
public weka.core.Instances getDatasetHeader()
Returns the header of the underlying dataset.- Returns:
- the header, null if none currently set
-
set
public void set(weka.core.Instance inst)
Clears the container and adds the data from the weka.core.Instance (internal values).- Parameters:
inst
- the instance to use
-
set
public void set(weka.core.Instance inst, int index, int[] additional, adams.core.Range range, HashSet<Integer> attTypes)
Clears the container and adds the data from the weka.core.Instance (internal values). Uses only the attributes specified in the range.- Parameters:
inst
- the instance to useindex
- the row index in the original dataset, use -1 to ignoreadditional
- the indices of the additional attribute values to store in the reportrange
- the range of attributes to limit the instance toattTypes
- whether to restrict to attributes types, null or zero-length array means no restriction- See Also:
Attribute
-
hasReport
public boolean hasReport()
Checks whether a report is present.- Specified by:
hasReport
in interfaceadams.data.report.ReportHandler<adams.data.report.Report>
- Returns:
- always true
-
setReport
public void setReport(adams.data.report.Report value)
Sets a new report.- Specified by:
setReport
in interfaceadams.data.report.MutableReportHandler<adams.data.report.Report>
- Parameters:
value
- the new report
-
getReport
public adams.data.report.Report getReport()
Returns the report.- Specified by:
getReport
in interfaceadams.data.report.ReportHandler<adams.data.report.Report>
- Returns:
- the report, can be null if none available
-
toDoubleArray
public double[] toDoubleArray()
Returns the y values as double array.- Returns:
- the y values
-
toInstance
public weka.core.Instance toInstance()
Generates a weka instance, if a dataset header is available.- Returns:
- the generated Instance, null if no header available
-
getNotes
public adams.data.Notes getNotes()
Returns the currently stored notes.- Specified by:
getNotes
in interfaceadams.data.NotesHandler
- Returns:
- the current notes
-
toSpreadSheet
public adams.data.spreadsheet.SpreadSheet toSpreadSheet()
Returns the content as spreadsheet.- Specified by:
toSpreadSheet
in interfaceadams.data.spreadsheet.SpreadSheetSupporter
- Returns:
- the content
-
-