This is an example iOS Application for the Enabyl Foresight framework. The application provides examples of three major functions of the SwiftyForesight
API:
To run the application, first install the necessary pods by including pod SwiftyForesight
in the application's podfile and running pod install
. All the necessary AWS dependencies are installed by Cocoapods automatically. The application must then be connected to the user's own AWS resources. If an awsconfiguration.json file has been provided (or if it has been downloaded from the AWS Mobile Hub), include it in the application bundle. Then update the following lines of code in ViewController.swift:
let identityID = "<your_identity_ID>" // AWS Identity ID
let writeBucket = "<your_write_bucket>" // AWS Write Bucket Name
let readBucket = "<your_read_bucket>" // AWS Read Bucket Name
let tableName = "<your_table_name>" // AWS DynamoDB Table Name
The identityID
, readBucket
, and writeBucket
may be copied from the awsconfiguration.json file, and the DynamoDB table name is optional for writing metadata to a DynamoDB database.
Data for upload is first generated by tapping the Generate Data button. The appliction populates the LibraData
object with training data and metadata. Note that the user may optionally choose a unique userID
for their device by entering it in the text field at the top of the screen. Once complete, the status text label on the display will change to "Generated Data". Generating data activates the Upload Data button, which formats and uploads training data and metadata to AWS resources. When data upload is complete, the status text label will read "Uploaded Data (2)".
The application fetches a generic softmax .mlmodel file from a remote server and compiles it in a LibraModel
subclass (FeedforwardModel
) when Retrieve Model is tapped. If the user is using an awsconfiguration.json file provided by Enabyl, the specified read bucket will contain this file; otherwise, the .mlmodel file is provided in the application bundle if the user is providing their own AWS backend resources. If successful, the status text label will read "Retrieved Model".
Tapping Generate Predictions will generate a prediction from the compiled model using generated data. If the model has been compiled correctly, the output of the softmax layer should approach [1, 0, 0]
. This is because the default model for the device is trained to output [0, 0, 1]
, however the training data uploaded to the server re-maps the output to [1, 0, 0]
. To verify that the application has performed correctly, the three green prediction indicator icons below the buttons visually display the softmax output, with green being 1 and white being 0 -- predictions are also printed to the console if the user is running the application through XCode. If predictions were generated correctly, the status label will read "Generated Predictions"; else, it will read "Error Generating Predictions".