
public final class DatabaseUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
DatabaseUtil.CollectionFromRelation<O>
Collection view on a database that retrieves the objects when needed.
|
static class |
DatabaseUtil.RelationObjectIterator<O>
Iterator class that retrieves the given objects from the database.
|
| Constructor and Description |
|---|
DatabaseUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <V extends FeatureVector<?,?>> |
assumeVectorField(Relation<V> relation)
Get the dimensionality of a database
|
static <V extends NumberVector<? extends V,?>> |
centroid(Relation<? extends V> relation)
Returns the centroid as a NumberVector object of the specified database.
|
static <V extends NumberVector<? extends V,?>> |
centroid(Relation<? extends V> relation,
DBIDs ids)
Returns the centroid as a NumberVector object of the specified objects
stored in the given database.
|
static <V extends NumberVector<? extends V,?>> |
centroid(Relation<? extends V> relation,
DBIDs ids,
BitSet dimensions)
Returns the centroid w.r.t. the dimensions specified by the given BitSet as
a NumberVector object of the specified objects stored in the given
database.
|
static <NV extends NumberVector<NV,?>> |
computeMinMax(Relation<NV> database)
Determines the minimum and maximum values in each dimension of all objects
stored in the given database.
|
static Matrix |
covarianceMatrix(Matrix data)
Determines the d x d covariance matrix of the given n x d data matrix.
|
static <V extends NumberVector<? extends V,?>> |
covarianceMatrix(Relation<? extends V> database,
DBIDs ids)
Determines the covariance matrix of the objects stored in the given
database.
|
static int |
dimensionality(Relation<? extends FeatureVector<?,?>> relation)
Get the dimensionality of a database
|
static <V extends NumberVector<?,?>> |
exactMedian(Relation<V> relation,
DBIDs ids,
int dimension)
Returns the median of a data set in the given dimension.
|
static <O> Class<?> |
getBaseObjectClassExpensive(Relation<O> database)
Do a full inspection of the database to find the base object class.
|
static SortedSet<ClassLabel> |
getClassLabels(Database database)
Retrieves all class labels within the database.
|
static SortedSet<ClassLabel> |
getClassLabels(Relation<? extends ClassLabel> database)
Retrieves all class labels within the database.
|
static <V extends FeatureVector<?,?>> |
getColumnLabel(Relation<? extends V> rel,
int col)
Get the column name or produce a generic label "Column XY".
|
static ArrayModifiableDBIDs |
getObjectsByLabelMatch(Database database,
Pattern name_pattern)
Find object by matching their labels.
|
static Relation<String> |
guessLabelRepresentation(Database database)
Guess a potentially label-like representation, preferring class labels.
|
static <O> Class<? extends O> |
guessObjectClass(Relation<O> database)
Do a cheap guess at the databases object class.
|
static Relation<String> |
guessObjectLabelRepresentation(Database database)
Guess a potentially object label-like representation.
|
static <V extends NumberVector<?,?>> |
quickMedian(Relation<V> relation,
ArrayDBIDs ids,
int dimension,
int numberOfSamples)
Returns the median of a data set in the given dimension by using a sampling
method.
|
static <V extends NumberVector<?,?>,T extends NumberVector<?,?>> |
relationUglyVectorCast(Relation<T> database)
An ugly vector type cast unavoidable in some situations due to Generics.
|
static double[] |
variances(Relation<? extends NumberVector<?,?>> database,
NumberVector<?,?> centroid,
DBIDs ids)
Determines the variances in each dimension of the specified objects stored
in the given database.
|
static <V extends NumberVector<? extends V,?>> |
variances(Relation<V> database)
Determines the variances in each dimension of all objects stored in the
given database.
|
static <V extends NumberVector<? extends V,?>> |
variances(Relation<V> database,
DBIDs ids)
Determines the variances in each dimension of the specified objects stored
in the given database.
|
public static <V extends FeatureVector<?,?>> VectorFieldTypeInformation<V> assumeVectorField(Relation<V> relation)
relation - relationpublic static int dimensionality(Relation<? extends FeatureVector<?,?>> relation)
relation - relationpublic static <V extends NumberVector<? extends V,?>> V centroid(Relation<? extends V> relation)
NumberVector.V - Vector typerelation - the Relation storing the objectsIllegalArgumentException - if the database is emptypublic static <V extends NumberVector<? extends V,?>> V centroid(Relation<? extends V> relation, DBIDs ids)
NumberVector.V - Vector typerelation - the relationids - the ids of the objectsIllegalArgumentException - if the id list is emptypublic static <V extends NumberVector<? extends V,?>> V centroid(Relation<? extends V> relation, DBIDs ids, BitSet dimensions)
NumberVector.V - Vector typerelation - the database storing the objectsids - the identifiable objectsdimensions - the BitSet representing the dimensions to be consideredIllegalArgumentException - if the id list is emptypublic static <V extends NumberVector<? extends V,?>> Matrix covarianceMatrix(Relation<? extends V> database, DBIDs ids)
V - Vector typedatabase - the database storing the objectsids - the ids of the objectspublic static Matrix covarianceMatrix(Matrix data)
data - the database storing the objectspublic static <V extends NumberVector<? extends V,?>> double[] variances(Relation<V> database)
database - the database storing the objectspublic static <V extends NumberVector<? extends V,?>> double[] variances(Relation<V> database, DBIDs ids)
variances(database, centroid(database, ids), ids)database - the database storing the objectsids - the ids of the objectspublic static double[] variances(Relation<? extends NumberVector<?,?>> database, NumberVector<?,?> centroid, DBIDs ids)
database - the database storing the objectsids - the ids of the objectscentroid - the centroid or reference vector of the idspublic static <NV extends NumberVector<NV,?>> Pair<NV,NV> computeMinMax(Relation<NV> database)
NV - vector typedatabase - the database storing the objectspublic static <V extends NumberVector<?,?>> double quickMedian(Relation<V> relation, ArrayDBIDs ids, int dimension, int numberOfSamples)
relation - Relation to processids - DBIDs to processdimension - DimensionalitynumberOfSamples - Number of samples to drawpublic static <V extends NumberVector<?,?>> double exactMedian(Relation<V> relation, DBIDs ids, int dimension)
relation - Relation to processids - DBIDs to processdimension - Dimensionalitypublic static Relation<String> guessLabelRepresentation(Database database) throws NoSupportedDataTypeException
database - NoSupportedDataTypeExceptionpublic static Relation<String> guessObjectLabelRepresentation(Database database) throws NoSupportedDataTypeException
database - NoSupportedDataTypeExceptionpublic static SortedSet<ClassLabel> getClassLabels(Relation<? extends ClassLabel> database)
database - the database to be scanned for class labelspublic static SortedSet<ClassLabel> getClassLabels(Database database)
database - the database to be scanned for class labelspublic static <O> Class<? extends O> guessObjectClass(Relation<O> database)
O - Restriction typedatabase - Databasepublic static <O> Class<?> getBaseObjectClassExpensive(Relation<O> database)
O - Restriction typedatabase - Databasepublic static ArrayModifiableDBIDs getObjectsByLabelMatch(Database database, Pattern name_pattern)
database - Database to search inname_pattern - Name to match against class or object labelpublic static <V extends NumberVector<?,?>,T extends NumberVector<?,?>> Relation<V> relationUglyVectorCast(Relation<T> database)
V - Base vector typeT - Derived vector type (is actually V, too)database - Databasepublic static <V extends FeatureVector<?,?>> String getColumnLabel(Relation<? extends V> rel, int col)
rel - Relationcol - Column