Skip to content

Commit

Permalink
Update module structure
Browse files Browse the repository at this point in the history
  • Loading branch information
rweinsteMW committed Nov 20, 2023
1 parent 2b0254b commit e8b664e
Show file tree
Hide file tree
Showing 139 changed files with 1,095 additions and 67 deletions.
8 changes: 6 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*.mexa64 binary
*.mexw64 binary
*.mexmaci64 binary
*.mlapp binary
*.mlapp binary linguist-language=MATLAB
*.mldatx binary
*.mlproj binary
*.mlx binary
*.mlx binary merge=mlAutoMerge linguist-language=MATLAB
*.p binary
*.sfx binary
*.sldd binary
Expand All @@ -26,3 +26,7 @@
*.pdf binary
*.png binary
*.xlsx binary

# Ignore HTML

*.html linguist-detectable=false
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: MATLAB Build

# Controls when the action will run.
on:
push:
branches: [ release ]
pull_request:
branches: [ release ]
workflow_dispatch:

jobs:
test:
strategy:
fail-fast: false
matrix:
MATLABVersion: [R2023a,R2023b]
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Sets up MATLAB on the GitHub Actions runner
- name: Setup MATLAB
uses: matlab-actions/setup-matlab@v1
with:
release: ${{ matrix.MATLABVersion }}

# Run SmokeTests
- name: Run SmokeTests
uses: matlab-actions/run-command@v1
with:
command: openProject(pwd); results = runtests(fullfile("SoftwareTests","SmokeTests.m")); assertSuccess(results);

# Run FunctionTests
- name: Run FunctionTests
uses: matlab-actions/run-command@v1
with:
command: openProject(pwd); results = runtests(fullfile("SoftwareTests","FunctionTests.m")); assertSuccess(results);

# Upload the test results as artifact
- name: Upload TestResults
uses: actions/upload-artifact@v3.1.3
with:
name: TestResults
path: ./SoftwareTests/TestResults_${{ matrix.MATLABVersion }}.txt

# Download the test results from artifact
- name: Download TestResults
uses: actions/download-artifact@v2.1.1
with:
name: TestResults
path: ./SoftwareTests/

# Create the test results badge
- name: Run CreateBadge
uses: matlab-actions/run-command@v1
with:
command: openProject(pwd); results = runtests(fullfile("SoftwareTests","CreateBadge.m"));

# Commit the JSON for the MATLAB releases badge
- name: Commit changed files
continue-on-error: true
run: |
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"
git commit Images/TestedWith.json -m "Update CI badges ${{ github.ref_name }}"
git fetch
git push
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
# List of untracked files to ignore

# Autosave files
*.asv
*.m~
*.autosave
*.slx.r*
*.mdl.r*

# MATLAB Drive
*.MATLABDriveTag

# Compiled files
*.mex*
*.p

# Compressed files
*.zip

# Packaged app and toolbox files
*.mlappinstall
*.mltbx

# Deployable archives
*.ctf

# Generated helpsearch folders
helpsearch*/

# Defined Simulink cache folder
Utilities/SimulinkCache/*

# Standard code generation folders
slprj/
sccprj/
codegen/

# Code generation file
*.eep
*.elf
*.hex
*.bin

# Cache files
*.slxc

# Project settings
Utilities/ProjectSettings.mat

# Test results
SoftwareTests/TestResults_*
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contributing

>_If you believe you have discovered a security vulnerability, please **do not** open an issue or make a pull request. Follow the instructions in the [SECURITY.md](SECURITY.md) file in this repository._
Thank you for your interest in contributing to a MathWorks repository! We encourage contributions large and small to this repository.

**Contributions do not have to be code!** If you see a way to explain things more clearly or a great example of how to use something, please contribute it (or a link to your content). We welcome issues even if you don't code the solution. We also welcome pull requests to resolve issues that we haven't gotten to yet!

## How to give feedback
* **Send us an email:** Contact the [MathWorks teaching resources team.](mailto:onlineteaching@mathworks.com)
* **Open an issue:** Start by [creating an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue) in the repository that you're interested in. That will start a conversation with the maintainer. When you are creating a bug report, please include as many details as possible. Please remember that other people do not have your background or understanding of the issue; make sure you are clear and complete in your description.

## How to contribute to the repository
* **Work in your own public fork:** If you choose to make a contribution, you should [fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo). This creates an editable copy on GitHub where you can write, test, and refine your changes. We suggest that you keep your changes small and focused on the issue you submitted.
* **Sign a Contributor License Agreement (CLA):** We require that all outside contributors sign a [CLA](https://en.wikipedia.org/wiki/Contributor_License_Agreement) before we can accept your contribution. When you create a pull request (see below), we'll reach out to you if you do not already have one on file. Essentially, the CLA gives us permission to publish your contribution as part of the repository.
* **Make a pull request:** "[Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests)" is a confusing term, but it means exactly what it says: You're requesting that the maintainers of the repository pull your changes in. If you don't have a CLA on file, we'll reach out to you. Your contribution will be reviewed, and we may ask you to revise your pull request based on our feedback. Once everyone is satisfied, we'll merge your pull request into the repository.

## Guidelines

We don't have best practices for writing MATLAB&reg; code, but we do have some recommendations:

* You should not have any warnings or errors in the [code analyzer report](http://www.mathworks.com/help/matlab/matlab_prog/matlab-code-analyzer-report.html)
* [Loren Shure's blog](https://blogs.mathworks.com/loren) has [great advice on improving your MATLAB code](https://blogs.mathworks.com/loren/category/best-practice/)
* Examples should be written as [live scripts](https://www.mathworks.com/help/matlab/matlab_prog/what-is-a-live-script-or-function.html) or [Simulink&reg; models](https://www.mathworks.com/help/simulink/index.html).
* We adhere to the [CommonMark](https://commonmark.org/) specification where it does not conflict with GitHub rendering. If you edit your Markdown in Visual Studio Code or a similar editor, it uses [markdownlint](https://github.com/DavidAnson/markdownlint) to highlight issues in your Markdown.

**Again, thanks for contributing, and we look forward to your issues and pull requests!**
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added Images/RegressionBasics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/image_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2023, The MathWorks, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
* Neither the name of the The MathWorks, Inc. nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Binary file added MainMenu.mlx
Binary file not shown.
130 changes: 81 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,85 @@
# Regression Basics
[![View Regression Basics on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/93435-regression-basics)
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/Regression-Basics&project=RegressionBasics.prj)

<a name="T_DEF03274"></a>
# <span style="color:rgb(213,80,0)">Regression Basics</span>
<a name="H_053613DF"></a>

**Curriculum Module**
_Created with R2020a. Compatible with R2020a and later releases._
[![View on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/93435-regression-basics) 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/Regression-Basics&project=RegressionBasics.prj)

## Description ##
This package contains a [live script](https://www.mathworks.com/products/matlab/live-editor.html) and supporting files to illustrate some basics of regression analysis. The materials are designed to be flexible and can be easily modified to accommodate a variety of teaching and learning methods. We include a brief background, interactive illustrations, tasks, reflection questions, a real-world application example, and a guided exercise for the different concepts explored.
**Curriculum Module**

The instructions inside the live scripts will guide you through the tasks and activities one section at a time. To run this interactive script in a controls-only mode, use the **Hide code** button on the **View** tab of the MATLAB toolstrip.
_Created with R2020a. Compatible with R2020a and later releases._

**Learning Goals**
- Explain the difference between linear, multiple linear, and nonlinear regression.
- Use ordinary least squares to analytically solve for linear regression parameters.
- Assess and improve the performance of a regression model using a goodness-of-fit measure.
- Apply gradient descent to iteratively minimize a cost function and estimate model parameters.
- Explain the effect of increasing and decreasing the learning rate and number of steps for the gradient descent algorithm.
- Use a linear regression model to perform short-term forecasting.

<img src="https://user-images.githubusercontent.com/81376570/122819892-02032a80-d2a9-11eb-993b-a3069f9df662.gif" height = "300"/>

## Suggested Prework ##
[MATLAB Onramp](https://matlabacademy.mathworks.com/details/matlab-onramp/gettingstarted) – a free two-hour introductory tutorial to learn the essentials of MATLAB®.

## Details ##

**`regressionBasics.mlx`** [![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/Regression-Basics&project=RegressionBasics.prj&file=regressionBasics.mlx)
An interactive lesson that introduces the fundamentals of regression analysis. Students apply a basic linear regression to model real-world electricity load data.

## ##
**`electricityLoadData.mlx`** [![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/Regression-Basics&project=RegressionBasics.prj&file=electricityLoadData.mlx)
A supplementary script to download the external electricity load data from [New York ISO](http://mis.nyiso.com/public/) for use in the practice problem.

## ##
**`regressSolnIm/`**
This folder includes supplementary image files containing solutions for tasks in `regressionBasics.mlx`. The main script provides controls to hide or expose the solutions when needed. Ensure that this folder is in the same location as `regressionBasics.mlx`

## ##
**`linearData.mat`, `linearData2.mat`, `multivariateData.mat`, `nonlinearData.mat`**
Data files containing some sample data for the different types of regression problems.

## Products ##
MATLAB&reg;, Statistics and Machine Learning Toolbox&trade;

## License ##
The license for this module is available in the LICENSE.TXT file in this GitHub repository.

## Support ##
Have any questions or feedback? Contact the [MathWorks online teaching team](mailto:onlineteaching@mathworks.com).

# #
_Copyright 2021 The MathWorks, Inc._
# Information

This curriculum module contains an interactive [MATLAB® live script](https://www.mathworks.com/products/matlab/live-editor.html) that illustrates some basic concepts of regression analysis.

<a name="H_F00D98E4"></a>
## Background

You can use this live script as a demonstration in lectures, a class activity, or an interactive assignment outside class. This module covers topics including solving for linear regression parameters, assessing and improving performance of regression models, and applying the gradient descent algorithm. It also includes an example of using a linear regression model to perform short-term forecasting.


The instructions inside the live script will guide you through the exercises and activities. Get started with the 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.

## Contact Us

Solutions are available upon instructor request. Contact the [MathWorks teaching resources team](mailto:onlineteaching@mathworks.com) if you would like to request solutions, provide feedback, or if you have a question.

<a name="H_30BC7141"></a>
## Prerequisites

This module assumes knowledge of plotting and working with linear data.

<a name="H_330E72C3"></a>
## Getting Started
### Accessing the Module
### **On MATLAB Online:**

Use the [<img src="Images/image_1.png" width="136" alt="image_1.png">](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Regression-Basics&project=RegressionBasics.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.

### **On Desktop:**

Download or clone this repository. Open MATLAB, navigate to the folder containing these scripts and double-click on [RegressionBasics.prj](RegressionBasics.prj). It will add the appropriate files to your MATLAB path and open an app that asks you where you would like to start.


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**.

<a name="H_E850B4FF"></a>
## Products

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

<a name="H_E8C62B23"></a>
# Scripts

*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/93435-regression-basics)

## [**RegressionBasics.mlx**](Scripts/RegressionBasics.mlx)
| <img src="Images/image_3.png" width="171" alt="image_3.png"> | **In this script, students will...** <br>- Use least squares to solve for linear regression paramaters <br>- Use a goodness-of-fit measure to assess model performance <br>- Apply a basic linear regression to model real-world electricity load data |
| :-- | :-- |

# Related Courseware Modules
<a name="H_61EB2540"></a>
## [**Machine Learning for Regression**](https://www.mathworks.com/matlabcentral/fileexchange/95903-machine-learning-for-regression)
| <img src="Images/image_4.png" width="171" alt="image_4.png"> | **Available on:**[<img src="Images/image_5.png" width="129" alt="image_5.png">](https://www.mathworks.com/matlabcentral/fileexchange/95903-machine-learning-for-regression)[<img src="Images/image_6.png" width="130" alt="image_6.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) |
| :-- | :-- |

<a name="H_61EB2540"></a>
## [**Machine Learning Methods: Clustering**](https://www.mathworks.com/matlabcentral/fileexchange/135381-machine-learning-methods-clustering)
| <img src="Images/image_7.png" width="171" alt="image_7.png"> | **Available on:**[<img src="Images/image_8.png" width="129" alt="image_8.png">](https://www.mathworks.com/matlabcentral/fileexchange/135381-machine-learning-methods-clustering)[<img src="Images/image_9.png" width="130" alt="image_9.png">](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Machine-Learning-Methods-Clustering&project=MLMethodsClustering.prj)[GitHub](https://github.com/MathWorks-Teaching-Resources/Machine-Learning-Methods-Clustering) |
| :-- | :-- |


Or feel free to explore our other [modular courseware content](https://www.mathworks.com/matlabcentral/fileexchange/?q=tag%3A%22courseware+module%22&sort=downloads_desc_30d).

# Educator Resources
- [Educator Page](https://www.mathworks.com/academia/educators.html)
<a name="H_0FA5DA18"></a>
# Contribute

Looking for more? Find an issue? Have a suggestion? Please contact the [MathWorks teaching resources team](mailto:%20onlineteaching@mathworks.com). If you want to contribute directly to this project, you can find information about how to do so in the [CONTRIBUTING.md](https://github.com/MathWorks-Teaching-Resources/Regression-Basics/blob/release/CONTRIBUTING.md) page on GitHub.


*©* Copyright 2023 The MathWorks™, Inc

Expand Down
Binary file added README.mlx
Binary file not shown.
File renamed without changes.
Binary file not shown.
Loading

0 comments on commit e8b664e

Please sign in to comment.