<commit_before># Swift-HAR

Human activity recognition on iPhones using Swift.
Feed-Forward Neural Network from Swift-AI by <NAME>.
FFNN Swift-AI files are from the version present in SwiftOCR project by Garnele007.

## Notes

### Code outline:
Summary: Look at the accelerometer and gyro data to predict whether a user is sitting, walking, or running.
1. Read accelerometer and gyro data for 1 activity for 30 seconds.
2. Write the recorded data from memory to a file along with a tag.
4. Create multiple data files by using a sliding window to sample the 30 second data.
2. Split the data into a training and a testing set. 
3. Train the classifier (maybe SVM or FFN).
4. Test the classifier with a subset of test data.

### Machine learning APIs in Swift for iOS
1. Swift-AI
2. Swift-Brain

### References:
1. http://systemg.research.ibm.com/ma-sensoranalytics.html
2. https://medium.com/@robringham/ios-motion-data-machine-learning-with-swift-and-r-1291f9ab7379#.p7x241ci4
3. http://blog.telenor.io/2015/10/26/machine-learning.html
4. http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=6838194
5. http://www.icephd.org/sites/default/files/IWAAL2012.pdf
6. https://www.hackingwithswift.com/example-code/system/how-to-use-core-motion-to-read-accelerometer-data
7. http://nshipster.com/cmdevicemotion/
8. https://medium.com/@0xben/using-github-with-xcode-6-8208b92c7a60#.tztc1xfqr
9. http://www.mydrivesolutions.com/engineering/swift-data-collection/

### Swift Tutorials:
1. https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html
2. https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/
3. Accelerometer data recorder: https://developer.apple.com/reference/coremotion/cmsensorrecorder
4. <NAME>'s tutorial on "Swift Tutorial: Core Motion (Accelerometer/Gyroscope)"
5. https://www.sitepoint.com/creating-hello-world-app-swift/

### Swift StackExchange threads:
1. http://stackoverflow.com/questions/24097826/read-and-write-data-from-text-file<commit_msg>Fixed code outline and progress<commit_after># Swift-HAR

Human activity recognition on iPhones using Swift, CoreMotion, and a
Feed-Forward Neural Network from Swift-AI.

## Progress
- [x] UI to display results and gather user input.
- [x] Data logger to record accelerometer data from an iPhone 6s.
- [x] Data exporter to save data in CSV format.
- [x] Bootstrapper to create testing and training data for the NeuralNet.
- [x] Set up and configure the NeuralNet object for activity classification.
- [x] Hook up the NeuralNet to classify untagged user activity.
- [x] Midnight dance party cause it works!
- [ ] Rewrite the spaghetti code in the ViewController into classes.
- [ ] Add support for additional activities (running, sit ups, weight lifting, etc.)

## Notes

### Current Code outline:
Summary: Use accelerometer data to predict whether a user is standing or walking.
1. Read accelerometer data for 1 activity for 10 seconds.
2. Tag the data as standing or walking.
3. Repeat steps 1 and 2 for the second activity.
4. Bootstrap the recorded data using a 1 second window to create training and testing files for the NeuralNet.
5. Train the NeuralNet based on the training and testing file.
6. Now the NeuralNet is ready to classify user activities.

### Machine learning APIs in Swift for iOS
1. [NeuralNet module from Swift-AI by <NAME>.](https://github.com/Swift-AI/NeuralNet)

### References:
1. http://systemg.research.ibm.com/ma-sensoranalytics.html
2. https://medium.com/@robringham/ios-motion-data-machine-learning-with-swift-and-r-1291f9ab7379#.p7x241ci4
3. http://blog.telenor.io/2015/10/26/machine-learning.html
4. http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=6838194
5. http://www.icephd.org/sites/default/files/IWAAL2012.pdf
6. https://www.hackingwithswift.com/example-code/system/how-to-use-core-motion-to-read-accelerometer-data
7. http://nshipster.com/cmdevicemotion/
8. https://medium.com/@0xben/using-github-with-xcode-6-8208b92c7a60#.tztc1xfqr
9. http://www.mydrivesolutions.com/engineering/swift-data-collection/

### Swift Tutorials:
1. https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html
2. https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/
3. Accelerometer data recorder: https://developer.apple.com/reference/coremotion/cmsensorrecorder
4. <NAME>'s tutorial on "Swift Tutorial: Core Motion (Accelerometer/Gyroscope)"
5. https://www.sitepoint.com/creating-hello-world-app-swift/

### Swift StackExchange threads:
1. http://stackoverflow.com/questions/24097826/read-and-write-data-from-text-file
{'fraction_non_alphanumeric': 0.11299915038232795, 'fraction_numerical': 0.03525913338997451, 'mean_word_length': 4.507602339181287, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 15, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2289610', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1479, 'n_words': 432}