Class PredictorMappingExtensions
Extension methods for the IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures> interface.
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Learners.Mappings
Assembly: Microsoft.ML.Probabilistic.Learners.dll
Syntax
public static class PredictorMappingExtensions
Methods
GetFeaturesSafe<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures>(IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures>, TInstance, TInstanceSource)
Safely retrieves the features for a given instance.
Declaration
public static TFeatures GetFeaturesSafe<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures>(this IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures> mapping, TInstance instance, TInstanceSource instanceSource = null)
Parameters
Type | Name | Description |
---|---|---|
IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures> | mapping | The mapping. |
TInstance | instance | The instance to provide features for. |
TInstanceSource | instanceSource | An optional source of instances. |
Returns
Type | Description |
---|---|
TFeatures | The features for the given instance. |
Type Parameters
Name | Description |
---|---|
TInstanceSource | The type of a source of instances. |
TInstance | The type of an instance. |
TLabelSource | The type of a source of labels. |
TLabel | The type of a label. |
TFeatures | The type of the features. |
Exceptions
Type | Condition |
---|---|
MappingException | Thrown if the retrieved feature values are null. |
GetInstancesSafe<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures>(IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures>, TInstanceSource)
Safely retrieves instances for a given instance source.
Declaration
public static IEnumerable<TInstance> GetInstancesSafe<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures>(this IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures> mapping, TInstanceSource instanceSource)
Parameters
Type | Name | Description |
---|---|---|
IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures> | mapping | The mapping. |
TInstanceSource | instanceSource | The source of instances. |
Returns
Type | Description |
---|---|
IEnumerable<TInstance> | The instances provided by the instance source. |
Type Parameters
Name | Description |
---|---|
TInstanceSource | The type of a source of instances. |
TInstance | The type of an instance. |
TLabelSource | The type of a source of labels. |
TLabel | The type of a label. |
TFeatures | The type of the features. |
Exceptions
Type | Condition |
---|---|
MappingException | Thrown if the retrieved instances are null. |
GetLabelSafe<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures>(IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures>, TInstance, TInstanceSource, TLabelSource)
Safely retrieves the label for a given instance.
Declaration
public static TLabel GetLabelSafe<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures>(this IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures> mapping, TInstance instance, TInstanceSource instanceSource = null, TLabelSource labelSource = null)
Parameters
Type | Name | Description |
---|---|---|
IPredictorMapping<TInstanceSource, TInstance, TLabelSource, TLabel, TFeatures> | mapping | The mapping. |
TInstance | instance | The instance to provide the label for. |
TInstanceSource | instanceSource | An optional source of instances. |
TLabelSource | labelSource | An optional source of labels. |
Returns
Type | Description |
---|---|
TLabel | The label of the given instance. |
Type Parameters
Name | Description |
---|---|
TInstanceSource | The type of a source of instances. |
TInstance | The type of an instance. |
TLabelSource | The type of a source of labels. |
TLabel | The type of a label. |
TFeatures | The type of the features. |
Exceptions
Type | Condition |
---|---|
MappingException | Thrown if the retrieved label is null. |