Share via


IMLFeatureProvider Interface

Definition

An interface that defines input or output features and allows access to their values.

[Foundation.Protocol(Name="MLFeatureProvider", WrapperType=typeof(CoreML.MLFeatureProviderWrapper))]
[Foundation.ProtocolMember(IsProperty=false, IsRequired=true, IsStatic=false, Name="GetFeatureValue", ParameterByRef=new System.Boolean[] { false }, ParameterType=new System.Type[] { typeof(System.String) }, ReturnType=typeof(CoreML.MLFeatureValue), Selector="featureValueForName:")]
[Foundation.ProtocolMember(ArgumentSemantic=ObjCRuntime.ArgumentSemantic.None, GetterSelector="featureNames", IsProperty=true, IsRequired=true, IsStatic=false, Name="FeatureNames", PropertyType=typeof(Foundation.NSSet<Foundation.NSString>), Selector="featureNames")]
public interface IMLFeatureProvider : IDisposable, ObjCRuntime.INativeObject
[<Foundation.Protocol(Name="MLFeatureProvider", WrapperType=typeof(CoreML.MLFeatureProviderWrapper))>]
[<Foundation.ProtocolMember(IsProperty=false, IsRequired=true, IsStatic=false, Name="GetFeatureValue", ParameterByRef=new System.Boolean[] { false }, ParameterType=new System.Type[] { typeof(System.String) }, ReturnType=typeof(CoreML.MLFeatureValue), Selector="featureValueForName:")>]
[<Foundation.ProtocolMember(ArgumentSemantic=ObjCRuntime.ArgumentSemantic.None, GetterSelector="featureNames", IsProperty=true, IsRequired=true, IsStatic=false, Name="FeatureNames", PropertyType=typeof(Foundation.NSSet<Foundation.NSString>), Selector="featureNames")>]
type IMLFeatureProvider = interface
    interface INativeObject
    interface IDisposable
Derived
Attributes
Implements

Remarks

CoreML does not directly read and write system-native data. Rather it uses this class to map strings to values for the inputs and outputs of the MLModel object.

The following example shows a IMLFeatureProvider that provides 3 inputs variables, all of type double:

public class MarsHabitatPricerInput : NSObject, IMLFeatureProvider
{
	public double SolarPanels { get; set; }
	public double Greenhouses { get; set; }
	public double Size { get; set; }

	public NSSet<NSString> FeatureNames => new NSSet<NSString>(new NSString("solarPanels"), new NSString("greenhouses"), new NSString("size"));

	public MLFeatureValue GetFeatureValue(string featureName)
	{
		switch (featureName)
		{
			case "solarPanels":
				return MLFeatureValue.Create(SolarPanels);
			case "greenhouses":
				return MLFeatureValue.Create(Greenhouses);
			case "size":
				return MLFeatureValue.Create(Size);
			default:
				return MLFeatureValue.Create(0);
		}
	}
}

Properties

Name Description
FeatureNames

The names of the feature, as defined by the MLModel.

Handle

Handle (pointer) to the unmanaged object representation.

(Inherited from INativeObject)

Methods

Name Description
GetFeatureValue(String)

Retrieves the value of the featureName.

Extension Methods

Name Description
GetHandle(INativeObject)
GetNonNullHandle(INativeObject, String)

Applies to