After a bit of playing around, I think I have a workable solution to share.
Firstly, let's create a classifier using the titanic datset.
cl = Classify[ ResourceData["Sample Data: Titanic Survival"] -> "SurvivalStatus"]
Let's now define an API function. Within the function, we want to define the independent variables that are passed through the classifier to get the desired output.
For this dataset, there are three inputs
- Class - a string - 1st, 2nd or 3rd
- Age - a number
- Sex - string - male or female
The output of the function is going to be in term of the class probabilities - "survived" & "died"
func = APIFunction[{"Class" -> "String", "Age" -> "Number", "Sex" -> "String"}, cl[{#Class, #Age, #Sex}, "Probabilities"] &]
Let's now deploy this and set the appropriate permissions.
co = CloudDeploy[func, Permissions -> "Public"]
We can then choose to embed the code into the c# script.
EmbedCode[co, "C#"]
We can now test the API function within MMA using URLExecute[]
URLExecute["API Link", {"Class" -> "3rd", "Age" -> 30, "Sex" -> "male"}]
Which returns the desired output.
<|"died" -> 0.9095863222570499, "survived" -> 0.09041367774295012|>