Predicting California Housing Prices: Data Visualization and Machine Learning in MATLAB

Chao Wang, Arizona State University at the Tempe Campus,
Author Profile
Initial Publication Date: October 10, 2024

Summary

This exercise aims to give freshman engineering students a brief introduction to data science, data visualization and machine learning.

Share your modifications and improvements to this activity through the Community Contribution Tool »

Learning Goals

For this exercise, students are given a California housing data set and the goal is to expose students to data visualization techniques other than a simple 2D plot. It also introduces students to machine learning concept, specifically regression model, through predicting the median house value using the given variables in the data set.

The instructor will walk through the MATLAB live script with the students in class and demonstrate how to use the low code data analysis features in MATLAB to generate visualization and train machine learning models.

Context for Use

This exercise will be implemented in a freshman "Introduction to Engineering" class. This class meets twice a week, one hour and fifty minutes for each lecture. Students are from different engineering disciplines such as aerospace, biomedical, chemical, electrical and mechanical enginering.
MATLAB is introduced to students through the "MATLAB Onramp" homework assignment.

Having finished MATLAB Onramp, students enter the three-lecture sequence after already familiarizing themselves with MATLAB. In the first lecture, I quickly review the basics that the students learned and have them practice using MATLAB to write and run scripts; define and access scalar, vector, and matrix variables; and create 2D plots from data imported from a text file. In the second lecture of the series, students use MATLAB to solve problems from various engineering disciplines. For example, I have them import experimental data from a file and create plots to visualize the relationship between input and output variables. I also have students practice data analysis skills needed in all engineering disciplines, such as curve fitting, interpolation, and extrapolation.

This exercise will be a followup to the above lessons and will take less than one hour.

Description and Teaching Materials

Materials includes data file, MATLAB live scripts and two MATLAB generated functions.
MATLAB live script (MATLAB Live Script 365kB Oct10 24) 
data file (Comma Separated Values 986kB Oct10 24) 
MATLAB function file (Matlab File 1kB Oct10 24) 
MATLAB function file (Matlab File 4kB Oct10 24) 

Teaching Notes and Tips

Live demonstration is needed to work through the MATLAB script together with the students.


Assessment

References and Resources