Create ML

RSS for tag

Create machine learning models for use in your app using Create ML.

Create ML Documentation

Posts under Create ML subtopic

Post

Replies

Boosts

Views

Activity

Create ML cancels model training without explanations
I‘ve created text classification project and selected BERT algorithm With 100 iterations for json file. Json file is valid but training always cancels on 37 iteration… Because tool does not provide any cancellation reasons I have no clue why it happens. Can I check reasons somehow? Or do anyone knows possible reasons or solutions for this?
1
0
841
Jul ’24
Question about ARKit Object Tracking Capabilities
Hi everyone, I'm curious about the capabilities of ARKit's object tracking feature. Specifically, I'd like to know: Is there a size limit for the objects that can be tracked? Can ARKit differentiate between two objects with the same shape but different models (e.g., different colors)? Are objects with single colors and generic shapes (like squares or circles) effectively trackable? Any insights or examples from your experiences would be greatly appreciated! Thanks in advance.
1
0
959
Jul ’24
On device training of text classifier model
I have made a text classifier model but I want to train it on device too. When text is classified wrong, user can make update the model on device. Code : // // SpamClassifierHelper.swift // LearningML // // Created by Himan Dhawan on 7/1/24. // import Foundation import CreateMLComponents import CoreML import NaturalLanguage enum TextClassifier : String { case spam = "spam" case notASpam = "ham" } class SpamClassifierModel { // MARK: - Private Type Properties /// The updated Spam Classifier model. private static var updatedSpamClassifier: SpamClassifier? /// The default Spam Classifier model. private static var defaultSpamClassifier: SpamClassifier { do { return try SpamClassifier(configuration: .init()) } catch { fatalError("Couldn't load SpamClassifier due to: \(error.localizedDescription)") } } // The Spam Classifier model currently in use. static var liveModel: SpamClassifier { updatedSpamClassifier ?? defaultSpamClassifier } /// The location of the app's Application Support directory for the user. private static let appDirectory = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first! class var urlOfModelInThisBundle : URL { let bundle = Bundle(for: self) return bundle.url(forResource: "SpamClassifier", withExtension:"mlmodelc")! } /// The default Spam Classifier model's file URL. private static let defaultModelURL = urlOfModelInThisBundle /// The permanent location of the updated Spam Classifier model. private static var updatedModelURL = appDirectory.appendingPathComponent("personalized.mlmodelc") /// The temporary location of the updated Spam Classifier model. private static var tempUpdatedModelURL = appDirectory.appendingPathComponent("personalized_tmp.mlmodelc") // MARK: - Public Type Methods static func predictLabelFor(_ value: String) throws -> (predication :String?, confidence : String) { let spam = try NLModel(mlModel: liveModel.model) let result = spam.predictedLabel(for: value) let confidence = spam.predictedLabelHypotheses(for: value, maximumCount: 1).first?.value ?? 0 return (result,String(format: "%.2f", confidence * 100)) } static func updateModel(newEntryText : String, spam : TextClassifier) throws { guard let modelURL = Bundle.main.url(forResource: "SpamClassifier", withExtension: "mlmodelc") else { fatalError("Could not find model in bundle") } // Create feature provider for the new image let featureProvider = try MLDictionaryFeatureProvider(dictionary: ["label": MLFeatureValue(string: newEntryText), "text": MLFeatureValue(string: spam.rawValue)]) let batchProvider = MLArrayBatchProvider(array: [featureProvider]) let updateTask = try MLUpdateTask(forModelAt: modelURL, trainingData: batchProvider, configuration: nil, completionHandler: { context in let updatedModel = context.model let fileManager = FileManager.default do { // Create a directory for the updated model. try fileManager.createDirectory(at: tempUpdatedModelURL, withIntermediateDirectories: true, attributes: nil) // Save the updated model to temporary filename. try updatedModel.write(to: tempUpdatedModelURL) // Replace any previously updated model with this one. _ = try fileManager.replaceItemAt(updatedModelURL, withItemAt: tempUpdatedModelURL) loadUpdatedModel() print("Updated model saved to:\n\t\(updatedModelURL)") } catch let error { print("Could not save updated model to the file system: \(error)") return } }) updateTask.resume() } /// Loads the updated Spam Classifier, if available. /// - Tag: LoadUpdatedModel private static func loadUpdatedModel() { guard FileManager.default.fileExists(atPath: updatedModelURL.path) else { // The updated model is not present at its designated path. return } // Create an instance of the updated model. guard let model = try? SpamClassifier(contentsOf: updatedModelURL) else { return } // Use this updated model to make predictions in the future. updatedSpamClassifier = model } }
1
0
808
Jul ’24
timeseriesclassifier
After I have a dataframe of data with one column as features with type MLshapedarray and one column of annotations with type Int. How can I convert them to the correct input type for the timeseriesclassifier?
0
0
667
Jul ’24
CreateML Preview Tab Miscalculating Sample Duration
I'm training an activity classifier with CreateML and when I add samples to the Preview tab, the length of the sample it displays does not match its actual length. I have set prediction window size to 15 and sample rate to 10. The activity is roughly 1.5 seconds. When I put a 1.49 second sample into preview, it says it is 00:00.06 seconds: and when I put a 12.91 second sample into preview, it says it is 00:00.52 seconds: Here is the code I am using to print out sensor data in csv format: if motionManager.isDeviceMotionAvailable { motionManager.deviceMotionUpdateInterval = 0.1 motionManager.startDeviceMotionUpdates(to: .main) { data, error in guard let data = data, let startTime = self.startTime else { return } let timestamp = Date().timeIntervalSince(startTime) let xAcc = data.userAcceleration.x let yAcc = data.userAcceleration.y let zAcc = data.userAcceleration.z let xRotRate = data.rotationRate.x let yRotRate = data.rotationRate.y let zRotRate = data.rotationRate.z let roll = data.attitude.roll let pitch = data.attitude.pitch let yaw = data.attitude.yaw let row = "\(timestamp),\(xAcc),\(yAcc),\(zAcc),\(xRotRate),\(yRotRate),\(zRotRate),\(roll),\(pitch),\(yaw)" print(row) } } And here is the data for the 1.49 second sample mentioned above:
0
0
806
Apr ’24
What is the maximum data processing speed?
For example: we use DocKit for birdwatching, so we have an unknown field distance and direction. Distance = ? Direction = ? For example, the rock from which the observation is made. The task is to recognize the number of birds caught in the frame, add a detection frame and collect statistics. Question: What is the maximum number of frames processed with custom object recognition? If not enough, can I do the calculations myself and transfer to DokKit for fast movement?
0
0
943
Apr ’24
CreateML debug log lines?
Where can I find CreateML logs? I'd like to inspect log lines if they exist to diagnose what kind of error the app encounters when I provide it training data for a multi-label image classifier and the UI displays "Data Analysis stopped". I do see some crash reports for "MLRecipeExecutionService" in the Console app which seem related, but I haven't spotted anything useful there yet.
1
3
987
Feb ’24
CreateML action classifier: wrist joint missing
Hi! I'd like to ask why after training an action classifier model using CreateML, I consistently fail to detect my wrist joint while using the live preview feature, while other joints are detected correctly. What could be causing this result? Thank you to anyone for providing answers. Training Data Sources: YouTube videos, searching keyword: "20min workout at home" All videos display the full body. Training Data Quantity: Model 1: Target action: 1 video / Irrelevant action: 1 video Model 2: Target action: 6 videos / Irrelevant action: 40 videos Both Model 1 and Model 2 fail to detect the wrist joint during live preview.
1
0
936
Sep ’23
[Create ML Components] The transformer is not representable as a CoreML model (ImageReader).
Following this guide https://developer.apple.com/documentation/CreateML/creating-a-multi-label-image-classifier Has anyone been able to export a CoreML model, specifically according to the documentation below? Since there isn't any runnable examples, just snippets, perhaps documentation error? If anyone is already familiar with these pipeline generics, is there something that jumps out about the example transformer used that fails conformance or just factually incorrect? Export the model to use with Vision After you train the model, you can export it as a Core ML model. // Export to Core ML let modelURL = URL(filePath: "/path/to/model") try model.export(to: modelURL)
2
1
1.1k
Sep ’23
Create ML Multi-Label Image Classifier will not train, throws error: "Unexpected Error"
Hello everyone, I am new to using Create ML, but am running up against a problem where the error is not descriptive, and I can not figure out what might be causing it. I am fairly sure my data is formatted properly, as in the CreateML software, it detects the images and shows me a bar graph of how many images belong to each label. But when it comes to actually training, the moment I press the "Train" button, it shows an error with the message: "Unexpected Error". I have also attempted to create and train the model programmatically, and that actually works! The framework requires that the JSON be named "annotations.json" instead of "annotation.json" and that the key representing the name of image be changed to "filename" from "image", but other than that, the data is the same. I tried to use the software with the changes I made to the JSON for use in the framework, but if I try that, it won't even parse the data, so I am fairly sure that my data is formatted correctly. I would prefer to use the app rather than do everything programmatically, because it presents the data in a much more digestible way. Has anyone else come up against this issue or a similar issue. I should note that I am running the latest Beta of MacOS Sonoma and Xcode.
7
0
2.2k
Sep ’23
Is it possible to import CreateML on an iOS project
Is it possible to use import CreateML on an iOS project? I'm looking at the code form the "Build dynamic iOS apps with the Create ML framework" video from this link https://developer.apple.com/videos/play/wwdc2021/10037/, but I'm not sure what kind of project I need to create. If I created an iOS project and tried running the code, what inputs would I need?
1
0
980
Jul ’23
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?
1
0
1.2k
Apr ’23
Evaluating image recognition models and obtaining preview results
I am training an image recognition model in CreateML. The model is ready, but I would like to have the data displayed in the evaluation view and preview in a CSV file. using the CSV file, I would like to identify the image files that have contributed to the accuracy of the model as a result of the training. I have searched the documentation but could not find a solution. If anyone knows of a solution, please let me know.
1
0
622
Jan ’23
Evaluating image recognition models and obtaining preview results
I am training an image recognition model in CreateML. The model is ready, but I would like to have the data displayed in the evaluation view and preview in a CSV file. using the CSV file, I would like to identify the image files that have contributed to the accuracy of the model as a result of the training. I have searched the documentation but could not find a solution. If anyone knows of a solution, please let me know.
0
0
625
Jan ’23
Linear Regression training using CreateML components and multiple iterations
Hello, I am currently stuck on a problem involving the newly released feature of CreateML components. I followed Get to know CreateML components, however, its not clear to me how this model can train with multiple iterations. I got a model to go through one iteration with the code shown in the video (it wasnt released as a project file), but there doesnt seem to be a way to increase the iterations. I also looked through the only associated project on CreateML components, but the code was different from what was described in that video and lacked the audio classifier example to see how it ticked. It was also mentioned in the video that there might be issues saving the model in a CoreML file format due to it being custom, but that leaves the question of how ones supposed to save the trained model once done. It seems like saving a model would be really beneficial to machine learning tasks, right? Here is the code I am using in swift playgrounds: truct ImageRegressor{ static let trainingDataURL = URL(fileURLWithPath: "Project/regression_label") static let parameterURL = URL(fileURLWithPath: "Project/parameters") static func train() async throws -> some Transformer<CIImage, Float>{ let estimator = ImageFeaturePrint() .appending(LinearRegressor()) let data = try AnnotatedFiles(labeledByNamesAt: trainingDataURL, separator: "-",type: .image) .mapFeatures(ImageReader.read) .mapAnnotations({_ in Float()}) let (training,validation) = data.randomSplit(by: 0.8) let transformer = try await estimator.fitted(to:training,validateOn: validation){ event in guard let trainingMaxError = event.metrics[.trainingMaximumError] else{ return } guard let validationMaxError = event.metrics[.validationMaximumError] else{ return } print("Training max error: \(trainingMaxError), Validation max error: \(validationMaxError)") } let validationError = try await meanAbsoluteError( transformer.applied(to: validation.map(\.feature)), validation.map(\.annotation)) print("Mean absolute error: \(validationError)") try estimator.write(transformer, to:parameterURL) return transformer } } func doSomething() { Task{ let transformer = try await ImageRegressor.train() } } doSomething()
0
0
977
Dec ’22
There is skiprow option in MLDataTable framework and I am wondering what would be the equivalent in Swift TabularData framework ?
I was working in this csv file and header in located in 4th row so how to skip 3 rows in TabularData framework. Note that skiprow option in available in MLDataTable framework as well as in Python's Panda import Foundation import TabularData let options = CSVReadingOptions( hasHeaderRow: false, nilEncodings: ["","nil"], ignoresEmptyLines: true ) let dataPath = " https://www2.census.gov/programs-surveys/saipe/datasets/time-series/model-tables/irs.csv" var dataFrame = try! DataFrame(contentsOfCSVFile: URL(string: dataPath)!, rows: 0..<15, options: options) print (dataFrame.description)
1
0
1.4k
Sep ’22
Create ML - Unexpected Error
I'm attempting to build a Create ML Image Classification model with 60k images and 4k classes. Each time I run it it manages to extract all the image features and run over 8 iterations but then when I come back to it it has stopped with "Unexpected Error". I ran it on a MacBook Air 2020 (Intel chip) a few times and then purchased a Mac mini M1 to try it on (256GB, 8GB ram - 160 GB free space), but the same happens. Are there any logs with more details of the errors? "Unexpected Error" doesn't give me anything to go on. Thanks.
1
1
1.2k
Aug ’22
Create ML cancels model training without explanations
I‘ve created text classification project and selected BERT algorithm With 100 iterations for json file. Json file is valid but training always cancels on 37 iteration… Because tool does not provide any cancellation reasons I have no clue why it happens. Can I check reasons somehow? Or do anyone knows possible reasons or solutions for this?
Replies
1
Boosts
0
Views
841
Activity
Jul ’24
Question about ARKit Object Tracking Capabilities
Hi everyone, I'm curious about the capabilities of ARKit's object tracking feature. Specifically, I'd like to know: Is there a size limit for the objects that can be tracked? Can ARKit differentiate between two objects with the same shape but different models (e.g., different colors)? Are objects with single colors and generic shapes (like squares or circles) effectively trackable? Any insights or examples from your experiences would be greatly appreciated! Thanks in advance.
Replies
1
Boosts
0
Views
959
Activity
Jul ’24
TimeseriesClassifier crash when update
TimeseriesClassifier crash when update as follows:
Replies
1
Boosts
0
Views
756
Activity
Jul ’24
On device training of text classifier model
I have made a text classifier model but I want to train it on device too. When text is classified wrong, user can make update the model on device. Code : // // SpamClassifierHelper.swift // LearningML // // Created by Himan Dhawan on 7/1/24. // import Foundation import CreateMLComponents import CoreML import NaturalLanguage enum TextClassifier : String { case spam = "spam" case notASpam = "ham" } class SpamClassifierModel { // MARK: - Private Type Properties /// The updated Spam Classifier model. private static var updatedSpamClassifier: SpamClassifier? /// The default Spam Classifier model. private static var defaultSpamClassifier: SpamClassifier { do { return try SpamClassifier(configuration: .init()) } catch { fatalError("Couldn't load SpamClassifier due to: \(error.localizedDescription)") } } // The Spam Classifier model currently in use. static var liveModel: SpamClassifier { updatedSpamClassifier ?? defaultSpamClassifier } /// The location of the app's Application Support directory for the user. private static let appDirectory = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first! class var urlOfModelInThisBundle : URL { let bundle = Bundle(for: self) return bundle.url(forResource: "SpamClassifier", withExtension:"mlmodelc")! } /// The default Spam Classifier model's file URL. private static let defaultModelURL = urlOfModelInThisBundle /// The permanent location of the updated Spam Classifier model. private static var updatedModelURL = appDirectory.appendingPathComponent("personalized.mlmodelc") /// The temporary location of the updated Spam Classifier model. private static var tempUpdatedModelURL = appDirectory.appendingPathComponent("personalized_tmp.mlmodelc") // MARK: - Public Type Methods static func predictLabelFor(_ value: String) throws -> (predication :String?, confidence : String) { let spam = try NLModel(mlModel: liveModel.model) let result = spam.predictedLabel(for: value) let confidence = spam.predictedLabelHypotheses(for: value, maximumCount: 1).first?.value ?? 0 return (result,String(format: "%.2f", confidence * 100)) } static func updateModel(newEntryText : String, spam : TextClassifier) throws { guard let modelURL = Bundle.main.url(forResource: "SpamClassifier", withExtension: "mlmodelc") else { fatalError("Could not find model in bundle") } // Create feature provider for the new image let featureProvider = try MLDictionaryFeatureProvider(dictionary: ["label": MLFeatureValue(string: newEntryText), "text": MLFeatureValue(string: spam.rawValue)]) let batchProvider = MLArrayBatchProvider(array: [featureProvider]) let updateTask = try MLUpdateTask(forModelAt: modelURL, trainingData: batchProvider, configuration: nil, completionHandler: { context in let updatedModel = context.model let fileManager = FileManager.default do { // Create a directory for the updated model. try fileManager.createDirectory(at: tempUpdatedModelURL, withIntermediateDirectories: true, attributes: nil) // Save the updated model to temporary filename. try updatedModel.write(to: tempUpdatedModelURL) // Replace any previously updated model with this one. _ = try fileManager.replaceItemAt(updatedModelURL, withItemAt: tempUpdatedModelURL) loadUpdatedModel() print("Updated model saved to:\n\t\(updatedModelURL)") } catch let error { print("Could not save updated model to the file system: \(error)") return } }) updateTask.resume() } /// Loads the updated Spam Classifier, if available. /// - Tag: LoadUpdatedModel private static func loadUpdatedModel() { guard FileManager.default.fileExists(atPath: updatedModelURL.path) else { // The updated model is not present at its designated path. return } // Create an instance of the updated model. guard let model = try? SpamClassifier(contentsOf: updatedModelURL) else { return } // Use this updated model to make predictions in the future. updatedSpamClassifier = model } }
Replies
1
Boosts
0
Views
808
Activity
Jul ’24
timeseriesclassifier
After I have a dataframe of data with one column as features with type MLshapedarray and one column of annotations with type Int. How can I convert them to the correct input type for the timeseriesclassifier?
Replies
0
Boosts
0
Views
667
Activity
Jul ’24
Change the training folder of Create ML
Is it possible to change the folder where .blob are stocked when we training a model ? I trying to train a model to track an object, and I'm limited to the extraordinary 256Gb of my 2024 Mac ! :(
Replies
0
Boosts
0
Views
689
Activity
Jun ’24
CreateML Preview Tab Miscalculating Sample Duration
I'm training an activity classifier with CreateML and when I add samples to the Preview tab, the length of the sample it displays does not match its actual length. I have set prediction window size to 15 and sample rate to 10. The activity is roughly 1.5 seconds. When I put a 1.49 second sample into preview, it says it is 00:00.06 seconds: and when I put a 12.91 second sample into preview, it says it is 00:00.52 seconds: Here is the code I am using to print out sensor data in csv format: if motionManager.isDeviceMotionAvailable { motionManager.deviceMotionUpdateInterval = 0.1 motionManager.startDeviceMotionUpdates(to: .main) { data, error in guard let data = data, let startTime = self.startTime else { return } let timestamp = Date().timeIntervalSince(startTime) let xAcc = data.userAcceleration.x let yAcc = data.userAcceleration.y let zAcc = data.userAcceleration.z let xRotRate = data.rotationRate.x let yRotRate = data.rotationRate.y let zRotRate = data.rotationRate.z let roll = data.attitude.roll let pitch = data.attitude.pitch let yaw = data.attitude.yaw let row = "\(timestamp),\(xAcc),\(yAcc),\(zAcc),\(xRotRate),\(yRotRate),\(zRotRate),\(roll),\(pitch),\(yaw)" print(row) } } And here is the data for the 1.49 second sample mentioned above:
Replies
0
Boosts
0
Views
806
Activity
Apr ’24
What is the maximum data processing speed?
For example: we use DocKit for birdwatching, so we have an unknown field distance and direction. Distance = ? Direction = ? For example, the rock from which the observation is made. The task is to recognize the number of birds caught in the frame, add a detection frame and collect statistics. Question: What is the maximum number of frames processed with custom object recognition? If not enough, can I do the calculations myself and transfer to DokKit for fast movement?
Replies
0
Boosts
0
Views
943
Activity
Apr ’24
CreateML debug log lines?
Where can I find CreateML logs? I'd like to inspect log lines if they exist to diagnose what kind of error the app encounters when I provide it training data for a multi-label image classifier and the UI displays "Data Analysis stopped". I do see some crash reports for "MLRecipeExecutionService" in the Console app which seem related, but I haven't spotted anything useful there yet.
Replies
1
Boosts
3
Views
987
Activity
Feb ’24
CreateML action classifier: wrist joint missing
Hi! I'd like to ask why after training an action classifier model using CreateML, I consistently fail to detect my wrist joint while using the live preview feature, while other joints are detected correctly. What could be causing this result? Thank you to anyone for providing answers. Training Data Sources: YouTube videos, searching keyword: "20min workout at home" All videos display the full body. Training Data Quantity: Model 1: Target action: 1 video / Irrelevant action: 1 video Model 2: Target action: 6 videos / Irrelevant action: 40 videos Both Model 1 and Model 2 fail to detect the wrist joint during live preview.
Replies
1
Boosts
0
Views
936
Activity
Sep ’23
[Create ML Components] The transformer is not representable as a CoreML model (ImageReader).
Following this guide https://developer.apple.com/documentation/CreateML/creating-a-multi-label-image-classifier Has anyone been able to export a CoreML model, specifically according to the documentation below? Since there isn't any runnable examples, just snippets, perhaps documentation error? If anyone is already familiar with these pipeline generics, is there something that jumps out about the example transformer used that fails conformance or just factually incorrect? Export the model to use with Vision After you train the model, you can export it as a Core ML model. // Export to Core ML let modelURL = URL(filePath: "/path/to/model") try model.export(to: modelURL)
Replies
2
Boosts
1
Views
1.1k
Activity
Sep ’23
Create ML Multi-Label Image Classifier will not train, throws error: "Unexpected Error"
Hello everyone, I am new to using Create ML, but am running up against a problem where the error is not descriptive, and I can not figure out what might be causing it. I am fairly sure my data is formatted properly, as in the CreateML software, it detects the images and shows me a bar graph of how many images belong to each label. But when it comes to actually training, the moment I press the "Train" button, it shows an error with the message: "Unexpected Error". I have also attempted to create and train the model programmatically, and that actually works! The framework requires that the JSON be named "annotations.json" instead of "annotation.json" and that the key representing the name of image be changed to "filename" from "image", but other than that, the data is the same. I tried to use the software with the changes I made to the JSON for use in the framework, but if I try that, it won't even parse the data, so I am fairly sure that my data is formatted correctly. I would prefer to use the app rather than do everything programmatically, because it presents the data in a much more digestible way. Has anyone else come up against this issue or a similar issue. I should note that I am running the latest Beta of MacOS Sonoma and Xcode.
Replies
7
Boosts
0
Views
2.2k
Activity
Sep ’23
CreateML tabular regression ... SVM model?
does anyone know if the CreateML app has a way to build Support Vector Machine models for tabular regression? I see only the attached options. xcode14.2
Replies
1
Boosts
0
Views
1.2k
Activity
Aug ’23
Is it possible to import CreateML on an iOS project
Is it possible to use import CreateML on an iOS project? I'm looking at the code form the "Build dynamic iOS apps with the Create ML framework" video from this link https://developer.apple.com/videos/play/wwdc2021/10037/, but I'm not sure what kind of project I need to create. If I created an iOS project and tried running the code, what inputs would I need?
Replies
1
Boosts
0
Views
980
Activity
Jul ’23
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
1
Boosts
0
Views
1.2k
Activity
Apr ’23
Evaluating image recognition models and obtaining preview results
I am training an image recognition model in CreateML. The model is ready, but I would like to have the data displayed in the evaluation view and preview in a CSV file. using the CSV file, I would like to identify the image files that have contributed to the accuracy of the model as a result of the training. I have searched the documentation but could not find a solution. If anyone knows of a solution, please let me know.
Replies
1
Boosts
0
Views
622
Activity
Jan ’23
Evaluating image recognition models and obtaining preview results
I am training an image recognition model in CreateML. The model is ready, but I would like to have the data displayed in the evaluation view and preview in a CSV file. using the CSV file, I would like to identify the image files that have contributed to the accuracy of the model as a result of the training. I have searched the documentation but could not find a solution. If anyone knows of a solution, please let me know.
Replies
0
Boosts
0
Views
625
Activity
Jan ’23
Linear Regression training using CreateML components and multiple iterations
Hello, I am currently stuck on a problem involving the newly released feature of CreateML components. I followed Get to know CreateML components, however, its not clear to me how this model can train with multiple iterations. I got a model to go through one iteration with the code shown in the video (it wasnt released as a project file), but there doesnt seem to be a way to increase the iterations. I also looked through the only associated project on CreateML components, but the code was different from what was described in that video and lacked the audio classifier example to see how it ticked. It was also mentioned in the video that there might be issues saving the model in a CoreML file format due to it being custom, but that leaves the question of how ones supposed to save the trained model once done. It seems like saving a model would be really beneficial to machine learning tasks, right? Here is the code I am using in swift playgrounds: truct ImageRegressor{ static let trainingDataURL = URL(fileURLWithPath: "Project/regression_label") static let parameterURL = URL(fileURLWithPath: "Project/parameters") static func train() async throws -> some Transformer<CIImage, Float>{ let estimator = ImageFeaturePrint() .appending(LinearRegressor()) let data = try AnnotatedFiles(labeledByNamesAt: trainingDataURL, separator: "-",type: .image) .mapFeatures(ImageReader.read) .mapAnnotations({_ in Float()}) let (training,validation) = data.randomSplit(by: 0.8) let transformer = try await estimator.fitted(to:training,validateOn: validation){ event in guard let trainingMaxError = event.metrics[.trainingMaximumError] else{ return } guard let validationMaxError = event.metrics[.validationMaximumError] else{ return } print("Training max error: \(trainingMaxError), Validation max error: \(validationMaxError)") } let validationError = try await meanAbsoluteError( transformer.applied(to: validation.map(\.feature)), validation.map(\.annotation)) print("Mean absolute error: \(validationError)") try estimator.write(transformer, to:parameterURL) return transformer } } func doSomething() { Task{ let transformer = try await ImageRegressor.train() } } doSomething()
Replies
0
Boosts
0
Views
977
Activity
Dec ’22
There is skiprow option in MLDataTable framework and I am wondering what would be the equivalent in Swift TabularData framework ?
I was working in this csv file and header in located in 4th row so how to skip 3 rows in TabularData framework. Note that skiprow option in available in MLDataTable framework as well as in Python's Panda import Foundation import TabularData let options = CSVReadingOptions( hasHeaderRow: false, nilEncodings: ["","nil"], ignoresEmptyLines: true ) let dataPath = " https://www2.census.gov/programs-surveys/saipe/datasets/time-series/model-tables/irs.csv" var dataFrame = try! DataFrame(contentsOfCSVFile: URL(string: dataPath)!, rows: 0..<15, options: options) print (dataFrame.description)
Replies
1
Boosts
0
Views
1.4k
Activity
Sep ’22
Create ML - Unexpected Error
I'm attempting to build a Create ML Image Classification model with 60k images and 4k classes. Each time I run it it manages to extract all the image features and run over 8 iterations but then when I come back to it it has stopped with "Unexpected Error". I ran it on a MacBook Air 2020 (Intel chip) a few times and then purchased a Mac mini M1 to try it on (256GB, 8GB ram - 160 GB free space), but the same happens. Are there any logs with more details of the errors? "Unexpected Error" doesn't give me anything to go on. Thanks.
Replies
1
Boosts
1
Views
1.2k
Activity
Aug ’22