CoreML.PredictionFromFeatures
-----------------------------

Runs model with set parameters.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CoreML](component_CoreML.md) | [7.4](newinversion74.md) | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |

MBS( "CoreML.PredictionFromFeatures"; CoreMLRef ) 

**MBS**( **"CoreML.PredictionFromFeatures";** /\* Runs model with set parameters. \*/  
**$CoreMLRef**) /\* The reference number to the model.e.g. $Model \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| CoreMLRef | The reference number to the model. | $Model |

### Result

Returns JSON or error.

### Description

Runs model with set parameters.  
Returns JSON with the result from the model.  
  
The result is stored for later query result images via [CoreML.ResultImage](CoreMLResultImage.md).  
  
See also [Vision.ClassifyImage](VisionClassifyImage.md) to use Vision framework from Apple to classify images with Apple's model.  
### Examples

Run model:

 If \[ Length ( $$ML ) = 0 \]   
 Show Custom Dialog \[ "Please load model first." \]   
 Exit Script \[ Text Result: "" \]   
End If  
Set Variable \[ $r ; Value: MBS ("[CoreML.Clear](CoreMLClear.md)"; $$ML ) \]   
\# The Resnet50 model we use for testing, needs a specific image size   
Set Variable \[ $r ; Value: MBS ("[CoreML.AddImageParameter](CoreMLAddImageParameter.md)"; $$ML ; "image"; CoreML::Input Picture) \]   
Set Variable \[ $r ; Value: MBS ("CoreML.PredictionFromFeatures"; $$ML ) \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Failed to process" ; $r \]   
Else  
 Set Field \[ CoreML::Output ; $r \]   
 Show Custom Dialog \[ "Result" ; MBS ( "[JSON.GetPathItem](JSONGetPathItem.md)"; $r ; "classLabel";1 ) \]   
End If  
### See also

- [CoreML.AddImageParameter](CoreMLAddImageParameter.md)
- [CoreML.Clear](CoreMLClear.md)
- [CoreML.ResultImage](CoreMLResultImage.md)
- [IsError](IsError.md)
- [JSON.GetPathItem](JSONGetPathItem.md)
- [Vision.ClassifyImage](VisionClassifyImage.md)

### Example Databases

- [Mac and iOS/Machine Learning/Core ML Photos](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Machine%20Learning/Core%20ML%20Photos.shtml#7ScriptAnchor_)
- [Mac and iOS/Machine Learning/CoreML](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Machine%20Learning/CoreML.shtml#2ScriptAnchor_)

### FileMaker Magazin

- [Ausgabe 5/2022, Seite 27](https://filemaker-magazin.de/neuigkeit/4196-Appetithappen-FMM_202205)

This function checks for a license.

Created 16th September 2017 , last changed 17th October 2019

  
[CoreML.OpenModel](CoreMLOpenModel.md) - [CoreML.Release](CoreMLRelease.md)

[HTML Version](CoreMLPredictionFromFeatures.shtml)