Monday, June 21, 2021

The Bus Stop Problem

I ran into a fairly familiar conundrum (for me) the other day -- how long to wait for a long-running process to finish before assuming that there is something wrong? The details of the particular case are not important, but it had to do with doing with creating a Redshift table from a materialized view using INSERT INTO. I knew that the query would take some time, so I kicked it off and then went on to other things, checking back every once in a while. 

After an hour or so, I began to get a little nervous. Not having any admin access to Redshift itself, I had no real way of assessing progress. I was hoping that the job would finish within an hour, but I also knew that we had other operations that took several hours to complete, so I figured that this might take more time than hoped.

So I waited.

An hour later, I checked in again. Still not finished. Hmm. Maybe three hours is the magic number? I decided to be patient. 

As I kept checking in on my always-in-process query throughout the day, it struck me that I was feeling very much like someone waiting at a bus stop for the last bus of the evening. If you get to the bus stop right on time, but the bus isn't there, you start to wonder if it already came already (in which case you will be waiting all night) or if it is just running a few minutes late. The more you wait, the more nervous you become that you may be too late. But you also don't want to start walking away from the bus stop only to have the bus zoom by without seeing you. Do you wait, or do you walk?*  

I have a friend and former colleague, we'll call him "Bill", who rarely seems to experience this problem. As a long-time IT guru, he has a much better understanding of how various systems interact with each other, what the hardware specs of the machines he is working on are, what the theoretical limits are for certain operations, and how to combine all of that information into a reasonable estimate of expected performance. I've often marveled at how quickly after kicking off a process he will say something like "Hmmm, we should be getting much better throughput than that. I wonder if X, Y, or Z is happening?" I wish I had that ability.

Long story short, I ended up canceling the job after many more hours than I'd care to admit. I don't know for sure, but I think that there was a connection error early on and I was really waiting for the DB management tool to re-establish the connection rather than for the job to finish. Bill would know.....

*My analogy probably works better for someone like me who didn't grow up in a world with Uber and Lyft just a click away.

Monday, June 14, 2021

Pareto Learning Analytics

 The Pareto Principle (knows also as the 80/20 rule) roughly states that 80% of the benefit/cost comes from 20% of the input. (I'm sure there's a more rigorous definition, but this will do for our purposes.) That got me thinking about learning analytics, particularly in terms of the always elusive "learning dashboard" that will finally (in theory) bring the power of data to the business of teaching and learning.

If we grant that there is a Pareto-like effect for educational analytics, this would suggest that perhaps our dashboard won't need very many metrics on it. (Or, perhaps, no matter how many metrics are presented, only a small subset will be actually useful for anything.) Even though modern automobiles collect all sorts of information about the system, only a small subset are presented to the driver. And, of that subset, the only one we really pay attention to in real-time is probably the speedometer. (When was the last time you drove fixated on the engine temperature gauge or RPMs?)

This, in turn, got me thinking about what we could ever expect from a teacher- or student-oriented dashboard, even with "predictive analytics." Sure, it might be nice to know that historically N% of students who got X grade on test Y ended the course with a B+, but does that really change anything fundamental about what the student and/or instructor need to do to change the situation. Do we really need historical performance data to tell us that not leaving major assignments to the last minute is probably a good idea? 

But, you may argue, data allows us to make mid-course corrections. This is probably more true in theory than in practice and is very context dependent. If you are teaching an introductory session (or one of several sections) with hundreds of students, how much leeway is there really to diverge from the planned material? One can certainly hold an "after action report" at the end of the semester, replete with all sorts of information, to try to tweak the syllabus or materials to provide a better experience for future cohorts, but that may be rather tricky to do on-the-fly.

I'm not saying that one should not alter instruction in response to student performance -- I'm all for greater use of real formative assessment in the curriculum. But, rather, my point is that more than learning analytics, the cultivation of an environment in which that type of reflective, responsive teaching is supported (and even expected) is the real prerequisite to educational change, not the provision of a dashboard.

Tuesday, June 8, 2021

Moving Forward Without Prematurely Worrying About Future Bridges

This post is based on a "note to self" from two years ago.

In many undertakings, there is a fine line between being proactive (or energetic or take-charge) and being reckless. Very few people work in an environment where you can merely think your way to success, so the more things you try, the more likely you are to succeed. In general it is good make progress, but not if that progress comes at the expense of other important qualities, such as sustainability or safety, or causes irreparable damage to an important relationship. 

At the other end of the spectrum, there is a fine line between being cautious (or careful or prudent) and being moribund. In many situations, it is good to "look before you leap" to prevent avoidable mistakes or to make sure that you really understand what you are trying to do so you aren't happily running down the wrong path at the outset. At the same time, however, there are many situations in which you will be waiting forever if you wait for perfect information or the perfect design, so you really need to try something to move forward. Even if that approach ends up being abandoned in the long run, you will have learned more about your problem space.

Most people probably fall somewhere in the middle of the spectrum, with some being a little more on the "risk-taking" side and others being a little more on the "measure twice, cut once" side. I might also posit that the same person can exhibit different tendencies over time based on previous experiences. If you have been burned in the past by moving too quickly (perhaps an egregious error made its way to the the final version of the project and revealed itself in a very public way), you will likely have that in the back of your mind when similar conditions present themselves. On the other hand, if your deliberate approach has caused you to lose opportunities (or funding) to others "who can get things done," that may also influence your attitude moving forward.

One might imagine that there are certain organizations which tend to attract folks that are to one side or the other of the continuum. Even so, within an organization, or even a team, there may be a range of attitudes. And, of course, a proactive approach may be more appropriate for some projects while a cautious approach is more appropriate for others. Identifying your own "default" attitude can be useful, as can developing the ability to articulate specific reasons for why a proactive (or cautious) approach is warranted in a given situation. Otherwise you run the risk of being seen as reckless or moribund. 

The title of this post comes (obviously, I assume) from the saying "we'll cross that bridge when we come to it." Pretending that the bridge is of no consequence as you barrel towards it is probably reckless. That said, worrying endlessly about how you will cross the bridge is futile if that prevents you from ever starting the journey towards it in the first place.

Monday, June 7, 2021

When an AI Presentation Makes You Think of Proficiency Testing

 This is a very belated post about a presentation that I saw many months ago (summer 2020?). If memory serves, the presentation was from a NASEM (National Academies of Science Engineering Medicine) event, but I don't recall the details or the speakers. Like so many virtual talks during these pandemic times that I had planned to view with rapt attention, I ended up listening to it in the background while working on more pressing tasks.

 I do recall, however, one of the discussions which was focused on the topic of AI fairness. One thing that made me perk up was when of the panelists noted that although we rely on supervised learning algorithms to solve many real-world prediction needs, they are limited in scope of what we can predict because our predictions will be for the same relationships on which the model was trained, such as the creditworthiness of a credit card applicant given demographic, income, banking history and other such information. 

This made me recall the discussions of (educational) test validity from when I was in that world. At the end of the day, we really don't care about performance on the particular assessment tasks per se ("Hey, Tommy got Item 6 correct!"), but rather the inferences that we are able to make based on performance across all of the assessment tasks in the test battery. And we don't really care about predicting performance on the test battery, but rather the inferences that we can make about real-world performance in untested domains. 

In the case of language proficiency, for example, we may use a thirty minute oral proficiency interview with a very limited number of tasks to assess how well the examinee might perform in a virtually infinite number "real world" language interactions post assessment. Are they ready (linguistically speaking) to lead the students on a study abroad program? To staff the front desk at an international hotel? To work as a foreign area officer?  In other words, the tasks on the test do not constitute the sum total of the domain of potential to which you want to make the inference. 

Thinking about learning analytics, we have the same challenge. Does it really do us any good to predict student performance in a course if that requires us to never change the course assignments because those were the items used to train the predictive model? What we need is a model of student performance that treats assignments as samples from a larger pool of potential assignments. We're not there yet. 

Other parts of the discussion made me think of the distinction between norm referenced and criterion referenced decisions. Much of AI fairness looks at whether or not group level rates are equitable given the respective rates in the population. Are the false negative rates proportional? That the error rates are equitable at the group level (in a norm referenced kind of way) is little consolation if e.g., you are the one falsely denied a raise. 

(If this post seems a little jumbled, it is because I was trying to reconstruct my thoughts based on a couple of phrases that were jotted down here months ago with a "make a post out of this" reminder to myself.....)


Saturday, June 5, 2021

Don't Forget the Cone

In keeping with the ice-cream metaphor, this is yet another follow-on from a post a few days ago that talked about creating logic and a proof-of-concept script that would check for LMS course completion (to identify students eligible for a free scoop of ice-cream). 

I had created a script to 1) get the most recent roster for the target course (as students could self-enroll), 2) check that roster against a list of previously identified finishers and filter them out, and 3) check the remaining students in the roster to get their completion status. As the script runs, it saves information to three csv files: the current roster for the course (overwritten each time the script is run), a running list of students who had finished the course (appended to each time the script is run), and a "recent completers" list of those students who had finished the course since the last time the script was run (created with a timestamp each time the script is run, but empty if there are no new "completers"). 

Although my script is not being used for the official project (it was only intended to illustrate how the logic might work), I've been running it a couple times a day to see how it performs now that the course is live. 

The first time I ran it, as expected, I noticed a few places where my script was not quite working correctly. Because I only had access to finished courses when writing it, the number of completions never changed no matter how many times it ran. Once I pointed it to the live class, I noticed that it was appending the complete list of "completers" each time rather than just the "delta" between the first and last time it was run. A few code tweaks here and there seemed to get things working as intended.

The next day, I ran the script again. It caught the updated class roster, correctly identified previously completed students, and saved everything where it should be. (Because the class is targeting incoming students, the roster expands rather quickly as they self-register.) I ran the script again a few hours later and it worked perfectly again. 

I was pretty pleased with myself. 

The next day, I ran the script first thing in the morning, and again it worked just as expected. By this point, I was becoming fairly convinced that the only potential glitch remaining would be if the number of students got too large there might be a bottleneck when checking completion status, as that is a separate API call for each student. I added a simple "end time - start time" calculation to keep track of how long things were taking. I ran the script again a couple of times throughout the day. So far, no problems.

Now I was really pleased with myself. 

The next day, I again ran the script first thing in the morning, and again it worked flawlessly. The overall time that the script was taking was slowly increasing as more and more students self-enrolled, but the rate was much less than I expected because I was filtering out those students who were already finished, so the overall number to check was still quite manageable. 

And then it happened.  

I ran the script again a little later in the day. I had a couple of print statements here and there so I could get a sense of where things were in terms of execution, and one that I didn't expect to see popped up: "No existing completions found."  Huh? That should only happen the first time I run the program....

One of the first things that the program does it to check for the "completed students" file so it can use it to filter out those students whose completion status has already been verified. Because, by definition, there will be no completed students the first time the program is run, I wrapped the piece of code that reads the file in a try-except block because it will throw an error if it tries to read a non-existent file. The "No existing completions found" message is from the error-handling part, which prints out that message and then creates an empty "completed students" list. I got that message the very first time I ran the script for the "live" course, but that was to be expected and I hadn't seen it since....

I looked at the directory where the output files were stored. Perhaps I had inadvertently deleted the file? Nope, everything seemed to be there. In fact, because my code was written to handle the exception (*any* exception), produce the message, and continue on, and because the completed student file appends results, I now had duplicates of "completers" in the saved file.

I was beginning to feel a little less smug (and quite grateful that my script wasn't the linchpin in the actual project -- see my other ice-cream post). 

So, what had happened? After a bit of Googling and head-scratching, it appears that the issue was one of file encoding. My script was failing to read the file because the Pandas read_csv default is utf-8. However, one of the records must have included a special characters (probably in a student name) that caused an error reading the file, throwing an exception. Explicitly setting the encoding to ISO-8859-1 in the read_csv statement removed the error. 

There are actually two morals to this story. The first is that the difference between a fragile script and a bullet-proof script may not be apparent until an unanticipated edge-case appears. Not being a software developer, it never occurred to me to think about things like file encoding. Just because a script can run for a few days without issue does not mean that it is production ready (as we have just seen). 

The second moral is that I should have been more specific in my error handling. When writing the script, it threw an exception when it couldn't find the completed students file. But rather than handling that *specific* exception, I wrote the script to handle *any* exception in the same way.  This allowed a completely different error to be treated the same as the error that I had anticipated, with obviously unfortunate consequences.

Friday, June 4, 2021

Another Scoop of Ice-cream

This is a follow-on from the last post where I talked about projects things that involve "data" may also require skills that are not necessarily part of the data analyst/scientist tool box (even though others, and even ourselves, may assume that we have them). This seems to be particularly noticeable with areas that are adjacent to, or even overlapping with, some of our daily activities, specifically around infrastructure and coding.   

I've been writing scripts in R and Python for a number of years, but never trained as a software developer and do not have a background in computer science. For most of what I need to do, this has not seemed to be much of an issue. But, of course, I don't know what I don't know, and that can be dangerous. Like so many other areas of endeavor, you can get pretty far with a surface understanding. (A Pareto principle-like idea, 80% of the problems can be solved with 20% of the knowledge/techniques.)

The unfortunate side effect of this, however, is that there are times when the techniques that work fine for developing a small, local script are completely inappropriate for other situations. A fairly trivial example is debugging an issue through the use of "print" statements or just inspecting program output through an IDE like RStudio. This is fine if you are sitting at the keyboard and able to watch the program as it runs, but completely useless if your program is running on unattended on a server and triggered by a scheduler. Unless you have become familiar with logging and error handling, you are flying blind. 

In the same vein, rather "inefficient" (from a computer science point of view) programming techniques may go virtually unnoticed when working with a relatively small data set locally. That your for-loop takes .2 seconds to iterate through the 100 records in the single file that you are working with locally may not even be noticeable. However, if you use that same technique to iterate over the records in 19,000 files you are now contending with over an hour of processing time. This can become a real issue if you are paying a per minute computing charge in a cloud environment. 

The other unfortunate side effect is that our estimates of effort and how close we are to "ready" can become very biased. Once we have our local process working, we get the false sense that we have conquered the hard part (and we probably have, in terms of our portion of the work). But because we are only familiar with our own working context, we might greatly underestimate how close to "production ready" our locally-produced code or data process may actually be. It is like looking at the tip of the iceberg and ignoring everything under the water.  Moving from a desktop to the enterprise may not be a matter of "just" automating or "just" scaling up what we have working locally -- it may be much more complicated and involve all sorts of issues, contingencies, and edge cases that we never even contemplated. 


Thursday, June 3, 2021

The Ice-cream Problem

As one of several people responsible for data-related requests about our enterprise Learning Management System (LMS), I was recently involved in several meetings relating to a seemingly simple proposition -- incoming students to the university would self-register for a course in the LMS (using their newly acquired university credentials), and upon successful completion of all of the course modules, they would be eligible for a free scoop of ice-cream at a shop in the student union on campus.

At first blush, it is not surprising that this would be seen as essentially a "data" issue. Our team regularly pulls data from the LMS to investigate trends in LMS usage (number of published courses, assignments per course, etc.), so one could imagine that the core issue to solve is how to query the data to identify the number of completed students for that particular course. And, to be sure, the ability to retrieve that course completion data from the LMS is indeed a prerequisite for the "complete the course, get some ice-cream" idea. 

However, the ability to retrieve the data is only part of the challenge. The data must be retrieved in a timely fashion. Our normal data process is very much retroactive, e.g., "What did LMS activity look like last semester compared to the semester before?". As such, the LMS information in our reporting database lags the LMS system by at least a couple of days. It defeats the purpose of the ice-cream incentive if a student who completed the course has to wait several weeks before that completion is verified in order to get their free ice-cream.

Luckily, the LMS also includes an API, and potentially relevant endpoints seemed to exist for the data that was needed. (The challenge of confirming that the API results did indeed include the data we need without having a sample of the course to use as a test case is an issue for another post.) We do occasionally use the API to get targeted data that is not readily available from our database.  

Another challenge is where the data needed to flow and how frequently. The "free" ice-cream is actually provided in the form of a credit in the amount of one scoop of ice-cream associated with the student's university ID card which can be swiped to be redeemed. This means that the data need to end up in a place where that card swipe system can take over the process. In other words, this is not only a "data" issue, but also an "integration" issue.

Lots of the pain points in integration are hidden if you never have to deal with them. For most of our daily data work, we explicitly control the scripts that we run and have access to the locations where the data are stored, with most of the authentication processes happening seamlessly behind-the-scenes. (And we are there to enter our credentials if prompted.) We don't think twice about manually running a script that points to a local folder or shared drive. But we are logged into the system what happens. To automate the ice-cream data pipeline the script has to hit the API (with the appropriate LMS credentials to do so) and save the data in the appropriate place (with the appropriate file system permissions to do so) via an automatic scheduler that has been provisioned (by someone with the appropriate permissions to do so), and then populate the swipe system (with appropriate permissions to do so), all without human intervention.

As for my part, I thought through the logic that one would need to implement in order to query the API for the current student roster (as student could self-enroll, the roster is always increasing), check the current roster against a list of completed students and filter them out, and then hit the API again to check for completion status of those remaining. I created a proof-of-concept script which implemented the basic logic for the LMS data side of the problem and shared that with others on the team (who then engaged their developers). I'm not sure what, if any, of my proof-of-concept script made it into the final version, but I don't feel slighted. For anything involving non-trivial integration, it makes much more sense to give the appropriate LMS credentials to a software developer who can put all the pieces together rather than trying to make a "data person" into an integration specialist.