Class Descriptor
This class is designed to describe the underlying types that will be used in the machine learning process. Any machine learning process requires a set of Features that will be used to discriminate the Label. The Label itself is the target element that the machine learning algorithms learn to predict.
Inheritance
Inherited Members
Namespace:numl.Model
Assembly:numl.dll
Syntax
public class Descriptor
              Constructors
View SourceDescriptor()
Default constructor.
Declaration
public Descriptor()
              Properties
View SourceFeatures
Set of features used to discriminate or learn about the Label.
Declaration
public Property[] Features { get; set; }
              Property Value
| Type | Description | 
|---|---|
| Property[] | The features.  | 
                  
Item[Int32]
Index into features (for convenience)
Declaration
public Property this[int i] { get; }
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | i | Feature index.  | 
                  
Property Value
| Type | Description | 
|---|---|
| Property | Feature Property.  | 
                  
Item[String]
Index intor features (for convenience)
Declaration
public Property this[string name] { get; }
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Feature name.  | 
                  
Property Value
| Type | Description | 
|---|---|
| Property | Feature Property.  | 
                  
Label
Target property that is the target of machine learning.
Declaration
public Property Label { get; set; }
              Property Value
| Type | Description | 
|---|---|
| Property | The label.  | 
                  
Name
Descriptor name.
Declaration
public string Name { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.String | The name.  | 
                  
Type
Base type of object being described. This could also be null.
Declaration
public Type Type { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Type | The type.  | 
                  
VectorLength
Total feature count The number of features does not necessarily equal the number of Features given that there might exist multi-valued features.
Declaration
public int VectorLength { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Int32 | The length of the vector.  | 
                  
Methods
View SourceAt(Int32)
Gets related property given its offset within the vector representation.
Declaration
public Property At(int i)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | i | Vector Index.  | 
                  
Returns
| Type | Description | 
|---|---|
| Property | Associated Feature.  | 
                  
Exceptions
| Type | Condition | 
|---|---|
| System.IndexOutOfRangeException | Thrown when the index is outside the required range.  | 
                  
ColumnAt(Int32)
Gets related property column name given its offset within the vector representation.
Declaration
public string ColumnAt(int i)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | i | Vector Index.  | 
                  
Returns
| Type | Description | 
|---|---|
| System.String | Associated Property Name.  | 
                  
Convert(IEnumerable<Object>, Boolean)
Converts a list of examples into a lazy double list of doubles.
Declaration
public IEnumerable<IEnumerable<double>> Convert(IEnumerable<object> items, bool withLabels = true)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Object> | items | Examples.  | 
                  
| System.Boolean | withLabels | True to include labels, otherwise False  | 
                  
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<System.Double>> | Lazy double enumerable of doubles.  | 
                  
Convert(Object)
Converts a given example into a lazy list of doubles in preparation for vector conversion (both features and corresponding label)
Declaration
public IEnumerable<double> Convert(object item)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | item | Example.  | 
                  
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<System.Double> | Lazy List of doubles.  | 
                  
Convert(Object, Boolean)
Converts a given example into a lazy list of doubles in preparation for vector conversion.
Declaration
public IEnumerable<double> Convert(object item, bool withLabel)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | item | Example.  | 
                  
| System.Boolean | withLabel | Should convert label as well.  | 
                  
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<System.Double> | Lazy List of doubles.  | 
                  
Exceptions
| Type | Condition | 
|---|---|
| System.InvalidOperationException | Thrown when the requested operation is invalid.  | 
                  
Create(Type)
Creates a descriptor based upon a marked up concrete type.
Declaration
public static Descriptor Create(Type t)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | t | Class Type.  | 
                  
Returns
| Type | Description | 
|---|---|
| Descriptor | Descriptor.  | 
                  
Exceptions
| Type | Condition | 
|---|---|
| System.InvalidOperationException | Thrown when the requested operation is invalid.  | 
                  
Create<T>()
Creates a descriptor based upon a marked up concrete class.
Declaration
public static Descriptor Create<T>()where T : class
              Returns
| Type | Description | 
|---|---|
| Descriptor | Descriptor.  | 
                  
Type Parameters
| Name | Description | 
|---|---|
| T | 
Equals(Object)
Equality test
Declaration
public override bool Equals(object obj)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | obj | object to compare  | 
                  
Returns
| Type | Description | 
|---|---|
| System.Boolean | equality  | 
                  
Overrides
For<T>()
Creates a new descriptor using a strongly typed fluent approach. This initial descriptor is worthless without adding features.
Declaration
public static Descriptor<T> For<T>()
              Returns
| Type | Description | 
|---|---|
| Descriptor<T> | Empty descriptor  | 
                  
Type Parameters
| Name | Description | 
|---|---|
| T | Source Object Type  | 
                  
For<T>(String)
Creates a new descriptor using a strongly typed fluent approach. This initial descriptor is worthless without adding features.
Declaration
public static Descriptor<T> For<T>(string name)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Desired Descriptor Name.  | 
                  
Returns
| Type | Description | 
|---|---|
| Descriptor<T> | Empty descriptor  | 
                  
Type Parameters
| Name | Description | 
|---|---|
| T | Source Object Type  | 
                  
GetColumns()
Available column names used to discriminate or learn about Label. The number of columns does not necessarily equal the number of Features given that there might exist multi-valued features.
Declaration
public IEnumerable<string> GetColumns()
              Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<System.String> | An enumerator that allows foreach to be used to process the columns in this collection.  | 
                  
GetHashCode()
Return hash
Declaration
public override int GetHashCode()
              Returns
| Type | Description | 
|---|---|
| System.Int32 | hash  | 
                  
Overrides
GetValue(Object, Property)
Returns the raw value from the object for the supplied property.
Declaration
public object GetValue(object o, Property property)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | o | Object to process.  | 
                  
| Property | property | Property value of the object to return.  | 
                  
Returns
| Type | Description | 
|---|---|
| System.Object | 
Learn(String)
Adds (or replaces) a label to the descriptor.
Declaration
public DescriptorProperty Learn(string name)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Name of label (must match property name or dictionary key)  | 
                  
Returns
| Type | Description | 
|---|---|
| DescriptorProperty | A DescriptorProperty.  | 
                  
Load(Stream)
Load a descriptor from a stream.
Declaration
public static Descriptor Load(Stream stream)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.IO.Stream | stream | Stream.  | 
                  
Returns
| Type | Description | 
|---|---|
| Descriptor | Descriptor.  | 
                  
Exceptions
| Type | Condition | 
|---|---|
| System.NotImplementedException | 
New()
Creates a new descriptor using a fluent approach. This initial descriptor is worthless without adding features.
Declaration
public static Descriptor New()
              Returns
| Type | Description | 
|---|---|
| Descriptor | Empty Descriptor.  | 
                  
New(String)
Creates a new descriptor using a fluent approach. This initial descriptor is worthless without adding features.
Declaration
public static Descriptor New(string name)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Desired name.  | 
                  
Returns
| Type | Description | 
|---|---|
| Descriptor | Empty Named Descriptor.  | 
                  
New(Type)
Creates a new descriptor using a fluent approach. This initial descriptor is worthless without adding features.
Declaration
public static Descriptor New(Type type)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | Type mapping.  | 
                  
Returns
| Type | Description | 
|---|---|
| Descriptor | A Descriptor.  | 
                  
ToExamples(IEnumerable<Object>)
Converts a list of examples into a Matrix/Vector tuple.
Declaration
public ToExamples(IEnumerable<object> examples)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Object> | examples | Examples.  | 
                  
Returns
| Type | Description | 
|---|---|
| System. | Tuple containing Matrix and Vector.  | 
                  
ToMatrix(IEnumerable<Object>)
Converts a list of examples into a Matrix.
Declaration
public Matrix ToMatrix(IEnumerable<object> examples)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Object> | examples | Examples.  | 
                  
Returns
| Type | Description | 
|---|---|
| Matrix | Matrix representation.  | 
                  
ToString()
Pretty printed descriptor.
Declaration
public override string ToString()
              Returns
| Type | Description | 
|---|---|
| System.String | Pretty printed string.  | 
                  
Overrides
ToVector(Object)
Convert an object to its vector representation based on the descriptor properties.
Declaration
public Vector ToVector(object item)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | item | object to convert.  | 
                  
Returns
| Type | Description | 
|---|---|
| Vector | Vector representation.  | 
                  
With(String)
Adds a new feature to descriptor.
Declaration
public DescriptorProperty With(string name)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Name of feature (must match property name or dictionary key)  | 
                  
Returns
| Type | Description | 
|---|---|
| DescriptorProperty | method for describing feature.  |