EME 210
Data Analytics for Energy Systems

Introducing Neural Networks

PrintPrint

Read It: Introducing Neural Networks

So, over the last few weeks we've gone from linear regression and talked about various subtopics within there-- testing whether we have significant correlation between two variables, whether the slope is significant. Once we do establish those, do we fit a good model?  

[00:00:29.68] And then can we use that model for reasonable predictions? And what can we say about the uncertainty about those predictions? And then we've, in the last week or last two lectures, gone over multiple linear regression. So, let's not limit ourselves to just a line, but let's talk about incorporating other x's so that we can get an even better model that can make even better predictions.  

[00:00:51.50] And by the way, the graphical analogy there is with simple linear regression, we're just doing a straight line. And then if we add in another x, we're putting a surface. And if we're adding in-- and it's a flat surface, by the way. And if we start adding in interaction terms-- let's say if we have x1 plus x2 plus x1 times x2, we're fitting a curved surface.  

[00:01:16.96] We're allowing that surface to curve. So that's kind of the graphical analogy of this. I find that can be helpful to kind of understand conceptually what's going on.  

[00:01:30.30] But then when you add in other x's, well, how do you go from a 2D surface to a 3D surface? That doesn't really make sense, and so you get into higher dimensions. And it becomes a little crazier.  

[00:01:40.29] And so today we're going to dive into neural networks. Let's get even more complicated here. Let's go from multilinear regression into something so much more complicated that we have to call it something else-- neural networks. Here we're looking at basically a network of linear relationships-- so lots and lots and lots of different smaller linear models, essentially, but all strung together into a network.  

 Watch It: Video -  ( minutes) REPLACE WITH CORRECT VIDEO

Click here for a transcript.

ADD TRANSCRIPT TEXT HERE

Credit: © Penn State is licensed under CC BY-NC-SA 4.0

Try It: OPTION 1 GOOGLE COLAB

  1. Click the Google Colab file used in the video here.
  2. Go to the Colab file and click "File" then "Save a copy in Drive", this will create a new Colab file that you can edit in your own Google Drive account.
  3. Once you have it saved in your Drive, try to implement the following code to import a file of your choice by mounting your Google Drive:

Note: You must be logged into your PSU Google Workspace in order to access the file.

from google.colab import drive

drive.mount('/content/drive')

import pandas as pd

df = pd.read_csv('yourfilename.csv')

df # print the dataframe

Once you have implemented this code on your own, come back to this page to test your knowledge.


OPTION 2 : DATACAMP

 Try It: OPTION 2 DataCamp - Apply Your Coding Skills

Dictionaries are a quick way to create a variable from scratch. However, their functionality is limited, so we will often want to convert those dictionaries into DataFrames. Try to code this conversion in the cell below. Hint: Make sure to import the Pandas library.

# This will get executed each time the exercise gets initialized. # Create a Simple Dictionary mydict = {'Name':['Amy', 'Bob', 'Clair', 'Daisy'], 'Birthday':['9/3/1991', '4/21/1988', '4/21/1990', '11/11/1989'], 'Age':[31, 34, 32, 33]} # convert the dictionary to a DataFrame # print the values in the 'Birthday' column # Create a Simple Dictionary mydict = {'Name':['Amy', 'Bob', 'Clair', 'Daisy'], 'Birthday':['9/3/1991', '4/21/1988', '4/21/1990', '11/11/1989'], 'Age':[31, 34, 32, 33]} # convert the dictionary to a DataFrame import pandas as pd mydataframe = pd.DataFrame(mydict) # print the values in the 'Birthday' column mydataframe['Birthday']


Assess It: Check Your Knowledge

Knowledge Check (replace question)