Skip to content

Commit 7ef2e1b

Browse files
committed
Maintenance of Live Modules Update for 2024b+.
- Updated CI - Updated Smoke Tests - Plotting hard-coded color updates - Project structure updates
1 parent 2dad119 commit 7ef2e1b

File tree

51 files changed

+507
-322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+507
-322
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*.slmx binary merge=mlAutoMerge
1717
*.sltx binary
1818
*.slxc binary
19-
*.slx binary merge=mlAutoMerge
19+
*.slx binary merge=mlAutoMerge linguist-language=Simulink
2020
*.slxp binary
2121

2222
## Other common binary file types

.github/workflows/ci.yml

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,60 @@ on:
88
branches: [ release ]
99
workflow_dispatch:
1010

11+
# Add permission to write GitHub pages
12+
permissions:
13+
contents: write
14+
pages: write
15+
id-token: write
16+
1117
jobs:
1218
test:
1319
strategy:
1420
fail-fast: false
1521
matrix:
16-
MATLABVersion: [R2021a,R2021b,R2022a,R2022b,R2023a,R2023b]
22+
MATLABVersion: [R2024a,R2024b]
1723
runs-on: ubuntu-latest
1824
steps:
1925
# Checks-out your repository
20-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
27+
28+
# Sets up a display server
29+
- name: Start display server
30+
if: ${{ always() }}
31+
run: |
32+
sudo apt-get install xvfb
33+
Xvfb :99 &
34+
echo "DISPLAY=:99" >> $GITHUB_ENV
2135
2236
# Sets up MATLAB
2337
- name: Setup MATLAB
24-
uses: matlab-actions/setup-matlab@v1
38+
uses: matlab-actions/setup-matlab@v2
2539
with:
2640
release: ${{ matrix.MATLABVersion }}
41+
products: MATLAB Statistics_and_Machine_Learning_Toolbox
42+
# List required products above in the format shown (and uncomment them)
43+
# List of product strings:
44+
# Simulink
45+
# Statistics_and_Machine_Learning_Toolbox
46+
# Simulink_Coder
47+
# Econometrics_Toolbox
48+
# Deep_Learning_Toolbox
49+
2750

2851
# Run all the tests
2952
- name: Run SmokeTests
30-
uses: matlab-actions/run-command@v1
53+
uses: matlab-actions/run-command@v2
3154
with:
3255
command: openProject(pwd); RunAllTests;
3356

3457
# Upload the test results as artifact
3558
- name: Upload TestResults
36-
uses: actions/upload-artifact@v3.1.3
59+
if: ${{ always() }}
60+
uses: actions/upload-artifact@v4
3761
with:
38-
name: TestResults
39-
path: ./SoftwareTests/TestResults_${{ matrix.MATLABVersion }}.txt
62+
name: TestResults_${{ matrix.MATLABVersion }}
63+
path: ./public/*
64+
overwrite: true
4065

4166
badge:
4267
if: ${{ always() }}
@@ -47,26 +72,38 @@ jobs:
4772
steps:
4873

4974
# Checks-out your repository
50-
- uses: actions/checkout@v3
75+
- uses: actions/checkout@v4
5176

5277
# Sets up R2023b
5378
- name: Setup MATLAB
54-
uses: matlab-actions/setup-matlab@v1
79+
uses: matlab-actions/setup-matlab@v2
5580
with:
56-
release: R2023b
81+
release: R2024b
5782

5883
# Download the test results from artifact
59-
- name: Download TestResults
60-
uses: actions/download-artifact@v2.1.1
84+
- name: Download All TestResults
85+
uses: actions/download-artifact@v4
6186
with:
62-
name: TestResults
63-
path: ./SoftwareTests/
64-
87+
path: public
88+
pattern: TestResults_*
89+
merge-multiple: true
90+
6591
# Create the test results badge
66-
- name: Run CreateBadge
67-
uses: matlab-actions/run-command@v1
92+
- name: Run PostSmokeTest
93+
uses: matlab-actions/run-command@v2
94+
with:
95+
command: openProject(pwd); PostSmokeTest;
96+
97+
# Deploy reports to GitHub pages
98+
- name: Setup Pages
99+
uses: actions/configure-pages@v5
100+
- name: Upload pages artifact
101+
uses: actions/upload-pages-artifact@v3
68102
with:
69-
command: openProject(pwd); CreateBadge;
103+
path: public
104+
- name: Deploy to GitHub Pages
105+
id: deployment
106+
uses: actions/deploy-pages@v4
70107

71108
# Commit the JSON for the MATLAB releases badge
72109
- name: Commit changed files

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,5 @@ codegen/
4747
# Project settings
4848
Utilities/ProjectSettings.mat
4949

50-
# Test results
51-
SoftwareTests/TestResults_*
52-
53-
# GitLab page fodler
54-
public/
50+
# GitLab page folder
51+
public/

Images/TestedWith.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"schemaVersion":1,"label":"Tested with","color":"success","message":"R2021a | R2021b | R2022a | R2022b | R2023a | R2023b"}
1+
{"schemaVersion":1,"label":"Tested with","color":"success","message":"R2024a | R2024b"}

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
<a name="T_DEF03274"></a>
1+
22
# <span style="color:rgb(213,80,0)">Machine Learning Methods: Clustering</span>
3-
<a name="H_053613DF"></a>
3+
44

55
[![View on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/135381-machine-learning-methods-clustering) or [![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Machine-Learning-Methods-Clustering&project=MLMethodsClustering.prj&file=README.mlx)
66

7-
![MATLAB Versions Tested](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FMathWorks-Teaching-Resources%2FMachine-Learning-Methods-Clustering%2Frelease%2FImages%2FTestedWith.json)
7+
[![MATLAB Versions Tested](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FMathWorks-Teaching-Resources%2FMachine-Learning-Methods-Clustering%2Frelease%2FImages%2FTestedWith.json)](https://MathWorks-Teaching-Resources.github.io/Machine-Learning-Methods-Clustering)
88

99
**Curriculum Module**
1010

11-
_Created with R2023b. Compatible with R2023b and later releases._
11+
_Created with R2024b. Compatible with R2024b and later releases._
1212

1313
# Information
1414

1515
This curriculum module contains interactive [MATLAB® live scripts](https://www.mathworks.com/products/matlab/live-editor.html) that apply fundamental concepts and basic terminology related to clustering.
1616

17-
<a name="H_F00D98E4"></a>
17+
1818
## Background
1919

20-
You can use these live scripts as demonstrations in lectures, class activities, or interactive assignments outside class. This module covers distance-based, density based, and probabilistic algorithms including k-means, DBSCAN, and GMMs. It also includes examples of applying each algorithm to a data set containing beak measurements for different species of penguins.
20+
You can use these live scripts as demonstrations in lectures, class activities, or interactive assignments outside class. This module covers distance\-based, density based, and probabilistic algorithms including k\-means, DBSCAN, and GMMs. It also includes examples of applying each algorithm to a data set containing beak measurements for different species of penguins.
2121

2222

2323
The instructions inside the live scripts will guide you through the exercises and activities. Get started with each live script by running it one section at a time. To stop running the script or a section midway (for example, when an animation is in progress), use the <img src="Images/image_0.png" width="19" alt="image_0.png"> Stop button in the **RUN** section of the **Live Editor** tab in the MATLAB Toolstrip.
@@ -26,59 +26,60 @@ The instructions inside the live scripts will guide you through the exercises an
2626

2727
Contact the [MathWorks teaching resources team](mailto:onlineteaching@mathworks.com) if you have a question or would like to provide any feedback.
2828

29-
<a name="H_30BC7141"></a>
29+
3030
## Prerequisites
3131

3232
This module assumes knowledge of basic statistics and probability, including Gaussian distributions and Bayes' theorem. If you would like to refresh your knowledge on these topics, more courseware on Gaussian distributions can be found [here](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Descriptive-Stats-and-Probability&project=StatsAndProb.prj&file=continuousDistributions.mlx), and more courseware on Bayes' theorem can be found [here](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Probability-Theory&project=Probability.prj&file=inferenceBayes.mlx). There is minimal MATLAB knowledge required for these scripts, but you can use [MATLAB Onramp](https://matlabacademy.mathworks.com/details/matlab-onramp/gettingstarted) as a resource to acquire familiarity with live scripts and MATLAB syntax.
3333

34-
<a name="H_330E72C3"></a>
34+
3535
## Getting Started
3636
### Accessing the Module
3737
### **On MATLAB Online:**
3838

39-
Use the [<img src="Images/image_1.png" width="154" alt="image_1.png">](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Machine-Learning-Methods-Clustering&project=MLMethodsClustering.prj) link to download the module. You will be prompted to log in or create a MathWorks account. The project will be loaded, and you will see an app with several navigation options to get you started.
39+
Use the [<img src="Images/image_1.png" width="154" alt="image_1.png">](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Machine-Learning-Methods-Clustering&project=MLMethodsClustering.prj) link to download the module. You will be prompted to log in or create a MathWorks account. The project will be loaded, and you will see an app with several navigation options to get you started.
4040

4141
### **On Desktop:**
4242

43-
Download or clone this repository. Open MATLAB, navigate to the folder containing these scripts and double-click on [MLMethodsClustering.prj](MLMethodsClustering.prj). It will add the appropriate files to your MATLAB path and open an app that asks you where you would like to start.
43+
Download or clone this repository. Open MATLAB, navigate to the folder containing these scripts and double\-click on [MLMethodsClustering.prj](matlab: openProject("MLMethodsClustering.prj")). It will add the appropriate files to your MATLAB path and open an app that asks you where you would like to start.
44+
4445

46+
Ensure you have all the required products (listed below) installed. If you need to include a product, add it using the Add\-On Explorer. To install an add\-on, go to the **Home** tab and select <img src="Images/image_2.png" width="16" alt="image_2.png"> **Add-Ons** > **Get Add-Ons**.
4547

46-
Ensure you have all the required products ([listed below](#H_E850B4FF)) installed. If you need to include a product, add it using the Add-On Explorer. To install an add-on, go to the **Home** tab and select <img src="Images/image_2.png" width="16" alt="image_2.png"> **Add-Ons** > **Get Add-Ons**.
4748

48-
<a name="H_E850B4FF"></a>
4949
## Products
5050

5151
MATLAB® is used throughout. Tools from the Statistics and Machine Learning Toolbox™ are used frequently as well.
5252

53-
<a name="H_E8C62B23"></a>
53+
5454
# Scripts
5555

56-
## [**ClusteringIntro.mlx**](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Machine-Learning-Methods-Clustering&project=MLMethodsClustering.prj&file=ClusteringIntro.mlx)
56+
*\* If you are viewing this in a version of MATLAB prior to R2023b, you can view the learning outcomes for each script* [*here*](https://www.mathworks.com/matlabcentral/fileexchange/135381-machine-learning-methods-clustering)
57+
58+
## [**ClusteringIntro.mlx**](ClusteringIntro.mlx)
5759
| | | |
5860
| :-- | :-- | :-- |
59-
| <img src="Images/image_3.png" width="251" alt="image_3.png"> | **In this script, students will...** - Learn what clustering is and what types of problems it can be applied to - Explore a step-by-step example of using k-means to cluster random data - Apply k-means to a real world data set, optimizing parameters along the way | **Academic disciplines** - Machine Learning - Artificial Intelligence |
61+
| <img src="Images/image_3.png" width="251" alt="image_3.png"> <br> | **In this script, students will...** <br> $\bullet$ Learn what clustering is and what types of problems it can be applied to <br> $\bullet$ Explore a step\-by\-step example of using k\-means to cluster random data <br> $\bullet$ Apply k\-means to a real world data set, optimizing parameters along the way <br> | **Academic disciplines** <br> $\bullet$ Machine Learning <br> $\bullet$ Artificial Intelligence <br> |
6062
| | | |
6163

62-
## [**ClusteringMethods.mlx**](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Machine-Learning-Methods-Clustering&project=MLMethodsClustering.prj&file=ClusteringMethods.mlx)
64+
## [**ClusteringMethods.mlx**](ClusteringMethods.mlx)
6365
| | | |
6466
| :-- | :-- | :-- |
65-
| <img src="Images/image_4.png" width="209" alt="image_4.png"> | **In this script, students will...** - Learn about two more clustering methods: DBSCAN and GMMs - Work through step-by-step examples of applying each algorithm to an example data set - Cluster the same real world data set using each method, considering their pros and cons - Learn about a variety of methods to evaluate clustering results | **Academic disciplines** - Machine Learning - Artificial Intelligence - Statistics |
67+
| <img src="Images/image_4.png" width="209" alt="image_4.png"> <br> | **In this script, students will...** <br> $\bullet$ Learn about two more clustering methods: DBSCAN and GMMs <br> $\bullet$ Work through step\-by\-step examples of applying each algorithm to an example data set <br> $\bullet$ Cluster the same real world data set using each method, considering their pros and cons <br> $\bullet$ Learn about a variety of methods to evaluate clustering results <br> | **Academic disciplines** <br> $\bullet$ Machine Learning <br> $\bullet$ Artificial Intelligence <br> $\bullet$ Statistics <br> |
6668
| | | |
6769

6870
## Related Courseware Modules
69-
<a name="H_792FBE0F"></a>
71+
7072
## [**Regression Basics**](https://www.mathworks.com/matlabcentral/fileexchange/93435-regression-basics)
7173
| | |
7274
| :-- | :-- |
73-
| <img src="Images/image_5.png" width="171" alt="image_5.png"> | **Available on:** [<img src="Images/image_6.png" width="129" alt="image_6.png">](https://www.mathworks.com/matlabcentral/fileexchange/93435-regression-basics) [<img src="Images/image_7.png" width="130" alt="image_7.png">](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Regression-Basics&project=RegressionBasics.prj) [GitHub](https://github.com/MathWorks-Teaching-Resources/Regression-Basics) |
75+
| <img src="Images/image_5.png" width="171" alt="image_5.png"> <br> | **Available on:** <br> [<img src="Images/image_6.png" width="129" alt="image_6.png">](https://www.mathworks.com/matlabcentral/fileexchange/93435-regression-basics) <br> [<img src="Images/image_7.png" width="130" alt="image_7.png">](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Regression-Basics&project=RegressionBasics.prj) <br> [GitHub](https://github.com/MathWorks-Teaching-Resources/Regression-Basics) <br> |
7476
| | |
7577

76-
<a name="H_6E8B4D8B"></a>
77-
<a name="H_61EB2540"></a>
78+
7879
## [**Machine Learning for Regression**](https://www.mathworks.com/matlabcentral/fileexchange/95903-machine-learning-for-regression)
7980
| | |
8081
| :-- | :-- |
81-
| <img src="Images/image_8.png" width="171" alt="image_8.png"> | **Available on:** [<img src="Images/image_9.png" width="129" alt="image_9.png">](https://www.mathworks.com/matlabcentral/fileexchange/95903-machine-learning-for-regression) [<img src="Images/image_10.png" width="130" alt="image_10.png">](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Machine-Learning-for-Regression&project=MLforRegression.prj) [GitHub](https://github.com/MathWorks-Teaching-Resources/Machine-Learning-for-Regression) |
82+
| <img src="Images/image_8.png" width="171" alt="image_8.png"> <br> | **Available on:** <br> [<img src="Images/image_9.png" width="129" alt="image_9.png">](https://www.mathworks.com/matlabcentral/fileexchange/95903-machine-learning-for-regression) <br> [<img src="Images/image_10.png" width="130" alt="image_10.png">](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Machine-Learning-for-Regression&project=MLforRegression.prj) <br> [GitHub](https://github.com/MathWorks-Teaching-Resources/Machine-Learning-for-Regression) <br> |
8283
| | |
8384

8485

@@ -91,4 +92,3 @@ Or feel free to explore our other [modular courseware content](https://www.mathw
9192
Copyright 2023 The MathWorks™, Inc
9293

9394

94-

Scripts/ClusteringIntro.mlx

-1.59 KB
Binary file not shown.

Scripts/ClusteringMethods.mlx

-1.58 KB
Binary file not shown.

SoftwareTests/CheckTestResults.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
end
55

66
properties (ClassSetupParameter)
7-
Project = {''};
7+
Project = {currentProject()};
88
end
99

1010
properties (TestParameter)
@@ -15,8 +15,8 @@
1515
methods (TestParameterDefinition,Static)
1616

1717
function Version = GetResults(Project)
18-
RootFolder = currentProject().RootFolder;
19-
Version = dir(fullfile(RootFolder,"SoftwareTests","TestResults*.txt"));
18+
RootFolder = Project.RootFolder;
19+
Version = dir(fullfile(RootFolder,"public","TestResults*.txt"));
2020
Version = extractBetween([Version.name],"TestResults_",".txt");
2121
end
2222

@@ -37,9 +37,11 @@ function SetUpSmokeTest(testCase,Project)
3737
methods(Test)
3838

3939
function CheckResults(testCase,Version)
40-
File = fullfile("SoftwareTests","TestResults_"+Version+".txt");
40+
File = fullfile("public","TestResults_"+Version+".txt");
4141
Results = readtable(File,TextType="string");
42-
testCase.verifyTrue(all(Results.Passed));
42+
if ~all(Results.Passed)
43+
error("Some of the tests did not pass.")
44+
end
4345
end
4446

4547
end

SoftwareTests/CreateBadge.m

Lines changed: 0 additions & 28 deletions
This file was deleted.

SoftwareTests/PostSmokeTest.m

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
function PostSmokeTest(ShowReport)
2+
arguments
3+
ShowReport (1,1) logical = false;
4+
end
5+
6+
import matlab.unittest.plugins.TestRunnerPlugin;
7+
8+
% Create the runner:
9+
Runner = matlab.unittest.TestRunner.withTextOutput;
10+
11+
% Create report folder:
12+
Folder = fullfile(currentProject().RootFolder,"public");
13+
if ~isfolder(Folder)
14+
mkdir(Folder)
15+
end
16+
17+
% Add HTML plugin:
18+
Plugin = matlab.unittest.plugins.TestReportPlugin.producingHTML(Folder,...
19+
"IncludingPassingDiagnostics",true,...
20+
"IncludingCommandWindowText",false,...
21+
"LoggingLevel",matlab.automation.Verbosity(1));
22+
Runner.addPlugin(Plugin);
23+
24+
25+
% Create Test Suite
26+
Suite = testsuite("CheckTestResults");
27+
28+
% Run the test suite
29+
Results = Runner.run(Suite);
30+
31+
32+
% Format the results in a table and save them
33+
Results = table(Results');
34+
Version = extractBetween(string(Results.Name),"Version=",")");
35+
Passed = Results.Passed;
36+
37+
% Add link to other report
38+
File = fileread(fullfile("public","index.html"));
39+
for iVer = 1:length(Version)
40+
File = replace(File,"Version="+Version(iVer),...
41+
sprintf('<a href="%s/index.html">%s</a>',Version(iVer),"Version="+Version(iVer)));
42+
end
43+
writelines(File,fullfile("public","index.html"),"WriteMode","overwrite");
44+
45+
% Format the JSON file
46+
Badge = struct;
47+
Badge.schemaVersion = 1;
48+
Badge.label = "Test Status";
49+
if all(Passed)
50+
Badge.color = "success";
51+
Badge.message = join("R"+Version," | ");
52+
elseif any(Passed)
53+
Badge.color = "yellowgreen";
54+
Badge.message = join("R")
55+
elseif all(~Passed)
56+
Badge.color = "critical";
57+
Badge.message = join("R"+Version," | ");
58+
end
59+
Badge = jsonencode(Badge);
60+
writelines(Badge,fullfile("Images","TestedWith.json"));
61+
62+
if ShowReport
63+
web(fullfile(Folder,"index.html"))
64+
end
65+
66+
end

0 commit comments

Comments
 (0)