Showing posts with label Computer Science. Show all posts
Showing posts with label Computer Science. Show all posts

AI and ML in Education

Image of two screens side by side. left with a childish idea of a lake and mountain, the right an AI realistic painting created from the childs image
nVidia's GAUGAN AI image creation
Computer programming as a mandated part of the curriculum began in the UK in 2013. Six years later we are beginning to see other educational regions requiring computer programing in the curriculum. But what about some of the more advanced tool? What about Machine Learning (ML) and Artificial Intelligence (AI)? We live with intelligent tools daily now. Whether you are shopping online or asking Siri for the time you are connecting to intelligent machines. But we aren’t all discussing how to implement it in the classroom. My mission at ISTE 2019 in Philadelphia was to explore what we are doing with AI and education. Here’s what I’ve taken away. 
We have been asking an entire profession to pick up a necessary skill set by tomorrow. And we need them to do it again. Computer programming in the classroom integrated through various courses is very popular now. Many classrooms are drawn to block-based coding like Scratch or Code.org. Much of the content delivery can be done through a video tutorial and try it yourself technique. The educator doesn’t need to know much about computer programing just enough about technology to setup a digital classroom. While this is not the most effective way to educate it can get the job done. We need to begin approaching AI and ML topics in the classroom and this may be the way to get a jumpstart into it. 
AI and ML tasks are accessible now more than ever. Educational resources are out there to begin talking about and trying AI. Google has a number of projects which can spark a classroom conversation and exploration on the topic. One of my favorite tools is a visual training demonstration called Teachable Machine. Students can train the system to recognize objects. The concept of data being routed through neural networks is very clear from the visual layout of the website. It can spark conversation on the differences between sensing and perceiving. The extraction of meaning from the images to say a word, show a gif, or play a sound supports student understanding of the concept of perception. This easily integrates into biology curriculum as the human senses are explored. 
Large datasets can be engaged by our students in various ways. Gapminder provides a visually stunning display of over 100 years of data. We can see populations grow and shrink over time as it’s tracked over 6 variables. This timeline motion chart feature brings something to the classroom we would have to make a 100 page graph paper flip book to replicate in the physical world. While this is a goto dataset there are others to explore with classes. The conversation can be around math or history. It all depends on from what angle you want to look at the material. The life expectancy drops from world wars are very clear. 
Life expectancy and income compared overtime


The level or AI and ML learning our students need to be at when graduating high school as recommended by AI4K12.org is high. I agree with their guidelines and I’ve been working to educate myself but I still am about the level of a 6th grader.
Benchmarks for AI in the classroom "What students should be able to do."
Educators need more educational opportunities to be able to understand the emerging technology. Curriculum will be generated by the big tech companies but it’s a necessity for educators to have a bit of a deeper knowledge of the tools than the in-the-box materials provided. We need to know what’s possible in order to integrate the learning throughout our curriculum. The work of Dr. Scott Garrigan can be a wonderful place to start. He is an educator whose interest is in cognitive disabilities. He provides professional development on many topics. He understands the pedagogy and can help support in implementing AI and ML through a curriculum. 


While this is not an exhaustive list of resources they do provide places to get started. 



We will very quickly approach the point that we won’t be able to tell if a computer is speaking to us or a human. Just last year Google Duplex was demoed and is now released. If this is our reality now what will it be when our students graduate? Shouldn’t we begin making the effort to include AI in our curriculum now? We are seeing a scramble to include coding in the curriculum. AI and ML have coding in them but the concepts can be vastly different. If we wait much longer to push this into our schools we will miss the opportunity and fall behind. 

In light of recent political events I was deeply struck by a quote regarding AI: “Whoever becomes the leader Artificial Intelligence will become the ruler of the world.” -Vladimir Putin, 2017. Looks like educators have some work to do. 

Visual Program - A response to "Why it's a bad Idea" by Mike Hadlow


After reading Mike Hadlow’s post on his blog titled “Code Rant: Visual Programming - Why it’s a Bad Idea” I feel I need to respond. Mike references block based coding such as the education tool “Scratch” from MIT. He points out three reasons why he thinks block based coding is bad. "1. Textual programming languages obfuscate what is essentially a simple process. 2. Abstraction and decoupling play a small and peripheral part in programming. 3. The tools that have been developed to support programming are unimportant."

What he doesn’t take into account is how we learn to code and think computationally. There is a process of learning how to identify a problem, pull a problem a part, break it down into abstract representational ideas, and build a step by step procedure to solve the problem. These parts can be looked at using a design thinking flow where we continually reconsider what we are doing and if out solution works. As we teach young students how to think computationally it’s helpful to have a system which can give immediate results. Block-based/visual coding is intended for the novice programmer. It’s there to give quick results without concern for syntax. The blocks don’t allow for syntax errors. 

I'm guilty of spending hours staring at code and going through debugging steps only to learn I spelled something wrong. When you start with code this sort of bug is enough to made you never want to code again. Perseverance does not happen over night. It's built incrementally. Block-based code allows for quick success of code without the headache.

Coding is very different from math but has similarities in how we grasp the concepts. Teaching coding requires giving the code concept to start. Allowing the student to modify the given code to see what happens. Then tasking the student to create something using the code and any other code or creative tools they can bring in. This iterative education process works best with visual code when there is no concern about syntax errors. The only errors are in how the code is put together. 

Do specifically address Mike's points:

1. Textual programming languages obfuscate what is essentially a simple process.
To a seasoned programmer this is very true. After I learned how to code with interpreted languages like JavaScript I've had that question of, "How does it really do that?". Even text-based code can obfuscate a simple process. Many languages have text functions build in, ie Left(data, count of characters). The function is slicer of the data inputed. This is not a concept a novice needs to know as they use the Left function. The real mechanics are hidden. Visual code also hides the actual functions. 

2. Abstraction and decoupling play a small and peripheral part in programming.
I firmly disagree with this. When building a realistic game you need to provide gravity. Well, how do you give an accurate representation of gravity? How do you designate where the floor is? How high can your character jump? These are abstract concepts which can be represented by an algorithm. Students can't figure it out unless they explore the abstraction of gravity. Yes things get complex but part of coding is creating efficient code which interacts seamlessly and simply with other code. Gravity can become a function with quick inputs making it fairly universal for each character. Complexity can increase by adding more features but well built functions help to Make sense of it. 

3. The tools that have been developed to support programming are unimportant.
The tools that have been developed to support programing are what make it accessible to others. I've programmed in a raw text editor for years. I torture myself so I memorize code functionality. For a novice the tools to support programming are what make the difference. I spend a lot of time playing with Google Apps Script. The intelligent suggesting of options support my exploration and make me more efficient. Google provides suggestions to code; intelligent suggestions. I know my variable is not initialized because of the color signifier. It's a pleasure to program with Google and it's the coding environment which keeps me coding there. I promote Google Apps Script because it's easy to code in. 

I will say block based coding can be improved by providing tools to transition from the visual code to a syntactical base. Allow me to pull in the code in visual format. But give me the ability to pull back the visual curtain. Block based code makes it accessible to those that may have previously been intimidated. And let's face it, we can type faster than we can drag in code. once we start getting the hang of it we lean to typing the code. 

Non-technical people need to have access to coding. It's up there with learning math, language, science, history and arts. our lives are split between our digital life and our physical life. I can cook and make a basic meal in my physical life. Coding is relative. People need to know how to craft some basic code to help them solve a problem in their digital life. 


And just for fun here's a Scratch project I did in 10 minutes to teach about conditionals.






Looping Through Data


I don't know about you, but I often organize students with google sheets. I use rows for each student and columns for information related to the student. Sometimes I need to push this informatiuon back to students or parents. Sometimes I have do something else with the information. It’s helpful to know how to get the data and work with it in a loop.

Spreadsheets are a two dimensional arrays. There is information in Rows, dimension 1,  and information in columns, dimension 2. We can target each cell by knowing the proper row and column.

We can also loop through each row and do something with the data. 

Computers start counting from 0. Google Sheets starts counting the informational rows and columns from 1. I will also use my own label in row 1 to identify the column number. This way I can insert columns and move them around and still retrieve the same information. Let’s start with identifying the columns by our own labels and setting the column number to a variable which makes sense to us. 

function loopThroughData(){

  var ss= SpreadsheetApp.getActiveSpreadsheet();
  var sheet= SpreadsheetApp.getActiveSheet();
  var emailcol = getColumnByName(sheet, "Email");
  Logger.log(emailcol);
}

function getColumnByName(sheet, name) {
  var range = sheet.getRange(1, 1, 1, sheet.getMaxColumns());
  var values = range.getValues();
  for (var row in values) {
    for (var col in values[row]) {
      if (values[row][col] == name) {
        return parseInt(col)+1;
      }
    }
  }
}

A function called getColumnByName is used in our loopThroughData function. It’s used with two variables pushed into it. The first is the sheet we are working on and the second is the column name. This function runs and will return the column number if the column name is found. The program returns to the loopThroughData function and completes the script Logging the column number. 
This begins to give us some flexibility with the sheet. We can add and move columns and not work about breaking our program. We can run it and we’ll see the column number returned in the log. The intent here is to be able to loop through and use data in a full sheet. We know how to get the column numbers but what about the rows and the rest of the data. 

Efficiency in code so far doesn’t seem like a big deal. We’ve looked at very little data. But if we were to use an entire sheet composed of the maximum 5,000,000 cells (as of the newest 2018 update) we need to start being aware of how long each step of code takes. Even if we consider using up to 1,000,000 cells it can take longer than we expect to finish our script. Attendance data can exist in large data sets. Consider a school of 400 students * 180 school days * 7 classes each of attendance. 504,000 cells of data. If a step of our program takes .01 seconds it will take 5,040 seconds to complete or 84 minutes or 1 hour and 24 seconds. And that’s just one step. So while we can pull each cell individually with sheet.getRange(row, column).getValue() we need to ask ourselves if it’s the most efficient. 

Our loop will instead pull all the data, once, and reference it in the computer memory. Below I concentrate on our main function our getColumnByName should remain in the script. I usually keep functions I use in larger functions at the bottom on all my scripts. 

function loopThroughData(){
  var ss= SpreadsheetApp.getActiveSpreadsheet();
  var sheet= SpreadsheetApp.getActiveSheet();
  var emailcol = getColumnByName(sheet, "Email");
  var data = sheet.getDataRange().getValues();
  for (var i =1;i<data.length;i++){
    Logger.log(data[i][emailcol-1]);
  }
}

The variable data is the used area of the sheet. It provides data in a matrix format. The first referenced data index is the row. The second is the column. We would use a reference to the index number of the row and column to reference a value. The index starts from 0 so row 0 is our header. In the sheet it’s row 1.Our column   numbers compared to the sheet are all offset by -1. To return the header cell containing “Email” we can use row 0 and column emailcol-1. We’d write it like this in our script.

data[0][emailcol-1]

The square brackets [] are used to indicate an index number. They can be strung together to reference indexes of indexes.

Now that we have a concept of indexes we are going to use a for loop to walk through our rows of data. For loops have three inputs to get them started. First a variable to count with set to the first number; var i = 0. Then the end of the loop as an expression. I usually think “while” in my head as I write it; i<data.length. And finally an increment for our counting variable to increase by with each loop; i++. JavaScript allows the short hand of using ++ to increment by 1 rather than i=i+1.

Here’s our initial for loop. 
for (var i =1;i<data.length;i++)

The loop needs to know what to do each time around. We put an action inside curly brackets { and }. We can also use the i variable in our action. 

data[i][emailcol-1]

With data we are saying return the second row (computers start from 0 and i starts being set as 1 se we are skipping our header row) and the column of the email (we assigned emailcol as the sheet column which is now offset in data by -1 so we offset the email column number by -1).

Putting it all together we can loop through the data and do something with it. Above we are returning whatever is in the email column and putting it in the log. We can instead send emails, create slides, make websites or many other operations which we would do manually but take a lot of time. Here's a sample sheet that sends out emails. 
Sample

Enjoy!

onFormSubmit Do Something: Part 1


Did you know Google Scripts can be triggered when a form submits to do something? Assigning a function to the onFormSubmit trigger and it will call that function. Let’s build one now to email a response to a submitted form.

We all have sign-ups we use with our school community. Sometimes when some one signs up we need to provide them with a document and other information. With Google Apps Scripts we can automatically send an email to the person that signed up with attachments.  

Let’s explore. 
Start by creating a form. Be sure to turn on the Email capture or make a field for people to type their email and validate it as an email. Add any other questions to your form that you like. Keep the Allow only 1 response off so we can test with our own email multiple times.

Our script will be built in Google Sheets. IN the form responses link the responses to a new sheet. Open the sheet and select Tools>Script editor. The editor will open in a new tab. Give a name to your script. Remove the pre-populated function, myFunction, so we are working with a blank area. Let’s begin our function:

function formResponse(e){
}

I’m calling it formResponse because it makes sense to me. I made up this name for the function. It’s also case sensitive. So if I use it later I have to be sure it’s typed exactly the same way. 
This function is going to take an input of e.  e represents the form response. Let’s first take a look at what e looks like when it’s received. We’ll use the Logger for this. In the function type Logger.log(e);

function formResponse(e){
   Logger.log(e);
}

Now let’s hook up the trigger before testing. Click on the button that looks like a clock. 

This will open the Trigger settings. Click "No triggers set up. Click here to add one now." to add a trigger.






It will likely automatically populate the function we create. The Run column identifies the function to activate. The Events column gives the selection to happen either when something in the spreadsheet happens or time based. The last column is the specific event triggering the function. We can add more than one function to activate when triggered and multiple triggers.


Click Save to save the trigger to our form. You will be asked to approve some permissions. Click Review Permissions. Select your account, then click Allow on the next screen.


Now let's see what data looks like when it comes into the form. Open the form in submission mode. Fill it out and click submit. Our function will have captured the submission in the Logger. To get to the logger click View>Logs. This will open a window floating over our script with the data from the form submission.

When we look at the Logger we are seeing the form submission in the form of a program object. Let’s look closely at the label values. Notice it equals an open square bracket, "[",  then some comma separated information followed by a closed square bracket, "]". This is the information submitted through the Form as a list. A list is separated data with an unseen reference called an index. The index starts counting from 0. The first piece of data in the list is the timestamp. Let’s grab the timestamp and show it in our log. To return that value only we would use the input object e and the array values in e with the index 0. Logger.log(e.values[0]);

function formResponse(e){
   Logger.log(e.values[0]);
}

When we look at the Logger now we see only the timestamp. With this method we can identify the Email or other response data. We'll look further into how to use the response to do something in the next post. 

Google Apps Script Programming

I’ve been asked a few times to teacher a course for teachers on Google Apps Scripts. So I’m going to begin talking out the structure here until I can get a class together. I'll be working with Chrome to explore Scripts.

Scripts are instructions for a computer. The are read just as they are. they are a form of coding but not all coding or programming is scripting. Some languages have to be turned into specific computer read forms. This translation is called compiling. Scripts are interpreted just as they are. Most web interactions are done with scripts. Google Apps Script uses JavaScript. Typically javascript runs in the users computer. Google Apps Scripts run in the Google Cloud on the google servers. This makes the power of it consistent despite the user's machine. For a JavaScript course check out Codecacademy. I'll be using Google Apps Scripts, the Information on javascript can be helpful for a deeper under standing but not mandatory.


Let’s open Google Apps Scripts. Select One of the main GSuite Apps; Sheets, Docs, or Slides.  
On the top menu bar under Tools select Scripts
This opens a new tab with scripting tools to begin programing Forms opens slightly different from the three dots menu.

There’s a number of features within this tool but let’s keep it simple to begin. In Scripts we write functions. Let’s say you want a series of things done to come up with a particular result. We align code together in a function to be done in order to return some result. 

Usually we make up our own names for functions. The naming of things is usually where people get confused. Some names are reserved by the language creators to do things. To begin we’ll use a reserved function name in our code. JavaScript is case sensitive. So Function is different than function. And X is different than x. Mind your cases as you work. 

In the scripting area we are seeing:
function myFunction(){
}

We can remove this. Basically, it’s a prewritten function which does nothing. Let’s write our own. 
function:

function onOpen(){
  alert(“Hello World”);
}

This function uses a few reserved words.

  • function tells the browser that this is a series of code to be run in the order specified. 
  • onOpen is a reserved function name that binds the function to the document opening. 
  • alert is a reserved name for a function in JavaScript. 

The characters in our function also represent things.

  • The first () after onOpen are there to take in a value. 
  • The { is the start of our function. 
  • The } is the end of our function. 
  • Anything between { and } is part of our function,
  • alert uses () to take in a value. This is synonymous with the onOpen parentheses, (), which can take in a value. 
  • The “ “ are identifying what’s between them as words or what’s called a string datatype. 
  • The ; ends the line of code and tells to browser to move to the next line. 

For a function it must be structured in this way with <some name> being what you want to call your function and action code; being what you want you function to do. 
function <some name>(){
  action code;
  action code;
}

If you haven’t experimented with onOpen yet try it now. Close the document you were working on. Open your document back up from the drive. Give it a moment. Did you get an alert saying “Hello World”? If you did congratulations! If not compare your code to mine meticulously or copy and paste it. Remember it’s case sensitive. 

Let’s consider a usage for our pop-up. It’s great for quick disappearing messages. So directions would not be good here. Perhaps you want to give a shout out to a birthday, a high achiever, someone who did something special or unique. What about a quick reminder, “use the references”, “check your grammar”, “trip on Friday!”. Whatever you write is general to anyone who opens it right now. Can we get specific for individuals? It’s possible. For now let’s celebrate that you just wrote some code that you can use in class right away.

Congratulations!


Any copy of a Doc, Sheet, Slides, or Form will contain the script. If you write some great code you want to use in another file you can copy the code and past it to the new file’s scripting area or copy the file. 

Social Emotional Well-Being During Online Teaching and Learning

The world is a bit nutty right now because of the COVID-19 pandemic. Schools are switching to online learning and parents are working from...