
Machine Learning Projects
Data Analytics And Data Visualization
A selection of projects analyzed with machine learning algorithms and visualized in Tableau.

Role
Data Analyst
Tools
Radiant, Tableau, Excel
Duration
2 months
Deliverables
Dashboard, Report



UK Bank Customers - Market Segmentation
The entire analysis, visualization and storytelling was done in Tableau.
Market Segmentation
Data Preprocessing
Data Analysis
Data Visualization
Data Storytelling
Goal
To segment UK bank customers.
Dataset
4015 data points
9 variables
Methods & Tools
Analyzed and visualized in Tableau
Selected Variables
Account Balance
Job Classification
Customer ID
Gender
Region
Age

MovieLens - Movie Recommendation
MovieLens is a movie recommendation website run by the GroupLens Research Lab at the University of Minnesota. They collect user preferences about movies and do collaborative filtering to make recommendations.
Recommendation System
Hierarchical Clustering Algorithm
High-Match Movies
Content Filtering
Goal
To create a recommendation system to offer high-match movies to users.
Can we systematically find groups of movies with similar sets of genres?
- Movies within a group (cluster) should be similar
- Movies in different groups (clusters) should be different
Dataset
Number of data points: 1682 movies
Genre Requirements:
18 genres
Each movie may belong to many genres
Movies within a group (cluster) should be similar
Movies in different groups (clusters) should be different
Methods & Tools
Content filtering using Hierarchical Clustering
Selected Variables
Documentary
Drama
Fantasy
FilmNoir
Horror
Musical
Mystery
Romance
Sci-Fi
Thriller
War
Western
ID
Title
Release Date
Video Release Date
IMDB
Unknown
Action
Adventure
Animation
Children
Comedy
Crime
STEP 1
Data Analysis Process
First, I cleaned the data, named every variable and removed duplicates. Hierarchical clustering (multivariate) then showed 10 clusters, as seen in the dendrogram.
By considering 10 as the number of clusters, it was time to show the cluster number for each movie in the data set by adding a new column, "Hcluster".

STEP 2
Labelling Clusters
In the next step, a pivot table is used to show the mean of clusters for each of the movie genres and finally, the summary of pivot tables has been shown in one table and any number above 25% is highlighted by using conditional formatting. The purpose of this action was to know whether the clusters could be labeled or not.
For example, 100% of movies in cluster 9 are Drama as well as Comedy.

Clustering Results:
Cluster 1 is named Comedy-Musical-Children.
Cluster 2 is named Action-Adventure-Sci-fi-Thriller.
Cluster 3 is named Drama-Thriller-Crime.
Cluster 4 is named Drama.
Cluster 5 is named Comedy.
Cluster 6 is named Romance & Drama.
Cluster 7 is named Romance & Comedy (Romcom).
Cluster 8 is named Documentary.
Cluster 9 is named Drama & Comedy.
Cluster 10 is named Horror.
What is the best movie recommendation for someone who watched the "Men in Black" movie and liked it?
Filtering showed this movie belongs to cluster 2. To recommend movies, I filtered the Hcluster variable to 2, which gave titles such as GoldenEye and Twelve Monkeys.

Wine Distribution Industry - Customer Segmentation
A wine distribution company wanted to segment its customers to send targeted discount deals in a monthly newsletter. This took two steps:
1. Modelling
First, K-means clustering is used to cluster customers in the second dataset. The purpose is to put similar customers in a similar group based on their purchase patterns and see if the clusters are meaningful.
2. Labeling
In the next step, I created a pivot table of clusters.
To label clusters, I filtered our new variable Kcluster and picked a cluster, such as cluster 1, then calculated the mean for cluster 1, and showed it in a pivot table.
Then, I combined this table with the first dataset including the characteristics of offers to see what is special regarding offers with high means.
Customer Segmentation
Discount Deals
Email Campaign
Collaborative & Content Filtering
K-means Clustering
Goal
To segment customers so the company can send retailers targeted newsletters with discounts on specific wines.
Dataset
2 datasets have been taken into consideration.
First Dataset - Discount Deals: The list of the previous 32 offers sent to customers
Second Dataset - Customer Transactions: The list of 100 customers who received offers in the past year.
Methods & Tools
Collaborative and content filtering using K-means clustering.
Selected Variables
First Dataset
Offer
Campaign
Varietal
Minimum bottle
Discount percent
Origin, Past Peak
Second Dataset
Customers
32 offers (as binary variables)
Clustering Results:
Cluster 1 is labeled Pinot Noir based on Varietal.
Cluster 2 is labeled Minimum Quantity based on a Minimum Bottle of 6.
Cluster 3 is labeled Champagne based on Varietal.
Cluster 4 is labeled Large Minimum Quantity based on Minimum Bottle of 72 and 144.

Framingham Heart Study - Probability of Getting Coronary Heart Disease (CHD) in the Next 10 Years
This study estimates the likelihood of developing heart disease by identifying demographic, medical, behavioral and first-examination risk factors. I evaluated the relationships between variables using logistic regression.
CHD is a disease of the blood vessels supplying the heart
Prediction
Logistic Regression
Confusion Matrix
Classification prediction
What I found was that:
Gender, age, cigarettes per day, prevalent hypertension, total cholesterol, systolic blood pressure (sysBP) and glucose are important factors!
Being male increases the probability of CHD, holding other variables fixed: the log-odds increase by 0.600 (an odds ratio of about 1.82).
Increasing age, daily smoking, prevalent hypertension, higher total cholesterol, higher systolic blood pressure and higher glucose levels all increase the 10-year CHD risk.
Goal
To predict and prevent heart disease using the Framingham Heart Study data.
Dataset
5209 patients in the age range of 30-59
Methods & Tools
Data were collected through questionnaires and exams every 2 years.
Randomly split patients into training and testing sets
Logistic regression on training set used to predict whether a patient experiences CHD within 10 years of the first examination (The categorical variable response (TenYearCHD) including 0 or 1 was chosen)
Selected Variables
Male
Age
Education
CurrentSmoker
CigsPerDay=Cigarettes per day
BPMeds= On blood pressure medication (yes/no)
Prevalent Stroke
PrevalentHyp=Prevalent Hypertension
Diabetes
TotChol=Total Cholesterol
SysBP=Systolic Blood Pressure
DiaBP=Diastolic Blood Pressure
BMI=Body Mass Index
HeartRate
Glucose
TenYearCHD
Results:
Gender, age, cigarettes per day, prevalent hypertension, total cholesterol, systolic blood pressure, and glucose are important factors marked by asterisks.

Model Evaluation - Confusion Matrix on Framingham Test Dataset
A pivot table is created based on two variables, TenYearCHD (response variable) and TenYearCHDPred (predicted response).
Accuracy on the Framingham Test dataset is 84.7% (83.7% correctly predicted no CHD + 1.0% correctly predicted CHD).


Amazon Revenue Prediction for Q4, 2020
Amazon's guidance for the fourth quarter of 2020 was net sales between $112 billion and $121 billion.
Can we predict Amazon's quarterly revenue only based on one factor, period, by using the Time Series method and not considering any other factors or information?
Linear Regression
Time Series
Forecasting
In the first step, I used the whole data points (without creating a train and test dataset) and only two variables: QR and Period to predict the fourth quarter revenue of 2020. Then, I tried to develop the model by using plots.
Goal
To predict Amazon's Q4 2020 Revenue.
Dataset
Includes variables from the first quarter of 2001 to the third quarter of 2020 but main variables are Year/Quarter and Revenue amount. All revenue figures are in millions of US dollars (e.g., 125,995.3 = $125,995.3 million ≈ $126 billion).
Methods & Tools
The linear regression model (Time Series Method)
Selected Variables
Year/Quarter
Revenue amount
QR (Quarterly Revenue as the Dependent Variable)
Period (Number of Periods=Independent Variable)
Fiscal Quarter
Year & Quarter
Date
Fiscal Year
STEP 1
Linear Regression - Model 1
A linear Regression model was chosen. An R-squared of 0.75 shows the model is reasonably good but I need to predict period 80 and compare it with data points.

STEP 2
Amazon's Actual Revenue vs Predicted Revenue
I predicted period 80, which is the last quarter's revenue. I noticed it was off, because 2020’s quarterly revenues were rising. It does not make sense with the predicted revenue of 57,016.1 (≈ $57B).

STEP 3
Model Evaluation
To get a better picture and to see why the prediction is off, I took a look at the plots in the dashboard first and I predicted the whole data points with this model (pred-reg). Also, visualized them by scatter plot, and compared them with the main dataset.
By looking at the plots, it can be seen that Amazon's quarterly revenue is exponential (the revenue growth is based on percentage) while I had assumed it was linear. So, I did a non-linear transformation and created a new variable Log (QR).

STEP 4
Model 2
By using Log QR and Period, the model was run again. This time, the R-squared value is 0.985 which is highly satisfactory. Then I predicted period 80 but this time we needed to consider e^11.588 = 107,796.4 (≈ $107.8B) as the revenue and compared it with the main dataset and it shows that it is not off-predicted.
But we need to check plots in the dashboard to make sure we can consider it the final model. The residuals are not normally distributed (Residuals vs Normal Density). In addition, there is a pattern of ups and downs in residuals in the Residuals vs Fitted plot which violates the principles regarding errors that the mean of residuals should be zero and have a constant variance. As we can see, one quarter has a better performance as opposed to the rest. This showed the model wasn’t capturing the quarter. So, I needed to add different quarters (Fiscal quarter) as a factor variable because they have impacts on our model.

As can be seen, the second model has an absolutely higher R-squared which is 0.985.

The fourth quarter revenue prediction is equal to e^11.588 = 107,796.4 (≈ $107.8B).

Residuals vs Fitted should not show any patterns, however, it shows two groups that have ups and downs. And the means of residuals is not zero. Residuals should be distributed normally which we cannot see here!
STEP 5
Model 3
After adding the Fiscal Quarter to the model, it was run again. The R-squared became much better (0.997) and predicted the period 80, quarter=4 which is e^11.863 = 141,917.3 (≈ $141.9B).
Based on the evaluation of residuals' plots, the residuals vs Fitted plot, still shows a pattern but the group problem has been resolved and the mean of residuals is not zero. Residuals' distribution is getting close to normal; however, residuals are not independent as can be shown in the Residuals vs Row Order plot.
I noticed that quarters are related to each other and there is a relationship between them because they are seen as dependent over time. So, lags of QR have been created for all quarters [Lag (LogQR, 1), Lag (LogQR, 2), Lag (LogQR, 3), Lag (LogQR, 4)].

As can be seen, the third model even has a higher R-squared as opposed to the second one which is 0.997!

The fourth quarter revenue prediction is equal to e^11.863 = 141,917.3 (≈ $141.9B).

STEP 6
Model 4
After creating L1, L2, L3 & L4 which are Lag (LogQR, 1), Lag (LogQR, 2), Lag (LogQR, 3), and Lag (LogQR, 4), the model was run again. The R-squared increased to 0.999 and revenue was predicted to be $226B.

As can be seen, the fourth model has the highest R-squared which is 0.999.

The fourth quarter revenue prediction is equal to e^9.607 = 14,868.4976 (≈ 148B).

Residuals' distribution is roughly normal and their mean is roughly zero. In addition, residuals are independent.
STEP 7
Model 5
By removing all variables that are not significant from the fourth model, the best model is created with an R-squared of 0.998 and a predicted revenue of $126B for the fourth quarter of 2020.

As can be seen, the final model has an R-squared of 0.998.

The fourth quarter revenue prediction is equal to e^11.744 = 125,995.3 (≈ $126.0B).
The estimation is $126 billion with 95% confidence between $119 billion and $133 billion!

Residuals' distribution is roughly normal and their mean is roughly zero. In addition, residuals are independent.
Amazon’s actual Q4 2020 revenue was about $125.6 billion, so our final model’s $126B prediction was very close.








