It’s been a while..

Well, I had promised myself that I would try to blog every couple of weeks, but life gets in the way, and here’s the usual “sorry I haven’t updated in a while” post.

To be fair, I have a good amount of excuses; I’ve been keeping quite busy with Shiny app development. So far I’ve developed four complete applications. Here’s a list!

  1. World Explor-R: This is my first Shiny app ever and it was quite a massive undertaking. I did not know what I was getting myself into and I dove really, really deep. I collected a ton of info on all the countries from the CIA World Factbook and this app visualizes that data in several different ways. Here’s the link!  https://vazgenzakaryan.shinyapps.io/world_explor_r/
  2. Song Sentiment Analyzer: This was a pretty interesting experience. This app fetches up to five songs’ lyrics from the Internet and analyzes them for emotions, displaying them on a radar chart. Very interesting to build and I ran into some problems that I solved on my own – learned quite a bit from building this!  https://vazgenzakaryan.shinyapps.io/song_sentiment/
  3. Text Sentiment Analyzer: A poet friend of mine, Taylor Collier, saw the Song Sentiment Analyzer app and asked if I could modify it to take text and analyze its sentiments so he could play around with his poems. I obliged, simplifying the code from Song Sentiment Analyzer to turn it into this app. It proved very handy for the app that’s to follow..
    https://vazgenzakaryan.shinyapps.io/poem_analyzer/
  4. State of the Union Sentiment Analyzer: I took every State of the Union address transcript and used the code to Text Sentiment Analyzer to extract the sentiment from those addresses. This app explores all the sentiments in all the State of the Union addresses and allows you to compare presidents or political parties. Again, ran into a few problems that I haven’t seen before, and solving them proved to be a valuable learning experience.
    https://vazgenzakaryan.shinyapps.io/SotU_sentiments/

Aside from these, I also participated in some Kaggle competitions. I did reasonably well, but I found that my time wasn’t being utilized properly with those. In most real data science jobs, you won’t need to spend days trying to get 0.5% better performance out of a model; instead you’ll spend more time cleaning data, which Kaggle doesn’t allow you to practice because their data is already (mostly) clean.  However, along my Kaggle journey I found and read a fantastic book on Machine Learning, Applied Predictive Modeling by Max Kuhn. I highly recommend it if you’re interested in machine learning with R.

So that’s what I’ve been doing the past few months! I have a couple more Shiny projects in mind that I will be working on alongside job applications, so maybe I’ll update this soon and let you know how it goes!

Vazgen Zakaryan

Criticism vs Self-Criticism

I want to brag a little bit and tell a story about one of my favorite on the spot extra credit assignments I’ve ever given. My business calculus class had just taken their second exam and they had done quite abysmal. I believe the class average was in the early to mid 50s. So, as I learned to do in the past, the first thing I decided to do was give them another chance. After grading the exam, I composed an email to the class outlining the extra credit assignment. In a nutshell, they would get points back if they wrote an essay about how they’ve been studying for my course and what they should do to improve their performance in the future. The second part of the extra credit assignment involved them having to answer which was a better curve – getting half of the points they missed back or taking half of the grade they made and adding 50 points to that? Naturally, the two options are the exact same but why not tease your students a little bit?

Well, in that class of 127 students I got something like 90+ responses – a lot of people wanted those points back. There were a lot of “I will go to more office hours” and “I will ask for more help”. But of course, college kids will be college kids. I think only one more person started coming to office hours regularly.

They had their next exam a month later, and while they did slightly better, it was still pretty abysmal. I believe the class average improved by only about five points. This time, I gave them another extra credit assignment but for only ten points. They had to read their original essay from the first exam,  and write an update to it – did they follow their own advice? Why or why not?  If they did and they did better, then more props to them, otherwise who’s to blame?

Huge classes are notoriously difficult to control. One voice of dissent can easily turn all 127 students against you. By making each student criticize themselves for not following their own advice, I believe I avoided a lot of conflict that could lead to terrible wastes of time on both my and my students’ parts. Not to mention that those were their own words, you know? Criticism from someone else often leads to resentment and conflict. Criticism from your own self leads to reflection.

Most students did end up doing quite well on the final, too 🙂

Vazgen Zakaryan

Why learn math?

As the title says, this post will attempt to answer the question “why learn math?” I explained this as a lecture on the first day of every semester to most of my classes. As I have to explain this to pretty much every non-math person I meet, I figure it would be easier to write a blog about it.

Why learn math? If you are a math teacher, you’ve heard this a billion times. I’ll never use math in my career. Why should I bother learning it? Why do THEY make me learn it? If you’re a student, you’ve probably asked this a few times in your life. Well, it’s time you find out the secret. The truth is, no one really cares if you leave the class knowing how to draw a pretty parabola or how to factor a cubic expression. Here’s the real reason you learn math.

Imagine you’re driving on a highway on a hot Texas afternoon and your tire blows out. What should you do? Well, it all depends, right? If you’re skilled with your hands, changing a tire may be a no-brainer. If you have AAA membership, maybe you could put it to good use and get your car towed to the nearest auto shop. Maybe you could call a friend or family member to come rescue you. Maybe you’re skilled with your hands, but it’s too hot outside, or that particular highway is too busy and dangerous. What you’re really doing here is analyzing every possible solution to come up with an optimal one to solve your problem. This is the real life skill that everyone needs to have. Problems like this arise all the time, and as intelligent beings we are required to be able to come up with a good solution. But how do we learn this skill?

While I am all for throwing a bunch of college kids onto an uninhabited island and letting them experience problem solving first hand, in this day and age this might lead to some lawsuits. Therefore, we are forced to learn this “problem solving” skill in the realm of mathematics. Mathematics has its own laws, like the distributive law. It has its own rules, like DO NOT DIVIDE BY ZERO. The universe of math comes with its own regulations and natural occurrences, which enables us to use the knowledge of all these rules to practice problem solving. Just like you have to figure out what to do about your tire given a certain set of conditions – weather, AAA membership, etc – you have to figure out how to solve that quadratic equation. If it’s not too complicated and the coefficient of x is even, you could try completing by square. If it looks like something you’ve had experience factoring, you could try – you guessed it – factoring. Or you could just use the quadratic equation, assuming you have it memorized (yet another condition you need to take into account!)

Mathematics enables us to practice problem solving and logical thinking in the relative safety of our own pen and paper (try to avoid paper cuts though). It gets our gears moving without the risk of heatstroke while changing a tire on a dangerous highway. This is why we learn mathematics.

Vazgen Zakaryan

 

 

You learn more by doing

I’ve been a proponent of homework my entire teaching career. Actually sitting down and solving a problem on your own will lead you to discover intricacies in methods that a teacher cannot always fully convey. However, since I personally haven’t done homework in a while, I completely forgot about this neat little factoid. That is, until I decided to write a function in R.

Recently, I did a survey about board games on Reddit. I used Google Forms, which has different types of questions. One type of questions you can use is the “check marks” questions, where you check every option that applies out of a list. Well, Google Forms generates a CSV file for your results. In that file, a “check mark” question is treated as a single column that has all the options a person selected separated by commas, like such:

Option A, Option B, Option C
Option A, Option C
Option A, Option B, Option D, Option E
etc

In order to analyze these results, I would need each option in its own column, with the entries being 1 for that option being selected or 0 for that option not being selected. So the column above would turn into:

Option A         Option B             Option C             Option D                Option E
1                       1                           1                           0                              0
1                       0                           1                           0                              0
1                       1                           0                           1                              1

I had been thinking about how to accomplish this for a little while. From the courses on DataCamp, I knew there was a way to turn a column of single entries into several columns with zeroes and ones, and there was also a way to separate a column into multiple columns on comma separated entries. Sure, if I messed with those two options enough, I could probably figure it out after a little while. However, I decided to give it a shot writing my own function for my specific purpose. I thought about it for about a day and followed some classic advice from some very good programmers, and wrote a working prototype in about 30 minutes. It didn’t have a whole lot of options and it used nested loops (a pretty deadly sin in R) but it did what it was set out to do.

The next day, I took a dive into the ~apply family of functions in R and managed to take out both for loops in my function. I also added some extra functionality like giving the user the option to select a separator other than a comma, and whether to delete the original column.

Lately I’ve been in the process of brainstorming a bit more functionality. I am considering letting the user choose where to insert the new columns (in place of the original or at the very end of the data frame) among a couple of other options. The function could also use some improved readability and commenting. I’ll probably use it to figure out GitHub later and make a separate post about that 🙂

Writing this function taught me a few lessons that reading someone else’s code, or listening to a lecture would just never drive the point home. For example, I know very clearly understand the difference between using single or double bracket sub-setting on data frames. It’s just not something I would remember if someone told me, unless I got to experience it on my own through a simple homework assignment.

So it seems like the process is fairly simple! Come up with a process that works, no matter how inefficient, then improve efficiency and add options. I guess that applies to any solution to a problem though, doesn’t it?

Vazgen Zakaryan

“If you have to give the same advice more than three times, start a blog.”

I’ve read the quote above somewhere a couple of weeks ago, but it escapes me where. Anyway, I gave it a lot of thought because as an instructor I’ve given a lot of the same advice to a lot of my students so I figured why not, let’s write a blog.

This particular blog will focus on math education so if you hate math, feel free to stop reading 🙂  In particular, it will focus on math prerequisites.

When I taught slightly higher level mathematics courses (like Calculus II and Differential Equations), I had a decent chunk of students who were just not mathematically prepared to be in those courses and yet they somehow made it in. So after a bit of analysis, I came up with a nice hierarchy of what you should know throughout your mathematical education.

Note: This goes through Differential Equations (typically one of the last courses required for a math minor) but a similar argument may be made for higher courses as well.

Have you ever played any of those online flash games where you complete stages and level up between them? And when you level up a whooole bunch and attempt the first stage again, it’s a piece of cake? Well, math works like that too. As you take math courses, you “level up” your mathematical knowledge, and earlier topics (should) become a piece of cake. In this case, the formula is very simple: You should be very familiar with the topics of a course two “levels” below the one you are currently attending. A typical math course progression in college looks like this:
Algebra
Trigonometry
Calculus I (Differential Calculus)
Calculus II (Integral Calculus)
Calculus III (Multivariate Calculus)
Differential Equations

[Note: I did not include precalculus, as, in my experience, it’s simply college algebra with a few chapters of trigonometry thrown in. Seriously, when I taught precalculus and college algebra at the same time, the author for both books was the same. She simply took the college algebra book she wrote, didn’t even change examples, and threw in four chapters of trig right in the middle of it and called it Precalculus. Great books though.]

So if you’re attempting, say, Calculus II, you should be great at Trigonometry. Every one of these courses uses some content of the course immediately preceding it, but it really requires mastery of the course two levels before it – Calculus I is very algebra heavy especially in things like optimization problems; the most difficult problems of Calculus II usually involve some sort of trigonometry; Calculus III is just Calculus I on steroids; Differential Equations involves a lot of integrating so you have to be familiar with techniques from Calculus II. If you can keep up your mathematical mastery to where it’s two levels below where you currently are on your mathematical journey, you will be successful.

Vazgen Zakaryan