View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Videos

Abrir menú Cerrar menú
  • Colecciones
  • Todos los videos
  • Información

Más videos

  • Información
  • Código
  • Get to know Create ML Components

    Create ML makes it easy to build custom machine learning models for image classification, object detection, sound classification, hand pose classification, action classification, tabular data regression, and more. And with the Create ML Components framework, you can further customize underlying tasks and improve your model. We'll explore the feature extractors, transformers, and estimators that make up these tasks, and show you how you can combine them with other components and pre-processing steps to build custom tasks for concepts like image regression.

    For more information on creating complex customizable tasks, we recommend watching "Compose advanced models with Create ML Components" from WWDC22.

    Recursos

    • Create ML
      • Video HD
      • Video SD

    Videos relacionados

    WWDC23

    • Discover machine learning enhancements in Create ML

    WWDC22

    • Compose advanced models with Create ML Components
    • What's new in Create ML

    WWDC21

    • Build dynamic iOS apps with the Create ML framework
    • Classify hand poses and actions with Create ML

    Tech Talks

    • Explore and manipulate data in Swift with TabularData

    WWDC20

    • Swift packages: Resources and localization

    WWDC19

    • Understanding Images in Vision Framework
  • Buscar este video…
    • 8:59 - Image regressor

      import CoreImage
      import CreateMLComponents
      
      struct ImageRegressor {
          static let trainingDataURL = URL(fileURLWithPath: "~/Desktop/bananas")
          static let parametersURL = URL(fileURLWithPath: "~/Desktop/parameters")
      
          static func train() async throws -> some Transformer<CIImage, Float> {
              let estimator = ImageFeaturePrint()
                  .appending(LinearRegressor())
      
              // File name example: banana-5.jpg
              let data = try AnnotatedFiles(labeledByNamesAt: trainingDataURL, separator: "-", index: 1, type: .image)
                  .mapFeatures(ImageReader.read)
                  .mapAnnotations({ Float($0)! })
      
              let (training, validation) = data.randomSplit(by: 0.8)
              let transformer = try await estimator.fitted(to: training, validateOn: validation)
              try estimator.write(transformer, to: parametersURL)
      
              return transformer
          }
      }
    • 12:18 - Image regressor with metrics and augmentations

      import CoreImage
      import CreateMLComponents
      
      struct ImageRegressor {
          static let trainingDataURL = URL(fileURLWithPath: "~/Desktop/bananas")
          static let parametersURL = URL(fileURLWithPath: "~/Desktop/parameters")
      
          static func train() async throws -> some Transformer<CIImage, Float> {
              let estimator = SaliencyCropper()
                  .appending(ImageFeaturePrint())
                  .appending(LinearRegressor())
      
              // File name example: banana-5.jpg
              let data = try AnnotatedFiles(labeledByNamesAt: trainingDataURL, separator: "-", index: 1, type: .image)
                  .mapFeatures(ImageReader.read)
                  .mapAnnotations({ Float($0)! })
                  .flatMap(augment)
      
              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: parametersURL)
      
              return transformer
          }
      
          static func augment(_ original: AnnotatedFeature<CIImage, Float>) -> [AnnotatedFeature<CIImage, Float>] {
              let angle = CGFloat.random(in: -.pi ... .pi)
              let rotated = original.feature.transformed(by: .init(rotationAngle: angle))
      
              let scale = CGFloat.random(in: 0.8 ... 1.2)
              let scaled = original.feature.transformed(by: .init(scaleX: scale, y: scale))
      
              return [
                  original,
                  AnnotatedFeature(feature: rotated, annotation: original.annotation),
                  AnnotatedFeature(feature: scaled, annotation: original.annotation),
              ]
          }
      }
    • 20:23 - Tabular regressor

      import CreateMLComponents
      import Foundation
      import TabularData
      
      struct TabularRegressor {
          static let dataURL = URL(fileURLWithPath: "~/Downloads/avocado.csv")
          static let parametersURL = URL(fileURLWithPath: "~/Downloads/parameters.pkg")
      
          static let priceColumnID = ColumnID("price", Double.self)
      
          static var task: some SupervisedTabularEstimator {
              let numeric = ColumnSelector(
                  columns: ["volume"],
                  estimator: OptionalUnwrapper()
                      .appending(StandardScaler<Double>())
              )
              let regression = BoostedTreeRegressor<String>(
                  annotationColumnName: priceColumnID.name,
                  featureColumnNames: ["type", "region", "volume"]
              )
      
              return numeric.appending(regression)
          }
      
          static func train() async throws -> some TabularTransformer {
              let dataFrame = try DataFrame(contentsOfCSVFile: dataURL)
              let (training, validation) = dataFrame.randomSplit(by: 0.8)
              let transformer = try await task.fitted(to: DataFrame(training), validateOn: DataFrame(validation)) { event in
                  guard let validationError = event.metrics[.validationError] as? Double else {
                      return
                  }
                  print("Validation error: \(validationError)")
              }
              try task.write(transformer, to: parametersURL)
              return transformer
          }
      
          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]!
          }
      }

Developer Footer

  • Videos
  • WWDC22
  • Get to know Create ML Components
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines