smile.data
Class AttributeDataset
- java.lang.Object
-
- smile.data.Dataset<double[]>
-
- smile.data.AttributeDataset
-
- All Implemented Interfaces:
- java.lang.Iterable<Datum<double[]>>
public class AttributeDataset extends Dataset<double[]>
A dataset of fixed number of attributes. All attribute values are stored as double even if the attribute may be nominal, ordinal, string, or date. The dataset is stored row-wise internally, which is fast for frequently accessing instances of dataset.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description classAttributeDataset.Row
-
Constructor Summary
Constructors Constructor and Description AttributeDataset(java.lang.String name, Attribute[] attributes)Constructor.AttributeDataset(java.lang.String name, Attribute[] attributes, Attribute response)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description AttributeDataset.Rowadd(AttributeDataset.Row x)Add a datum item into the dataset.Datum<double[]>add(Datum<double[]> x)Add a datum item into the dataset.AttributeDataset.Rowadd(double[] x)Add a datum item into the dataset.AttributeDataset.Rowadd(double[] x, double y)Add a datum item into the dataset.AttributeDataset.Rowadd(double[] x, double y, double weight)Add a datum item into the dataset.AttributeDataset.Rowadd(double[] x, int y)Add a datum item into the dataset.AttributeDataset.Rowadd(double[] x, int y, double weight)Add a datum item into the dataset.Attribute[]attributes()Returns the list of attributes in this dataset.AttributeVectorcolumn(int i)Returns a column.AttributeVectorcolumn(java.lang.String col)Returns a column.AttributeDatasetcolumns(java.lang.String... cols)Returns a dataset with selected columns.AttributeDatasethead(int n)returns the first few rows.AttributeDatasetrange(int from, int to)Returns the rows in the given range [from, to).AttributeDatasetremove(java.lang.String... cols)Returns a new dataset without given columns.AttributeDatasetsummary()Returns statistic summary.AttributeDatasettail(int n)Returns the last few rows.java.lang.StringtoString()java.lang.StringtoString(int from, int to)Stringify dataset.double[][]x()Returns the array of data items.-
Methods inherited from class smile.data.Dataset
data, get, getDescription, getName, iterator, labels, remove, response, responseAttribute, setDescription, setName, size, toArray, toArray, toArray, toArray, toArray, y
-
-
-
-
Constructor Detail
-
AttributeDataset
public AttributeDataset(java.lang.String name, Attribute[] attributes)Constructor.- Parameters:
name- the name of dataset.attributes- the list of attributes in this dataset.
-
-
Method Detail
-
attributes
public Attribute[] attributes()
Returns the list of attributes in this dataset.
-
x
public double[][] x()
Returns the array of data items.
-
add
public Datum<double[]> add(Datum<double[]> x)
Description copied from class:DatasetAdd a datum item into the dataset.
-
add
public AttributeDataset.Row add(AttributeDataset.Row x)
Add a datum item into the dataset.- Parameters:
x- a datum item.- Returns:
- the added datum item.
-
add
public AttributeDataset.Row add(double[] x)
Description copied from class:DatasetAdd a datum item into the dataset.
-
add
public AttributeDataset.Row add(double[] x, int y)
Description copied from class:DatasetAdd a datum item into the dataset.
-
add
public AttributeDataset.Row add(double[] x, int y, double weight)
Description copied from class:DatasetAdd a datum item into the dataset.- Overrides:
addin classDataset<double[]>- Parameters:
x- a datum item.y- the class label of the datum.weight- the weight of datum. The particular meaning of weight depends on applications and machine learning algorithms. Although there are on explicit requirements on the weights, in general, they should be positive.- Returns:
- the added datum item.
-
add
public AttributeDataset.Row add(double[] x, double y)
Description copied from class:DatasetAdd a datum item into the dataset.
-
add
public AttributeDataset.Row add(double[] x, double y, double weight)
Description copied from class:DatasetAdd a datum item into the dataset.- Overrides:
addin classDataset<double[]>- Parameters:
x- a datum item.weight- the weight of datum. The particular meaning of weight depends on applications and machine learning algorithms. Although there are on explicit requirements on the weights, in general, they should be positive.- Returns:
- the added datum item.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
head
public AttributeDataset head(int n)
returns the first few rows.
-
tail
public AttributeDataset tail(int n)
Returns the last few rows.
-
range
public AttributeDataset range(int from, int to)
Returns the rows in the given range [from, to).
-
toString
public java.lang.String toString(int from, int to)Stringify dataset.- Parameters:
from- starting row (inclusive)to- ending row (exclusive)
-
column
public AttributeVector column(int i)
Returns a column.
-
column
public AttributeVector column(java.lang.String col)
Returns a column.
-
columns
public AttributeDataset columns(java.lang.String... cols)
Returns a dataset with selected columns.
-
remove
public AttributeDataset remove(java.lang.String... cols)
Returns a new dataset without given columns.
-
summary
public AttributeDataset summary()
Returns statistic summary.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG