Class Sparsity
Defines sparsity settings for vectors. The sparsity handling has been designed to deal with large dimensional distributions such as Discrete and Dirichlet distributions.
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Math
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
[Serializable]
[DataContract]
public class Sparsity
Properties
CountTolerance
The maximum allowed count of vector elements not set to the common value.
Declaration
[DataMember]
public int CountTolerance { get; }
Property Value
Type | Description |
---|---|
Int32 |
Dense
Static read-only property giving Sparsity settings for dense vectors.
Declaration
public static Sparsity Dense { get; }
Property Value
Type | Description |
---|---|
Sparsity |
Remarks
DenseVector uses this specification.
IsApproximate
True if the sparsity is approximate
Declaration
public bool IsApproximate { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsDense
True if is the vector is dense
Declaration
public bool IsDense { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsExact
True if the sparsity is exact
Declaration
public bool IsExact { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsPiecewise
True if is the vector is piecewise
Declaration
public bool IsPiecewise { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsSparse
True if the vector is sparse (exact or approximate)
Declaration
public bool IsSparse { get; }
Property Value
Type | Description |
---|---|
Boolean |
Piecewise
Static read-only property giving Sparsity settings for piecewise, exact vectors.
Declaration
public static Sparsity Piecewise { get; }
Property Value
Type | Description |
---|---|
Sparsity |
Remarks
A vector class which uses this sparsity is expected to have ranges of elements that have the same values. PiecewiseVector uses this specification.
Sparse
Static read-only property giving Sparsity settings for sparse, exact vectors.
Declaration
public static Sparsity Sparse { get; }
Property Value
Type | Description |
---|---|
Sparsity |
Remarks
A vector class which uses this sparsity will maintain a common background value. It is expected that only a small percentage of values will differ from this common value, and this enables the vector class to be efficient computationally and memory-wise. SparseVector uses this specification.
Storage
The storage method used by this vector
Declaration
public StorageType Storage { get; }
Property Value
Type | Description |
---|---|
StorageType |
Tolerance
The tolerance at which vector element values are considered equal to the common value.
Declaration
[DataMember]
public double Tolerance { get; }
Property Value
Type | Description |
---|---|
Double |
Methods
ApproximateWithTolerance(Double)
Static read-only property giving Sparsity settings for approximate vector with the given tolerance.
Declaration
public static Sparsity ApproximateWithTolerance(double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Double | tolerance | At what tolerance are vector values considered equal to the common value. |
Returns
Type | Description |
---|---|
Sparsity |
Remarks
ApproximateSparseVector supports this specification.
Equals(Object)
Determines the equality of this instance with another
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Overrides
FromSpec(StorageType, Double, Int32)
Static method to create a general sparsity specification
Declaration
[Construction(new string[]{"Storage", "Tolerance", "CountTolerance"})]
public static Sparsity FromSpec(StorageType storage, double tolerance, int countTolerance)
Parameters
Type | Name | Description |
---|---|---|
StorageType | storage | The storage method the vector should use |
Double | tolerance | The tolerance at which vector element values are considered equal to the common value. |
Int32 | countTolerance | The maximum allowed count of vector elements not set to the common value. |
Returns
Type | Description |
---|---|
Sparsity |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
ToString()
Instance description
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
Operators
Equality(Sparsity, Sparsity)
Equality operator.
Declaration
public static bool operator ==(Sparsity a, Sparsity b)
Parameters
Type | Name | Description |
---|---|---|
Sparsity | a | First sparsity. |
Sparsity | b | Second sparsity. |
Returns
Type | Description |
---|---|
Boolean | True if the sparsity specifications are equal. |
Inequality(Sparsity, Sparsity)
Inequality operator.
Declaration
public static bool operator !=(Sparsity a, Sparsity b)
Parameters
Type | Name | Description |
---|---|---|
Sparsity | a | First sparsity specification. |
Sparsity | b | Second sparsity specification. |
Returns
Type | Description |
---|---|
Boolean | True if sparsity specifications are not equal. |