-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8ca2e0
commit 6d1fddc
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
%%%------------- K-Means Clustering | ||
% Step 1: Choose the number k of clusters | ||
|
||
% Step 2: Select k point at random called centroids | ||
|
||
% Step 3: Assign each datapoint to the nearest centroid which lead to K | ||
% clusters | ||
|
||
% Step 4: Compute new centroids of each cluster based on the datapoints it | ||
% contains | ||
|
||
% Step 5: Reassign each datapoint to the new closest centroid | ||
|
||
% Choosing the k value, search for WCSS. "The Elbow Method" | ||
|
||
% Import the dataset | ||
data = readtable('Datasets\Mall_Customers.csv'); | ||
|
||
%Check for missing values | ||
missings = sum(ismissing(data)); | ||
|
||
%Plot variables to check for outliers | ||
IncomePlot = plot(data.AnnualIncome); | ||
SpendingPlot = plot(data.SpendingScore); | ||
|
||
% Perform Feature Scaling (Standardization Method) | ||
stand_income = (data.AnnualIncome - mean(data.AnnualIncome)) / std(data.AnnualIncome); | ||
data.AnnualIncome = stand_I |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters