AWSMachineLearning Class Reference

Inherits from AWSService : NSObject
Declared in AWSMachineLearningService.h
AWSMachineLearningService.m

Overview

Definition of the public APIs exposed by Amazon Machine Learning

  configuration

The service configuration used to instantiate this service client.

@property (nonatomic, strong, readonly) AWSServiceConfiguration *configuration

Discussion

Warning: Once the client is instantiated, do not modify the configuration object. It may cause unspecified behaviors.

Declared In

AWSMachineLearningService.h

+ defaultMachineLearning

Returns the singleton service client. If the singleton object does not exist, the SDK instantiates the default service client with defaultServiceConfiguration from [AWSServiceManager defaultServiceManager]. The reference to this object is maintained by the SDK, and you do not need to retain it manually.

+ (instancetype)defaultMachineLearning

Return Value

The default service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
    let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
    AWSServiceManager.default().defaultServiceConfiguration = configuration

    return true
}

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                      identityPoolId:@"YourIdentityPoolId"];
      AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
                                                                           credentialsProvider:credentialsProvider];
      [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;

      return YES;
  }

Then call the following to get the default service client:

Swift

 let MachineLearning = AWSMachineLearning.default()

Objective-C

 AWSMachineLearning *MachineLearning = [AWSMachineLearning defaultMachineLearning];

Declared In

AWSMachineLearningService.h

+ registerMachineLearningWithConfiguration:forKey:

Creates a service client with the given service configuration and registers it for the key.

+ (void)registerMachineLearningWithConfiguration:(AWSServiceConfiguration *)configuration forKey:(NSString *)key

Parameters

configuration

A service configuration object.

key

A string to identify the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
    let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
    AWSMachineLearning.register(with: configuration!, forKey: "USWest2MachineLearning")

    return true
}

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                     identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                          credentialsProvider:credentialsProvider];

     [AWSMachineLearning registerMachineLearningWithConfiguration:configuration forKey:@"USWest2MachineLearning"];

     return YES;
 }

Then call the following to get the service client:

Swift

 let MachineLearning = AWSMachineLearning(forKey: "USWest2MachineLearning")

Objective-C

 AWSMachineLearning *MachineLearning = [AWSMachineLearning MachineLearningForKey:@"USWest2MachineLearning"];

Warning: After calling this method, do not modify the configuration object. It may cause unspecified behaviors.

Declared In

AWSMachineLearningService.h

+ MachineLearningForKey:

Retrieves the service client associated with the key. You need to call + registerMachineLearningWithConfiguration:forKey: before invoking this method.

+ (instancetype)MachineLearningForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Return Value

An instance of the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
    let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
    AWSMachineLearning.register(with: configuration!, forKey: "USWest2MachineLearning")

    return true
}

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                     identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                          credentialsProvider:credentialsProvider];

     [AWSMachineLearning registerMachineLearningWithConfiguration:configuration forKey:@"USWest2MachineLearning"];

     return YES;
 }

Then call the following to get the service client:

Swift

 let MachineLearning = AWSMachineLearning(forKey: "USWest2MachineLearning")

Objective-C

 AWSMachineLearning *MachineLearning = [AWSMachineLearning MachineLearningForKey:@"USWest2MachineLearning"];

Declared In

AWSMachineLearningService.h

+ removeMachineLearningForKey:

Removes the service client associated with the key and release it.

+ (void)removeMachineLearningForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Discussion

Warning: Before calling this method, make sure no method is running on this client.

Declared In

AWSMachineLearningService.h

– getMLModel:

Returns an MLModel that includes detailed metadata, and data source information as well as the current status of the MLModel.

GetMLModel provides results in normal or verbose format.

- (AWSTask<AWSMachineLearningGetMLModelOutput*> *)getMLModel:(AWSMachineLearningGetMLModelInput *)request

Parameters

request

A container for the necessary parameters to execute the GetMLModel service method.

Return Value

An instance of AWSTask. On successful execution, task.result will contain an instance of AWSMachineLearningGetMLModelOutput. On failed execution, task.error may contain an NSError with AWSMachineLearningErrorDomain domain and the following error code: AWSMachineLearningErrorInvalidInput, AWSMachineLearningErrorResourceNotFound, AWSMachineLearningErrorInternalServer.

Declared In

AWSMachineLearningService.h

– getMLModel:completionHandler:

Returns an MLModel that includes detailed metadata, and data source information as well as the current status of the MLModel.

GetMLModel provides results in normal or verbose format.

- (void)getMLModel:(AWSMachineLearningGetMLModelInput *)request completionHandler:(void ( ^ _Nullable ) ( AWSMachineLearningGetMLModelOutput *_Nullable response , NSError *_Nullable error ))completionHandler

Parameters

request

A container for the necessary parameters to execute the GetMLModel service method.

completionHandler

The completion handler to call when the load request is complete. response - A response object, or nil if the request failed. error - An error object that indicates why the request failed, or nil if the request was successful. On failed execution, error may contain an NSError with AWSMachineLearningErrorDomain domain and the following error code: AWSMachineLearningErrorInvalidInput, AWSMachineLearningErrorResourceNotFound, AWSMachineLearningErrorInternalServer.

Declared In

AWSMachineLearningService.h

– predict:

Generates a prediction for the observation using the specified MLModel.

Note

Not all response parameters will be populated because this is dependent on the type of requested model.

- (AWSTask<AWSMachineLearningPredictOutput*> *)predict:(AWSMachineLearningPredictInput *)request

Parameters

request

A container for the necessary parameters to execute the Predict service method.

Return Value

An instance of AWSTask. On successful execution, task.result will contain an instance of AWSMachineLearningPredictOutput. On failed execution, task.error may contain an NSError with AWSMachineLearningErrorDomain domain and the following error code: AWSMachineLearningErrorInvalidInput, AWSMachineLearningErrorResourceNotFound, AWSMachineLearningErrorLimitExceeded, AWSMachineLearningErrorInternalServer, AWSMachineLearningErrorPredictorNotMounted.

Declared In

AWSMachineLearningService.h

– predict:completionHandler:

Generates a prediction for the observation using the specified MLModel.

Note

Not all response parameters will be populated because this is dependent on the type of requested model.

- (void)predict:(AWSMachineLearningPredictInput *)request completionHandler:(void ( ^ _Nullable ) ( AWSMachineLearningPredictOutput *_Nullable response , NSError *_Nullable error ))completionHandler

Parameters

request

A container for the necessary parameters to execute the Predict service method.

completionHandler

The completion handler to call when the load request is complete. response - A response object, or nil if the request failed. error - An error object that indicates why the request failed, or nil if the request was successful. On failed execution, error may contain an NSError with AWSMachineLearningErrorDomain domain and the following error code: AWSMachineLearningErrorInvalidInput, AWSMachineLearningErrorResourceNotFound, AWSMachineLearningErrorLimitExceeded, AWSMachineLearningErrorInternalServer, AWSMachineLearningErrorPredictorNotMounted.

Declared In

AWSMachineLearningService.h