Tabular classification using Create ML Components

I am working on a project that involves tabular classification using Create ML Components and I'm having trouble getting my model to work correctly.

I've been following the official documentation here: https://developer.apple.com/documentation/createmlcomponents/

and also i have followed the wwdc talks. This one seems to be the most relevant one: https://developer.apple.com/wwdc22/10019

In that talk the construction of a tabular regressor is explained(20:23 Tabular regressor) . I tried using BoostedTreeClassifier similar to that. I am having trouble getting it to work though. While training with 5 featureColumns and one annotation columns appears to have worked. i am unsure how to get the label (the categorical value that the model is supposed to return) after calling .predict .

This is the last bit of the example from apple (tabular regression)

 static func predict(
        type: String,
        region: String,
        volume: Double
    ) async throws -> Double {
        let model = try task.read(from: parametersURL)
        let dataFrame: DataFrame = [
            "type": [type],
            "region": [region],
            "volume": [volume]
        ]
        let result = try await model(dataFrame)
        return result[priceColumnID][0]!
    }

The last line is what i am wondering how to write for a Tabular classifier. It should return a category in my case.

Is there a tutorial or example for a tabular classifier code somewhere?

Replies

A tabular classifier will return both the classification probabilities and the most likely labels. If your target column name is "target" the predicted labels column is also going to be "target" while the probability distributions is going to be in "targetProbabilities". You can always print the whole data frame with print(result) and see what the columns are. Hope this helps.