From abb1019b3d6807803433ed00c1270cae4bbb6188 Mon Sep 17 00:00:00 2001 From: Nelson Joseph <63466039+nelson123-lab@users.noreply.github.com> Date: Wed, 10 May 2023 01:31:39 -0500 Subject: [PATCH 1/5] Update ReadingMaterial.md --- notes/ReadingMaterial.md | 55 ++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/notes/ReadingMaterial.md b/notes/ReadingMaterial.md index a083591..a45910c 100644 --- a/notes/ReadingMaterial.md +++ b/notes/ReadingMaterial.md @@ -24,18 +24,51 @@ ## Datasets -1. [Gym Exercise Dataset](https://www.kaggle.com/datasets/niharika41298/gym-exercise-data/code) +1. [Gym Exercise Dataset](https://www.kaggle.com/datasets/niharika41298/gym-exercise-data/code) +- Different Exercises title and their description in different columns. It also has what type of exercise it is and what body part it has most impact. +2. [Human Activity Recognition Using Smartphones Data Set](https://archive.ics.uci.edu/ml/datasets/human+activity+recognition+using+smartphones) +- Exercise performed by people that includes six activities (WALKING, WALKING_UPSTAIRS, WALKING_DOWNSTAIRS, SITTING, STANDING, LAYING) +3. [FitBit Fitness Tracker Data](https://www.kaggle.com/datasets/arashnic/fitbit/code) +- Data showing daily calories burned by people through different exercises. (18 csv files only some are useful) +4. [Workout Exercises Video](https://www.kaggle.com/datasets/hasyimabdillah/workoutfitness-video) +- Video data of people doing all types of exercises with each exercise videos in their name folder. Will be useful in future when we are developing app. +5. [2018 calorie, exercise and weight changes](https://www.kaggle.com/datasets/chrisbow/2018-calorie-exercise-and-weight-changes) +- Data showing the food intake weight, ounces and calories intake. +6. [Fitness Trackers Products Ecommerce](https://www.kaggle.com/datasets/devsubhash/fitness-trackers-products-ecommerce) +- Fitness products and their brands, materials etc. +7. [Lifesnaps Fitbit dataset](https://www.kaggle.com/datasets/skywescar/lifesnaps-fitbit-dataset) +- Hourly bpm, temperature, activity etc not aligned with our data requirements. +8. [Yoga Pose Image classification dataset](https://www.kaggle.com/datasets/shrutisaxena/yoga-pose-image-classification-dataset) +- Different yoga pose images in their respective folders. +9. [Food and their calories](https://www.kaggle.com/datasets/vaishnavivenkatesan/food-and-their-calories) +- Different types of food and their respective calories. Will be useful in future if we are adding a dietery meal information. +10. [Fitness Trends Dataset](https://www.kaggle.com/datasets/aroojanwarkhan/fitness-data-trends) +- Step count, calories, sleep hours, blood pressure and weights +- parameters can be used for profile building. +11. [Yoga Posture Dataset](https://www.kaggle.com/datasets/tr1gg3rtrash/yoga-posture-dataset) +- Yoga images postures not useful for our data requirements. +12. [Apple Watch and Fitbit data](https://www.kaggle.com/datasets/aleespinosa/apple-watch-and-fitbit-data) +- Age, height, weight, heart_rate and calories. +13. [Workout/Exercise Images](https://www.kaggle.com/datasets/hasyimabdillah/workoutexercises-images) +- Workout images can be used for app in future. +14. [🏋️‍♀️🏋️‍♂️Fitness Exercises🏋️‍♀️🏋️‍♂️](https://www.kaggle.com/datasets/edoardoba/fitness-exercises-with-animations) +- Exercise Names and what body part the exerciese is useful for. +15. [Fitness Analysis](https://www.kaggle.com/datasets/nithilaa/fitness-analysis) +- Fitness analysis of different people exercises and there outcomes. +16. [Calories Burned During Exercise and Activities](https://www.kaggle.com/datasets/aadhavvignesh/calories-burned-during-exercise-and-activities) +- Calories burned in different exercises. +17. [Fitness Consumer Survey Data](https://www.kaggle.com/datasets/harshitaaswani/fitness-consumer-survey-data) +- Exercise survey data of different people how often they do exercises. +18. [powerlifting-database](https://www.kaggle.com/datasets/dansbecker/powerlifting-database) +- Power lifting data information not really useful over here. +19. [Crossfit Athletes](https://www.kaggle.com/datasets/ulrikthygepedersen/crossfit-athletes) +- Data related to team competitions not userful over here. +20. [Yoga Vid Collected](https://www.kaggle.com/datasets/pulaksarmah/yoga-videos) +- Yoga pose recognition video data. 21. [Powerlifting Database](https://www.kaggle.com/datasets/open-powerlifting/powerlifting-database) - - - - - - - - - - +- Powerlifting data of different people depending on their weight and no of squats. +22. [CardioGoodFitness](https://www.kaggle.com/datasets/saurav9786/cardiogoodfitness) +- FItness vs education, income, miles etc. # To watch From 9a907799bfbddb30b6e7ad180acdfdfcb77211c0 Mon Sep 17 00:00:00 2001 From: Nelson Joseph <63466039+nelson123-lab@users.noreply.github.com> Date: Wed, 10 May 2023 23:00:35 -0500 Subject: [PATCH 2/5] m --- src/RecommenderEngine.py | 43 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/RecommenderEngine.py b/src/RecommenderEngine.py index ba061be..d81d2c2 100644 --- a/src/RecommenderEngine.py +++ b/src/RecommenderEngine.py @@ -1,3 +1,8 @@ +import numpy as np +import tensorflow as tf +import matplotlib.pyplot as plt +from keras import models, layers, losses, regularizers + class RecommenderEngine: def __init__(self) -> None: @@ -11,11 +16,45 @@ def handle_model_creation(self): ''' pass - def train(self): + def train(self, train, test): ''' A wrapper for training if needed ''' - pass + # Model Architecture + # Creating the Sequential object + model = models.Sequential() + # Adding the Conv2D layer to the model with fileters = 8, kernel size = (3, 3), strides = (1,1), padding='same', activation='relu' and a L2 Regularization of 0.0001. + model.add(layers.Conv2D(filters = 8, kernel_size = (3,3), strides = (1,1), padding='same', activation='relu', input_shape = train.shape[1:], kernel_regularizer = regularizers.l2(0.0001))) + # Adding the Conv2D layer to the model with filters = 16, kernel_size = (3,3), strides = (1,1), padding='same', activation='relu' and a L2 Regularization of 0.0001. + model.add(layers.Conv2D(filters = 16, kernel_size = (3,3), strides = (1,1), padding='same', activation='relu', kernel_regularizer = regularizers.l2(0.0001))) + # Adding the Max Pooling layer with a pool size of (2,2), strides = (2,2). + model.add(layers.MaxPooling2D(pool_size = (2,2), strides = (2,2))) + # Adding the Conv2D layer to the model with filters = 32, kernel_size = (3,3), strides = (1,1), padding='same', activation='relu' and a L2 Regularization of 0.0001. + model.add(layers.Conv2D(filters = 32, kernel_size = (3,3), strides = (1,1), padding='same', activation='relu', kernel_regularizer = regularizers.l2(0.0001))) + # Adding the Conv2D layer to the model with filters = 64, kernel_size = (3,3), strides = (1,1), padding='same', activation='relu' and a L2 Regularization of 0.0001. + model.add(layers.Conv2D(filters = 64, kernel_size = (3,3), strides = (1,1), padding='same', activation='relu', kernel_regularizer = regularizers.l2(0.0001))) + # Adding the Max Pooling layer with a pool size of (2,2), strides = (2,2). + model.add(layers.MaxPooling2D(pool_size = (2,2), strides = (2,2))) + # Adding a flatten layer to the model. + model.add(layers.Flatten()) + # Adding a dense layer to the model with units = 512, activation='relu' and L2 Regularization of 0.0001. + model.add(layers.Dense(units = 512, activation='relu', kernel_regularizer = regularizers.l2(0.0001))) + # Adding a dense layer to the model with units = 10, activation='linear' and L2 Regularization of 0.0001. + model.add(layers.Dense(units = 50, activation='linear', kernel_regularizer = regularizers.l2(0.0001))) + # Adding a softmax layer to the output layer. + model.add(layers.Activation('softmax')) + # Compiling the Neural Network model with adam optimizer, loss = losses.categorical_crossentropy and metrics as 'accuracy'. + model.compile(optimizer = 'adam', loss = losses.categorical_crossentropy, metrics = ['accuracy']) + + # Training the model with a validation split of 0.2 and storing the model in the history object. + history = model.fit(x = train, y = train, epochs = 10, batch_size = 1, validation_split = 0.2) + # Predict the probabilities for each class in the output layer + predictions = model.predict(test) + + predicted_labels = np.argmax(predictions, axis=1) + + + return predictions_labels def predict(self) -> str: ''' From bc5b6631c56fda079249093421224b8204e5e29d Mon Sep 17 00:00:00 2001 From: Nelson Joseph <63466039+nelson123-lab@users.noreply.github.com> Date: Wed, 10 May 2023 23:29:20 -0500 Subject: [PATCH 3/5] m --- src/RecommenderEngine.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/RecommenderEngine.py b/src/RecommenderEngine.py index d81d2c2..66371f7 100644 --- a/src/RecommenderEngine.py +++ b/src/RecommenderEngine.py @@ -1,27 +1,20 @@ import numpy as np import tensorflow as tf -import matplotlib.pyplot as plt from keras import models, layers, losses, regularizers +import pandas as pd +data_reference = pd.read_csv("\src\resources\data\exercise.csv") class RecommenderEngine: def __init__(self) -> None: self.model = None pass - def handle_model_creation(self): + def handle_model_creation(self, train): ''' Do model creation part Create the model, or load from the file ''' - pass - - def train(self, train, test): - ''' - A wrapper for training if needed - ''' - # Model Architecture - # Creating the Sequential object model = models.Sequential() # Adding the Conv2D layer to the model with fileters = 8, kernel size = (3, 3), strides = (1,1), padding='same', activation='relu' and a L2 Regularization of 0.0001. model.add(layers.Conv2D(filters = 8, kernel_size = (3,3), strides = (1,1), padding='same', activation='relu', input_shape = train.shape[1:], kernel_regularizer = regularizers.l2(0.0001))) @@ -45,16 +38,22 @@ def train(self, train, test): model.add(layers.Activation('softmax')) # Compiling the Neural Network model with adam optimizer, loss = losses.categorical_crossentropy and metrics as 'accuracy'. model.compile(optimizer = 'adam', loss = losses.categorical_crossentropy, metrics = ['accuracy']) + + return model - # Training the model with a validation split of 0.2 and storing the model in the history object. - history = model.fit(x = train, y = train, epochs = 10, batch_size = 1, validation_split = 0.2) - # Predict the probabilities for each class in the output layer - predictions = model.predict(test) - - predicted_labels = np.argmax(predictions, axis=1) + def train(self, train, test): + ''' + A wrapper for training if needed + ''' + if train.shape[0] % 21 == 0: + model = self.handle_model_creation(train) + history = model.fit(x = train, y = train, epochs = 10, batch_size = 1, validation_split = 0.2) + # Predict the probabilities for each class in the output layer + predictions = model.predict(test) + predicted_labels = np.argmax(predictions, axis=1) - return predictions_labels + return predicted_labels def predict(self) -> str: ''' From 0893808e0b6ad7c8f79e05056f1368024a365b58 Mon Sep 17 00:00:00 2001 From: Nelson Joseph <63466039+nelson123-lab@users.noreply.github.com> Date: Wed, 10 May 2023 23:48:48 -0500 Subject: [PATCH 4/5] code --- src/RecommenderEngine.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/RecommenderEngine.py b/src/RecommenderEngine.py index 66371f7..ba65d41 100644 --- a/src/RecommenderEngine.py +++ b/src/RecommenderEngine.py @@ -3,7 +3,11 @@ from keras import models, layers, losses, regularizers import pandas as pd -data_reference = pd.read_csv("\src\resources\data\exercise.csv") +# loading the exercise reference data. +data_reference = pd.read_csv("src/resources/data/exercise_raw.csv", index_col=False) +# To keep a reference of the exercise names. +exercise_data = data_reference.iloc[:, 1].values + class RecommenderEngine: def __init__(self) -> None: @@ -52,11 +56,25 @@ def train(self, train, test): # Predict the probabilities for each class in the output layer predictions = model.predict(test) predicted_labels = np.argmax(predictions, axis=1) + else: + # No training happening if the data count is not above 21 rows. + pass return predicted_labels - def predict(self) -> str: + def predict(self, exercise_data) -> str: ''' A wrapper for predicting if needed ''' - pass \ No newline at end of file + probabilities = self.train() + + # Combine the two lists using zip() + combined = list(zip(exercise_data, probabilities)) + + # Sort the combined list based on the exersise probabilites (in descending order) + sorted_combined = sorted(combined, key=lambda x: x[1], reverse=True) + + # Get the top 5 exercise recommendataions + top_5 = sorted_combined[:5] + + return top_5 \ No newline at end of file From cdfc288315b624806ad44467e4400674f9106ca5 Mon Sep 17 00:00:00 2001 From: Nelson Joseph <63466039+nelson123-lab@users.noreply.github.com> Date: Wed, 10 May 2023 23:51:47 -0500 Subject: [PATCH 5/5] m --- src/RecommenderEngine.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/RecommenderEngine.py b/src/RecommenderEngine.py index ba65d41..ea6ed8a 100644 --- a/src/RecommenderEngine.py +++ b/src/RecommenderEngine.py @@ -49,6 +49,7 @@ def train(self, train, test): ''' A wrapper for training if needed ''' + predicted_labels = None if train.shape[0] % 21 == 0: model = self.handle_model_creation(train) @@ -59,14 +60,14 @@ def train(self, train, test): else: # No training happening if the data count is not above 21 rows. pass - + return predicted_labels - def predict(self, exercise_data) -> str: + def predict(self, exercise_data, train, test) -> str: ''' A wrapper for predicting if needed ''' - probabilities = self.train() + probabilities = self.train(train, test) # Combine the two lists using zip() combined = list(zip(exercise_data, probabilities))