EME 210
Data Analytics for Energy Systems

Conceptual Feed-Forward Neural Network

PrintPrint

Read It: Conceptual Feed-Forward Neural Network

Enter image and alt text here. No sizes!
ADD IMAGEL27:Slide 6
Enter image credit here

[00:28:33.60] Does that make sense, guys? OK. OK, so let's talk a little bit more about the architecture of the neural network and some things that we can define. So of course, we have our inputs. And we can select what inputs to give it. Or we can just throw everything in there.  

[00:28:55.40] You have a recs data set. Why not just grab all the variables and just throw them all in? You could do that, but it does have some repercussions in terms of the computational cost of this thing. And essentially, the more complex this whole network gets, the more time it's going to take to train. The more time it'll take to run and get a prediction. But it's mostly the training part that takes a longer time.  

[00:29:24.96] So you need to select your input variables. And here, it's good to be judicious, to say, OK, I think-- this subset of variables, I think these matter a lot in predicting electricity use. I think how many numbers of rooms we have and total square footage and the number of children you have-- believe me, the number of children you have matters a lot in terms of electricity usage-- and so on and so forth.  

[00:29:49.43] You want to think about the problem you're actually solving. It'd be very naive and ill-suited to just throw everything in there and see what happens. I mean, you might end up getting a good model after you spend three days training the thing, but it's a little bit unwieldy. So  

[00:30:10.57] Then let's talk about the layers. So, this is called our input layer-- basically, one node here, a.k.a. neuron, for each input variable. And then these then link up to our first hidden layer, which links up to our second hidden layer. And we could have a third hidden layer and a fourth hidden layer and however many hidden layers we want.  

[00:30:39.04] And then there's an output layer. So, all our hidden layers are what are in between the input and the output. And as the name implies, they're hidden. And this gets to the black box thing I was saying before. We can't go in there and see exactly what's going on at each node.  

[00:31:00.41] Now, another name for the nodes are neurons. So, this is kind of where the term "neural networks" comes from is that it's-- in this representation I have here, it's modeled after the human brain, or any animal's brain, for that matter, where the way our brains work is we have a neuron, where inside the neuron, it's doing some very simple processing of an electrical signal. And it's taking an electrical signal from a neighboring neuron. So, you've got an axion that goes to some other neuron.  

[00:31:34.20] And after you link up many, many of these things, it's sort of like that game Telephone, if you've ever played that. You can string along some message and perform complicated tasks and learn complicated things, as humans are wont to do. And so, on these axions-- these lines connecting the two neurons-- we have our weights, a.k.a. our synaptic weights.  

[00:32:00.87] And so these are the things that we tune when we fit the neural network. These are the analogous terms to the betas in our multiple linear regression models. So, we're going to be adjusting the weights and the weights only when we fit the model to minimize the error or the difference between our output and the ground truth.  

[00:32:31.69] Make sense? Any questions about this? And by the way, in this representation, I've got multiple outputs here. But we may only have-- for many intents and purposes, we may only have just one output.  

[00:32:48.29] We may just have, say, kilowatt hours or one single variable. But you could easily have multiple outputs, too. In this example here, this is basically probability of sand and probability of shale. And it's a geological application here. Yeah.  


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)