In second language acquisition research, there is a concept known as interference. The core idea is fairly simple and refers to the influence that one known language has on the use of another for a person who speaks multiple languages. Having a "foreign accent" may be an obvious example of interference on pronunciation, but there can also be syntactic interference (influence on grammar) lexical interference (influence on words).
This same phenomenon can be seen in programming languages. Subtle variations in function names or usage can be sources of interference, such as R's head(df)versus Pandas df.head() or Python's len()versus R's length(). There are also more global issues such as how one expresses their intentions over several lines of code. Just as it is possible to make yourself understood in another language even if you don't phrase things the way a native speaker would, one can write working code which is regarded as "not Pythonic" by an expert programmer.
Perhaps this explains why my code sometimes feels like gibberish.
Saturday, February 10, 2018
Friday, February 9, 2018
"You're out of order!"
If you've ever seen the movie ...And Justice for All, you will do doubt vividly recall Al Pacino delivering that famous line during the film's climatic courtroom scene. This post is about a different kind of order -- the order of sorted data.
I was almost tripped up by order recently while munging some survey data for analysis. The survey had been taken by representatives of various academic and service units on the university campus and this was the second year it had been administered. I was attempting to match the current year's respondents to previous respondents to investigate change from one year to the next. This was not the straight-forward process that I assumed it would be, as some of the drop-down options for the "demographic" (in terms of where the unit is in the university hierarchy) questions had been altered between the two years. In addition, folks sometimes filled out a single survey to cover multiple units, so one had to look at a comment box to see if they had made any annotation to that effect (e.g., "this survey also covers unit X, Y, and Z"). Because there was no guarantee that the same units had responded to the survey each year, this also meant that one had to recognize that units with similar names across the two surveys may not refer to the same entity (e.g., Chemical and Molecular Bioengineering, Biochemistry, and Bioengineering are not necessarily the same thing).
I spent a bit of time trying to come up with a principled way to do this in R, but decided that it might be more efficient to just do things "by hand" as there were only about 100 survey responses. The data were in .csv format, so I grabbed the relevant columns from each survey, pasted them into separate workbooks in Excel, and compared them side by side. Each time I found what I determined was a "match," I would grab the unique id for that respondent in the current survey and paste it into a new column in the other sheet. Once I had matched all that I could, I pasted that new column into the survey response data from the previous year. That column was the link between the current year and the previous year.
At a couple of points along the way, I sorted the Excel sheets (sometimes on multiple columns) to make this visual comparison easier. For better or for worse, Excel does what you tell it to (usually). If you sort on multiple columns, and then later on a single column, Excel will maintain the current order for everything other than the column you are sorting on. Though I re-sorted on what I thought was the "main" column before pasting the final results into the original spreadsheet, I didn't double-check the final order. Had I done so, I would have realized that things were still not quite back in the "original" order. It was only at a later stage in the analysis that I realized my mistake. Ouch.
The moral of the story is to always keep track of any data permutations you are performing, particularly when using tools that do not naturally leave a digital trail. (This is why I prefer to work in R or Python and make modifications to data objects rather than the original data source -- you can always modify the script and rerun the process staring from the "original"data.) Had I simply added an "original position" column to the Excel sheet before doing any sorting, I could have easily sorted on that to get back to the starting state.
I was almost tripped up by order recently while munging some survey data for analysis. The survey had been taken by representatives of various academic and service units on the university campus and this was the second year it had been administered. I was attempting to match the current year's respondents to previous respondents to investigate change from one year to the next. This was not the straight-forward process that I assumed it would be, as some of the drop-down options for the "demographic" (in terms of where the unit is in the university hierarchy) questions had been altered between the two years. In addition, folks sometimes filled out a single survey to cover multiple units, so one had to look at a comment box to see if they had made any annotation to that effect (e.g., "this survey also covers unit X, Y, and Z"). Because there was no guarantee that the same units had responded to the survey each year, this also meant that one had to recognize that units with similar names across the two surveys may not refer to the same entity (e.g., Chemical and Molecular Bioengineering, Biochemistry, and Bioengineering are not necessarily the same thing).
I spent a bit of time trying to come up with a principled way to do this in R, but decided that it might be more efficient to just do things "by hand" as there were only about 100 survey responses. The data were in .csv format, so I grabbed the relevant columns from each survey, pasted them into separate workbooks in Excel, and compared them side by side. Each time I found what I determined was a "match," I would grab the unique id for that respondent in the current survey and paste it into a new column in the other sheet. Once I had matched all that I could, I pasted that new column into the survey response data from the previous year. That column was the link between the current year and the previous year.
At a couple of points along the way, I sorted the Excel sheets (sometimes on multiple columns) to make this visual comparison easier. For better or for worse, Excel does what you tell it to (usually). If you sort on multiple columns, and then later on a single column, Excel will maintain the current order for everything other than the column you are sorting on. Though I re-sorted on what I thought was the "main" column before pasting the final results into the original spreadsheet, I didn't double-check the final order. Had I done so, I would have realized that things were still not quite back in the "original" order. It was only at a later stage in the analysis that I realized my mistake. Ouch.
The moral of the story is to always keep track of any data permutations you are performing, particularly when using tools that do not naturally leave a digital trail. (This is why I prefer to work in R or Python and make modifications to data objects rather than the original data source -- you can always modify the script and rerun the process staring from the "original"data.) Had I simply added an "original position" column to the Excel sheet before doing any sorting, I could have easily sorted on that to get back to the starting state.
Thursday, February 8, 2018
2 + 2 = 5
I'm not very good at math. That's a bit of an ironic statement given that most of the jobs I've had since graduate school have been fairly quantitative. And to be clear, I'm not saying that my calculus has gotten rusty since I took an AP class in high school or that I don't remember much about trigonometry. I never took calculus, AP or otherwise, nor pre-calc, nor trig. And it isn't that I just haven't taken advanced math classes -- my "basic" math skills are not as strong as they should be. What happened?
My recollection is as follows. Back when I was in 6th grade, I took a pair of tests. One test was to see if I could skip 7th grade math, the other was to see if I could understand abstract concepts (i.e., the letter "x" representing an unknown value in an equation). Passing both tests meant that you would take pre-algebra in 7th grade, algebra in 8th, geometry in 9th, trigonometry in 10th, pre-calculus in 11th, and AP calculus senior year. (This was a a couple of decades ago -- I'm sure the math curriculum has changed several times since then.) Although I initially passed both tests, it turns out that there was a grading error and I really didn't have sufficient command of "basic" math skills to warrant skipping "regular" math in 7th grade. In other words, I don't have problems with the notion of abstraction, I just have trouble actually "solving for x" in the real world.
Needless to say, I didn't do very well in math in high school. (I think I took algebra twice.) At the time, only two years of math were required, so I never took anything past geometry (though I did take a single "consumer math" course as a college undergrad to fulfill a graduation requirement there). As I had little interest in pursuing any career that required mathematical knowledge, I wasn't too worried about my lack of mathematical background. After college, I got a job in Japan teaching English as a foreign language didn't give it another thought. I knew that I wasn't good in math, but (I thought) it didn't matter.
I became acutely aware of my math deficiencies in graduate school, when my interest in teaching English as a foreign language morphed into an interest in second language acquisition research and language testing in particular. In addition to readjusting to life as a student almost a decade after graduating college, it was painfully obvious that I was missing some of the foundational building blocks for the stats classes I was taking and the research literature I was reading. Although I've managed to get by (research and assessment are never JUST about the numbers), I still feel like an English Literature major who only read the Cliff's Notes version of the Western cannon.
I guess I'm living proof that you can have a fairly data heavy career even without a solid background in math. That said, I really don't recommend it. Building up your skills early if possible is probably a much better approach.
My recollection is as follows. Back when I was in 6th grade, I took a pair of tests. One test was to see if I could skip 7th grade math, the other was to see if I could understand abstract concepts (i.e., the letter "x" representing an unknown value in an equation). Passing both tests meant that you would take pre-algebra in 7th grade, algebra in 8th, geometry in 9th, trigonometry in 10th, pre-calculus in 11th, and AP calculus senior year. (This was a a couple of decades ago -- I'm sure the math curriculum has changed several times since then.) Although I initially passed both tests, it turns out that there was a grading error and I really didn't have sufficient command of "basic" math skills to warrant skipping "regular" math in 7th grade. In other words, I don't have problems with the notion of abstraction, I just have trouble actually "solving for x" in the real world.
Needless to say, I didn't do very well in math in high school. (I think I took algebra twice.) At the time, only two years of math were required, so I never took anything past geometry (though I did take a single "consumer math" course as a college undergrad to fulfill a graduation requirement there). As I had little interest in pursuing any career that required mathematical knowledge, I wasn't too worried about my lack of mathematical background. After college, I got a job in Japan teaching English as a foreign language didn't give it another thought. I knew that I wasn't good in math, but (I thought) it didn't matter.
I became acutely aware of my math deficiencies in graduate school, when my interest in teaching English as a foreign language morphed into an interest in second language acquisition research and language testing in particular. In addition to readjusting to life as a student almost a decade after graduating college, it was painfully obvious that I was missing some of the foundational building blocks for the stats classes I was taking and the research literature I was reading. Although I've managed to get by (research and assessment are never JUST about the numbers), I still feel like an English Literature major who only read the Cliff's Notes version of the Western cannon.
I guess I'm living proof that you can have a fairly data heavy career even without a solid background in math. That said, I really don't recommend it. Building up your skills early if possible is probably a much better approach.
Wednesday, February 7, 2018
You are what you do
When I was in my teens, I used to attend a camp in upstate New York called High Peaks, where we would spend most of our time climbing and canoeing in the beautiful Adirondack Mountain Reserve. As campers, we were expected to pull our weight when it came to carrying food, gathering firewood, etc. However, one thing that campers were not allowed to do (at least during my time there) was to fill or light the kerosene lantern that we used for light in the evenings.
For my last year at High Peaks, I returned as a counselor. Suddenly, my job included lighting the lantern. Although lighting the lantern is trivially easy if you have seen others do it in the past (and even if you haven't), I found it interesting that I had never been required to demonstrate this ability prior to being hired, particularly given that I had been forbidden from touching the lantern as a camper. My lantern-lighting knowledge did not suddenly change by virtue of being hired as a counselor.
In other words, for better or worse, you are identified by your title, and there are general expectations as to the types of skills and knowledge implied by that title, even if you were not required to explicitly demonstrate them prior to being hired. (No hiring process can be comprehensive.)
I've noticed this feeling since then, particularly when starting a new position (which, in my case, has always involved moving to a different organization). My experience has never been "same job, different organization." Every time I've changed jobs, I've always been required to do things that I've never really done before (though I certainly have acquired general skills that are transferable to different contexts). I always feel that there is much more to learn to "live up to" the job title.
At the same time, job titles are usually a poor measure of ability. Whether or not it is part of your degree or job title, if you create websites in your spare time, then you are, at some level, a web developer; if you play an instrument, you are a musician; if you analyze data, you are a data analyst; if you do watercolor, you are an artist. This doesn't necessarily mean that you are a great web developer (or musician, or data analyst, or artist), but that is a different issue.
For my last year at High Peaks, I returned as a counselor. Suddenly, my job included lighting the lantern. Although lighting the lantern is trivially easy if you have seen others do it in the past (and even if you haven't), I found it interesting that I had never been required to demonstrate this ability prior to being hired, particularly given that I had been forbidden from touching the lantern as a camper. My lantern-lighting knowledge did not suddenly change by virtue of being hired as a counselor.
In other words, for better or worse, you are identified by your title, and there are general expectations as to the types of skills and knowledge implied by that title, even if you were not required to explicitly demonstrate them prior to being hired. (No hiring process can be comprehensive.)
At the same time, job titles are usually a poor measure of ability. Whether or not it is part of your degree or job title, if you create websites in your spare time, then you are, at some level, a web developer; if you play an instrument, you are a musician; if you analyze data, you are a data analyst; if you do watercolor, you are an artist. This doesn't necessarily mean that you are a great web developer (or musician, or data analyst, or artist), but that is a different issue.
Tuesday, February 6, 2018
Luck
I recently read a book called Success and luck: good fortune and the myth of meritocracy by Robert H. Frank. The basic thesis is that those who are successful in getting a job, being accepted to a university, etc., are virtually always (perhaps always) luckier than those who failed to do so. However, due to cognitive bias, people tend to underestimate the role of luck in their success and attribute all of their favorable outcomes to their superior intelligence, work ethic, foresight, and the like. Enjoying the fruits of one's hard work is not necessarily a bad thing, but the troublesome corollary to this cognitive bias is that such people tend to attribute others' lack of success to a deficiency -- not smart enough, didn't work hard enough, etc. (I heard the term "weaponized self-help" recently that is along the same lines -- people don't fail because of racism, sexism, ageism, etc., they just didn't "believe" in themselves enough.) This can cause us to treat others as "inherently" lazy, unmotivated, or intellectually limited, and provides a convenient excuse to avoid uncomfortable questions of privilege (e.g., white, male) as factors in the increasingly unequal distribution of wealth in the society.
I don't want to get too far afield in the social/political aspects of the author's thesis. One thing that was interesting in the book is that the author mentioned results of a statistical simulation as part of his argument. The basic idea is to create a set of simulated job hunters, college applicants, etc. each with a random value for "strength" (or intelligence, inherent capability, or whatever else you want to call it) and a random value for "luck". These values are drawn from a uniform distribution between 1 and 100, so any value in that range is equally probable. Next, a composite variable called "performance" is created, which is the weighted sum of the strength and luck variables. For example, if you believe that luck plays a very small role in performance, you could set performance = (strength * .95) + (luck * .05).
I decided to implement this with a simple R script and apply it to some data. A quick web search shows that there were 39,494 applicants to Harvard for the class of 2021, and that 2,056 applicants were accepted. I created a "strength" vector and a "luck" vector of 39,494 draws each (the applicants) from a uniform distribution between 1 and 100, and then a "performance" vector of the same length (representing the overall "score" of the application package), with strength accounting for 98% and performance 2% of the score. These were all combined into a dataframe. I then ordered the dataframe by performance (high to low) and split the top 2056 records (the successful applicants) from the others (the unsuccessful applicants). Using R's summary() command, I captured the median "luck" score for each group, along with the minimum strength score in the successful group and the maximum strength score in the unsuccessful group. This process was repeated 1000 times.
My simulation showed that the median "luck" value for the "chosen" group was 55.33, while the median for the "not chosen" group was only 50.24. (A t-test confirms that these are statistically significantly different.) This suggests that, indeed, the chosen group were "luckier."
The average minimum "strength" score for the chosen group was 93.92, while the average *maximum* score for the "not chosen" group was 96.19. In other words, the chosen group were not "the best of the best," but rather "the luckiest of the best."
It is important to note that the takeaway from this is NOT that personal effort doesn't matter or that it is ONLY a matter of luck that people are successful. Obviously, the harder one works the more likely they are to be in a position to take advantage of a "lucky" break. The important point is that is a mistake to equate lack of success with lack of personal effort or ability. As the old saying goes "better to be lucky than good."
I don't want to get too far afield in the social/political aspects of the author's thesis. One thing that was interesting in the book is that the author mentioned results of a statistical simulation as part of his argument. The basic idea is to create a set of simulated job hunters, college applicants, etc. each with a random value for "strength" (or intelligence, inherent capability, or whatever else you want to call it) and a random value for "luck". These values are drawn from a uniform distribution between 1 and 100, so any value in that range is equally probable. Next, a composite variable called "performance" is created, which is the weighted sum of the strength and luck variables. For example, if you believe that luck plays a very small role in performance, you could set performance = (strength * .95) + (luck * .05).
I decided to implement this with a simple R script and apply it to some data. A quick web search shows that there were 39,494 applicants to Harvard for the class of 2021, and that 2,056 applicants were accepted. I created a "strength" vector and a "luck" vector of 39,494 draws each (the applicants) from a uniform distribution between 1 and 100, and then a "performance" vector of the same length (representing the overall "score" of the application package), with strength accounting for 98% and performance 2% of the score. These were all combined into a dataframe. I then ordered the dataframe by performance (high to low) and split the top 2056 records (the successful applicants) from the others (the unsuccessful applicants). Using R's summary() command, I captured the median "luck" score for each group, along with the minimum strength score in the successful group and the maximum strength score in the unsuccessful group. This process was repeated 1000 times.
My simulation showed that the median "luck" value for the "chosen" group was 55.33, while the median for the "not chosen" group was only 50.24. (A t-test confirms that these are statistically significantly different.) This suggests that, indeed, the chosen group were "luckier."
The average minimum "strength" score for the chosen group was 93.92, while the average *maximum* score for the "not chosen" group was 96.19. In other words, the chosen group were not "the best of the best," but rather "the luckiest of the best."
It is important to note that the takeaway from this is NOT that personal effort doesn't matter or that it is ONLY a matter of luck that people are successful. Obviously, the harder one works the more likely they are to be in a position to take advantage of a "lucky" break. The important point is that is a mistake to equate lack of success with lack of personal effort or ability. As the old saying goes "better to be lucky than good."
Friday, February 2, 2018
Thank You for Sharing
I recall reading something many years ago that talked about the distinction between material things and ideas. If you have a hamburger and decide to share it with someone, you have less than you would have otherwise. In fact, because the hamburger is finite, there is a limit to how many people you can share it with while still retaining some benefit for yourself. With ideas, on the other hand, you get to keep the "whole" idea even if you share it with others. (Determining appropriate attribution for an idea is a whole different set of issues.) One can consider computer code the expression of an idea which, given digital distribution, can be shared with others without reducing the benefit to the creator.
As an almost daily user of either R or Python, I am in awe of the extensive ecosystem around these languages. Although I'm not a free (as in libre) software purist (I've tried at times, but forces conspire to push me back to "what everyone else is using"), I greatly appreciate the efforts of people who contribute their ideas to these projects in the form of code and documentation. Thank you for sharing!
As an almost daily user of either R or Python, I am in awe of the extensive ecosystem around these languages. Although I'm not a free (as in libre) software purist (I've tried at times, but forces conspire to push me back to "what everyone else is using"), I greatly appreciate the efforts of people who contribute their ideas to these projects in the form of code and documentation. Thank you for sharing!
Large-ish data, or "Where should I put this?"
When I was collecting data for research studies while working on my degree in second language acquisition, the "golden number" was 30. If you could somehow get at least 30 language learners to participate in your research experiment, you were good to go. (This reminds me of the old joke: "How many statisticians does it take to change a light bulb?" "At least 30, but a really good one can get away with as few as 25.") As my focus turned more towards language testing, 30 seemed a little small, and the "rule of thumb" for using Rasch measurement was "at least 100." I had somewhere north of 400 test taker responses for my dissertation work, which I was happy with. When I was working as Assessment Director of a federally-funded language research center, we could normally get thousands of test takers to pilot a commonly taught language like Spanish, with considerably fewer for less commonly taught languages like Hindi or Urdu. For all that time, I never had an issue processing data on whatever desktop (or, increasingly, laptop) computer I happened to be using. (I seem to recall a brief period of time circa 2007 when in Excel would sometimes choke on our biggest data sets, but that easily overcome by upgrading to the most recent version.)
Recently, however, I've been working with data from a learning management system (LMS) that serves over 40,000 students and instructors. A "data dump" of information from the system consists of over 80 informational tables which, for reasons I won't go into here, we only have access to as flat files. Although most of the files are only a few hundred megabytes in size, some are several gigabytes, and one is so large that attempting to decompress it (files are downloaded in a compressed format) resulted in an "out of space" error on a 1TB drive. Even for the "smaller" files, manipulating them in R (our languages of choice) through joins and the like can quickly lead to memory issues. This is not "big data" by any means -- a modern computer with a multi-TB hard drive should be able to hold it all -- but it is large enough to be quite unwieldy for someone like me who has never needed to be concerned with memory-efficient processing or having enough storage space. There seems to be a gap between "big data" solutions (I certainly don't need a Hadoop cluster for a couple TBs worth of data) and "standard-issue" office computers.
The moral of this story is that having a "right-sized" data infrastructure in place is important, and just having years of experience in "data analysis" doesn't necessarily make you fluent in working efficiently with "larger-than-memory" data. There's a lot for me to learn.
Recently, however, I've been working with data from a learning management system (LMS) that serves over 40,000 students and instructors. A "data dump" of information from the system consists of over 80 informational tables which, for reasons I won't go into here, we only have access to as flat files. Although most of the files are only a few hundred megabytes in size, some are several gigabytes, and one is so large that attempting to decompress it (files are downloaded in a compressed format) resulted in an "out of space" error on a 1TB drive. Even for the "smaller" files, manipulating them in R (our languages of choice) through joins and the like can quickly lead to memory issues. This is not "big data" by any means -- a modern computer with a multi-TB hard drive should be able to hold it all -- but it is large enough to be quite unwieldy for someone like me who has never needed to be concerned with memory-efficient processing or having enough storage space. There seems to be a gap between "big data" solutions (I certainly don't need a Hadoop cluster for a couple TBs worth of data) and "standard-issue" office computers.
The moral of this story is that having a "right-sized" data infrastructure in place is important, and just having years of experience in "data analysis" doesn't necessarily make you fluent in working efficiently with "larger-than-memory" data. There's a lot for me to learn.
Subscribe to:
Posts (Atom)
