public class SparseDataset extends Object implements Iterable<Datum<SparseArray>>
LIL is typically used to construct the matrix. Once the matrix is constructed, it is typically converted to a format, such as Harwell-Boeing column-compressed sparse matrix format, which is more efficient for matrix operations.
| Constructor and Description |
|---|
SparseDataset()
Constructor.
|
SparseDataset(Attribute response)
Constructor.
|
SparseDataset(int ncols)
Constructor.
|
SparseDataset(String name)
Constructor.
|
SparseDataset(String name,
Attribute response)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Datum<SparseArray> |
get(int i)
Returns the element at the specified position in this dataset.
|
double |
get(int i,
int j)
Returns the value at entry (i, j).
|
String |
getDescription()
Returns the detailed dataset description.
|
String |
getName()
Returns the dataset name.
|
Iterator<Datum<SparseArray>> |
iterator()
Returns an iterator over the elements in this dataset in proper sequence.
|
int |
length()
Returns the number of nonzero entries.
|
int |
ncols()
Returns the number of columns.
|
Datum<SparseArray> |
remove(int i)
Removes the element at the specified position in this dataset.
|
Attribute |
response()
Returns the attribute of the response variable.
|
void |
set(int i,
double y)
Set the real-valued response of a datum.
|
void |
set(int i,
double y,
double weight)
Set the class label of real-valued response of a datum.
|
void |
set(int i,
int y)
Set the class label of a datum.
|
void |
set(int i,
int j,
double x)
Set a nonzero entry into the matrix.
|
void |
setDescription(String description)
Sets the detailed dataset description.
|
void |
setName(String name)
Sets the dataset name.
|
int |
size()
Returns the size of dataset that is the number of rows.
|
double[][] |
toArray()
Returns a dense two-dimensional array containing the whole matrix in
this dataset in proper sequence.
|
double[] |
toArray(double[] a)
Returns an array containing the response variable of the elements in this
dataset in proper sequence (from first to last element).
|
int[] |
toArray(int[] a)
Returns an array containing the class labels of the elements in this
dataset in proper sequence (from first to last element).
|
SparseArray[] |
toArray(SparseArray[] a)
Returns an array containing all of the elements in this dataset in
proper sequence (from first to last element); the runtime type of the
returned array is that of the specified array.
|
SparseMatrix |
toSparseMatrix()
Convert into Harwell-Boeing column-compressed sparse matrix format.
|
void |
unitize()
Unitize each row so that L2 norm of x = 1.
|
void |
unitize1()
Unitize each row so that L1 norm of x is 1.
|
public SparseDataset()
public SparseDataset(String name)
name - the name of dataset.public SparseDataset(Attribute response)
response - the attribute type of response variable.public SparseDataset(String name, Attribute response)
name - the name of dataset.response - the attribute type of response variable.public SparseDataset(int ncols)
ncols - the number of columns in the matrix.public String getName()
public void setName(String name)
public void setDescription(String description)
public String getDescription()
public Attribute response()
public int size()
public int ncols()
public int length()
public void set(int i,
int y)
i - the row index of entry.y - the class label or real-valued response of the datum.public void set(int i,
double y)
i - the row index of entry.y - the class label or real-valued response of the datum.public void set(int i,
double y,
double weight)
i - the row index of entry.y - the class label or real-valued response of the datum.weight - the optional weight of the datum.public void set(int i,
int j,
double x)
i - the row index of entry.j - the column index of entry.x - the value of entry.public Datum<SparseArray> get(int i)
i - the index of the element to be returned.public double get(int i,
int j)
i - the row index.j - the column index.public Datum<SparseArray> remove(int i)
i - the index of the element to be removed.public void unitize()
public void unitize1()
public SparseMatrix toSparseMatrix()
public Iterator<Datum<SparseArray>> iterator()
iterator in interface Iterable<Datum<SparseArray>>public double[][] toArray()
public SparseArray[] toArray(SparseArray[] a)
If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to null.
a - the array into which the elements of this dataset are to be
stored, if it is big enough; otherwise, a new array of the same runtime
type is allocated for this purpose.public int[] toArray(int[] a)
If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to Integer.MIN_VALUE.
a - the array into which the class labels of this dataset are to be
stored, if it is big enough; otherwise, a new array is allocated for
this purpose.public double[] toArray(double[] a)
If the dataset fits in the specified array with room to spare (i.e., the array has more elements than the dataset), the element in the array immediately following the end of the dataset is set to Double.NaN.
a - the array into which the response variable of this dataset are
to be stored, if it is big enough; otherwise, a new array is allocated
for this purpose.Copyright © 2015. All rights reserved.