Month: March 2021

NLP Model for IMDB Movie Sentiment Using TensorFlow Take 1

Template Credit: Adapted from a template made available by Dr. Jason Brownlee of Machine Learning Mastery.

SUMMARY: This project aims to construct a text classification model using a neural network and document the end-to-end steps using a template. The IMDB Movie Sentiment dataset is a binary classification situation where we attempt to predict one of the two possible outcomes.

INTRODUCTION: This dataset contains 50,000 movie reviews extracted from IMDB. The researchers have annotated the tweets with labels (0 = negative, 1 = positive) to detect the reviews’ sentiment.

In this Take1 iteration, we will create a bag-of-words model to perform binary classification (positive or negative) for the Tweets. The Part A script will focus on building the model with the training and validation datasets due to memory capacity constraints. Part B will focus on testing the model with the training and test datasets.

ANALYSIS: In this Take1 iteration, the preliminary model’s performance achieved an average accuracy score of 88.80% after 25 epochs with ten iterations of cross-validation. Furthermore, the final model processed the test dataset with an accuracy measurement of 89.48%.

CONCLUSION: In this iteration, the bag-of-words TensorFlow model appeared to be suitable for modeling this dataset. We should consider experimenting with TensorFlow for further modeling.

Dataset Used: IMDB Movie Sentiment

Dataset ML Model: Binary class text classification with text-oriented features

Dataset Reference: https://www.kaggle.com/columbine/imdb-dataset-sentiment-analysis-in-csv-format

One potential source of performance benchmarks: https://www.kaggle.com/columbine/imdb-dataset-sentiment-analysis-in-csv-format

The HTML formatted report can be found here on GitHub.

Multi-Class Image Classification Deep Learning Model for Textile Defect Detection Using TensorFlow Take 1

Template Credit: Adapted from a template made available by Dr. Jason Brownlee of Machine Learning Mastery.

SUMMARY: This project aims to construct a predictive model using a TensorFlow convolutional neural network (CNN) and document the end-to-end steps using a template. The Textile Defect Detection dataset is a multi-class classification situation where we attempt to predict one of several (more than two) possible outcomes.

INTRODUCTION: This dataset from Kaggle contains 96,000 patches of the textile image with different quality problems. The goal of the exercise is to detect the quality issue for a patch of textile during production. The greyscale photos are part of the public dataset made available by the MVTec Company and referred by the research paper from Paul Bergmann, Michael Fauser, David Sattlegger, Carsten Steger. MVTec AD – A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection; in: IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2019.

In this Take1 iteration, we will construct a CNN model using a simple three-block VGG architecture and test the model’s performance using a separate test dataset.

ANALYSIS: In this Take1 iteration, the baseline model’s performance achieved an accuracy score of 97.07% on the validation dataset after 15 epochs. Furthermore, the final model’s performance achieved an accuracy score of 68.03% on the test dataset after 15 epochs.

CONCLUSION: In this iteration, the simple three-block VGG CNN model did not appear suitable for modeling this dataset due to a high-variance problem. We should consider experimenting with more or different data for further modeling.

Dataset Used: Textile Defect Detection

Dataset ML Model: Multi-class image classification with numerical attributes

Dataset Reference: https://www.kaggle.com/belkhirnacim/textiledefectdetection

A potential source of performance benchmarks: https://www.kaggle.com/belkhirnacim/textiledefectdetection

The HTML formatted report can be found here on GitHub.

Algorithmic Trading Model for Trend-Following with APO Indicator Strategy Using Python Take 1

NOTE: This script is for learning purposes only and does not constitute a recommendation for buying or selling any stock mentioned in this script.

SUMMARY: This project aims to construct and test an algorithmic trading model and document the end-to-end steps using a template.

INTRODUCTION: This algorithmic trading model examines a simple trend-following strategy for a stock. The model enters a position when the price reaches either the highest or lowest points for the last X number of days. The model will exit the trade when the stock’s MACD histogram switches side.

In addition to the stock price, the models will also use the absolute price oscillator (APO) indicator to confirm the buy/sell signal further. Finally, the strategy will also incorporate a profit/loss threshold. The strategy will exit the position when the profit or loss has reached the established threshold.

In this Take1 iteration, we will set up the models using a trend window size for long trades only. The window size will vary from 10 to 20 trading days at a 5-day increment. We will use 10 to 20 days for the fast EMA curve and 40 to 50 days for the slow EMA curve. The models will also incorporate an APO indicator with a range of plus and minus 2 to 4 dollars. Furthermore, we will establish a profit cap of 15% and a loss threshold of 8%.

ANALYSIS: In this Take1 iteration, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2018, and March 19, 2021. The top trading model produced a profit of 136.38 dollars per share. The buy-and-hold approach yielded a gain of 109.12 dollars per share.

CONCLUSION: For the stock of COST during the modeling time frame, the long-only trading strategy with profit/loss limits did not produce a better return than the buy-and-hold approach. We should consider modeling this stock further by experimenting with more variations of the strategy.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.

Binary-Class Image Classification Deep Learning Model for Malaria Parasite Detection Using TensorFlow Take 4

Template Credit: Adapted from a template made available by Dr. Jason Brownlee of Machine Learning Mastery.

SUMMARY: This project aims to construct a predictive model using a TensorFlow convolutional neural network (CNN) and document the end-to-end steps using a template. The Malaria Parasite Detection dataset is a binary-class classification situation where we attempt to predict one of two possible outcomes.

INTRODUCTION: Biomedical researchers have developed a mobile application that runs on a standard Android smartphone attached to a conventional light microscope for detecting malaria disease. The smartphone’s built-in camera acquired thin blood smear images of slides for each microscopic field of view. An expert manually annotated the slides afterward. The dataset contains a total of 27,558 cell images with equal instances of parasitized and uninfected cells.

From iteration Take1, we constructed a CNN model using a simple three-block VGG architecture and tested the model’s performance using a held-out validation dataset.

From iteration Take2, we constructed a CNN model using the InceptionV3 architecture and tested the model’s performance using a held-out validation dataset.

From iteration Take3, we constructed a CNN model using the ResNet50V2 architecture and tested the model’s performance using a held-out validation dataset.

In this Take4 iteration, we will construct a CNN model using the DenseNet201 architecture and test the model’s performance using a held-out validation dataset.

ANALYSIS: From iteration Take1, the model’s performance achieved an average accuracy score of 94.08% on the validation dataset after 20 epochs.

From iteration Take2, the model’s performance achieved an average accuracy score of 95.12% on the validation dataset after 20 epochs.

From iteration Take3, the model’s performance achieved an average accuracy score of 95.19% on the validation dataset after 20 epochs.

In this Take4 iteration, the model’s performance achieved an average accuracy score of 95.41% on the validation dataset after 20 epochs.

CONCLUSION: In this iteration, the DenseNet201 CNN model appeared to be suitable for modeling this dataset. We should consider experimenting with TensorFlow for further modeling.

Dataset Used: Malaria Parasite Detection

Dataset ML Model: Binary-class image classification with numerical attributes

Dataset Reference: https://lhncbc.nlm.nih.gov/LHC-publications/pubs/MalariaDatasets.html

A potential source of performance benchmark: https://doi.org/10.7717/peerj.4568 or https://doi.org/10.7717/peerj.6977

One potential source of performance benchmarks: https://www.kaggle.com/c/cassava-leaf-disease-classification/leaderboard

The HTML formatted report can be found here on GitHub.

Binary-Class Image Classification Deep Learning Model for Malaria Parasite Detection Using TensorFlow Take 3

Template Credit: Adapted from a template made available by Dr. Jason Brownlee of Machine Learning Mastery.

SUMMARY: This project aims to construct a predictive model using a TensorFlow convolutional neural network (CNN) and document the end-to-end steps using a template. The Malaria Parasite Detection dataset is a binary-class classification situation where we attempt to predict one of two possible outcomes.

INTRODUCTION: Biomedical researchers have developed a mobile application that runs on a standard Android smartphone attached to a conventional light microscope for detecting malaria disease. The smartphone’s built-in camera acquired thin blood smear images of slides for each microscopic field of view. An expert manually annotated the slides afterward. The dataset contains a total of 27,558 cell images with equal instances of parasitized and uninfected cells.

From iteration Take1, we constructed a CNN model using a simple three-block VGG architecture and tested the model’s performance using a held-out validation dataset.

From iteration Take2, we constructed a CNN model using the InceptionV3 architecture and tested the model’s performance using a held-out validation dataset.

In this Take3 iteration, we will construct a CNN model using the ResNet50V2 architecture and test the model’s performance using a held-out validation dataset.

ANALYSIS: From iteration Take1, the model’s performance achieved an average accuracy score of 94.08% on the validation dataset after 20 epochs.

From iteration Take2, the model’s performance achieved an average accuracy score of 95.12% on the validation dataset after 20 epochs.

In this Take3 iteration, the model’s performance achieved an average accuracy score of 95.19% on the validation dataset after 20 epochs.

CONCLUSION: In this iteration, the ResNet50V2 CNN model appeared to be suitable for modeling this dataset. We should consider experimenting with TensorFlow for further modeling.

Dataset Used: Malaria Parasite Detection

Dataset ML Model: Binary-class image classification with numerical attributes

Dataset Reference: https://lhncbc.nlm.nih.gov/LHC-publications/pubs/MalariaDatasets.html

A potential source of performance benchmark: https://doi.org/10.7717/peerj.4568 or https://doi.org/10.7717/peerj.6977

One potential source of performance benchmarks: https://www.kaggle.com/c/cassava-leaf-disease-classification/leaderboard

The HTML formatted report can be found here on GitHub.