Machine learning and degrees of freedom

For starters, machine learning is not magic. It might appear like magic when you see Google Photos automatically tagging all your family members correctly, down to the day of their birth. It might appear so when Siri or Alexa give a perfect response to your request. And the way AlphaZero plays chess is almost human!

But no, machine learning is not magic. I’d made a detailed argument about that in the second edition of my newsletter (subscribe if you haven’t already!).

One way to think of it is that the output of a machine learning model (which could be anything from “does this picture contain a cat?” to “is the speaker speaking in English?”) is the result of a mathematical formula, whose parameters are unknown at the beginning of the exercise.

As the system gets “trained” (of late I’ve avoided using the word “training” in the context of machine learning, preferring to use “calibration” instead. But anyway…), the hitherto unknown parameters of the formula get adjusted in a manner that the formula output matches the given data. Once the system has “seen” enough data, we have a model, which can then be applied on unknown data (I’m completely simplifying it here).

The genius in machine learning comes in setting up mathematical formulae in a way that given input-output pairs of data can be used to adjust the parameters of the formulae. The genius in deep learning, which has been the rage this decade, for example, comes from a 30-year old mathematical breakthrough called “back propagation”. The reason it took until a few years back for it to become a “thing” has to do with data availability, and compute power (check this terrific piece in the MIT Tech Review about deep learning).

Within machine learning, the degree of complexity of a model can vary significantly. In an ordinary univariate least squares regression, for example, there are only two parameters the system can play with (slope and intercept of the regression line). Even a simple “shallow” neural network, on the other hand, has thousands of parameters.

Because a regression has so few parameters, the kind of patterns that the system can detect is rather limited (whatever you do, the system can only draw a line. Nothing more!). Thus, regression is applied only when you know that the relationship that exists is simple (and linear), or when you are trying to force-fit a linear model.

The upside of simple models such as regression is that because there are so few parameters to be adjusted, you need relatively few data points in order to adjust them to the required degree of accuracy.

As models get more and more complicated, the number of parameters increases, thus increasing the complexity of patterns that can be detected by the system. Close to one extreme, you have systems that see lots of current pictures of you and then identify you in your baby pictures.

Such complicated patterns can be identified because the system parameters have lots of degrees of freedom. The downside, of course, is that because the parameters start off having so much freedom, it takes that much more data to “tie them down”. The reason Google Photos can tag you in your baby pictures is partly down to the quantum of image data that Google has, which does an effective job of tying down the parameters. Google Translate similarly uses large repositories of multi-lingual text in order to “learn languages”.

Like most other things in life, machine learning also involves a tradeoff. It is possible for systems to identify complex patterns, but for that you need to start off with lots of “degrees of freedom”, and then use lots of data to tie down the variables. If your data is small, then you can only afford a small number of parameters, and that limits the complexity of patterns that can be detected.

One way around this, of course, is to use your own human intelligence as a pre-processing step in order to set up parameters in a way that they can be effectively tuned by data. Gopi had a nice post recently on “neat learning versus deep learning“, which is relevant in this context.

Finally, there is the issue of spurious correlations. Because machine learning systems are basically mathematical formulae designed to learn patterns from data, spurious correlations in the input dataset can lead to the system learning random things, which can hamper its predictive power.

Data sets, especially ones that have lots of dimensions, can display correlations that appear at random, but if the input dataset shows enough of these correlations, the system will “learn” them as a pattern, and try to use them in predictions. And the more complicated your model gets, the harder it is to know what it is doing, and thus the harder it is to identify these spurious correlations!

And the thing with having too many “free parameters” (lots of degrees of freedom but without enough data to tie down the parameters) is that these free parameters are especially susceptible to learning the spurious correlations – for they have no other job.

Thinking about it, after all, machine learning systems are not human!

Biases, statistics and luck

Tomorrow Liverpool plays Manchester City in the Premier League. As things stand now I don’t plan to watch this game. This entire season so far, I’ve only watched two games. First, I’d gone to a local pub to watch Liverpool’s visit to Manchester City, back in September. Liverpool got thrashed 5-0.

Then in October, I went to Wembley to watch Tottenham Hotspur play Liverpool. The Spurs won 4-1. These two remain Liverpool’s only defeats of the season.

I might consider myself to be a mostly rational person but I sometimes do fall for the correlation-implies-causation bias, and think that my watching those games had something to do with Liverpool’s losses in them. Never mind that these were away games played against other top sides which attack aggressively. And so I have this irrational “fear” that if I watch tomorrow’s game (even if it’s from a pub), it might lead to a heavy Liverpool defeat.

And so I told Baada, a Manchester City fan, that I’m not planning to watch tomorrow’s game. And he got back to me with some statistics, which he’d heard from a podcast. Apparently it’s been 80 years since Manchester City did the league “double” (winning both home and away games) over Liverpool. And that it’s been 15 years since they’ve won at Anfield. So, he suggested, there’s a good chance that tomorrow’s game won’t result in a mauling for Liverpool, even if I were to watch it.

With the easy availability of statistics, it has become a thing among football commentators to supply them during the commentary. And from first hearing, things like “never done this in 80 years” or “never done that for last 15 years” sounds compelling, and you’re inclined to believe that there is something to these numbers.

I don’t remember if it was Navjot Sidhu who said that statistics are like a bikini (“what they reveal is significant but what they hide is crucial” or something). That Manchester City hasn’t done a double over Liverpool in 80 years doesn’t mean a thing, nor does it say anything that they haven’t won at Anfield in 15 years.

Basically, until the mid 2000s, City were a middling team. I remember telling Baada after the 2007 season (when Stuart Pearce got fired as City manager) that they’d be surely relegated next season. And then came the investment from Thaksin Shinawatra. And the appointment of Sven-Goran Eriksson as manager. And then the youtube signings. And later the investment from the Abu Dhabi investment group. And in 2016 the appointment of Pep Guardiola as manager. And the significant investment in players after that.

In other words, Manchester City of today is a completely different team from what they were even 2-3 years back. And they’re surely a vastly improved team compared to a decade ago. I know Baada has been following them for over 15 years now, but they’re unrecognisable from the time he started following them!

Yes, even with City being a much improved team, Liverpool have never lost to them at home in the last few years – but then Liverpool have generally been a strong team playing at home in these years! On the other hand, City’s 18-game winning streak (which included wins at Chelsea and Manchester United) only came to an end (with a draw against Crystal Palace) rather recently.

So anyways, here are the takeaways:

  1. Whether I watch the game or not has no bearing on how well Liverpool will play. The instances from this season so far are based on 1. small samples and 2. biased samples (since I’ve chosen to watch Liverpool’s two toughest games of the season)
  2. 80-year history of a fixture has no bearing since teams have evolved significantly in these 80 years. So saying a record stands so long has no meaning or predictive power for tomorrow’s game.
  3. City have been in tremendous form this season, and Liverpool have just lost their key player (by selling Philippe Coutinho to Barcelona), so City can fancy their chances. That said, Anfield has been a fortress this season, so Liverpool might just hold (or even win it).

All of this points to a good game tomorrow! Maybe I should just watch it!

 

 

More issues with Slack

A long time back I’d written about how Slack in some ways was like the old DBabble messaging and discussion group platform, except for one small difference – Slack didn’t have threaded conversations which meant that it was only possible to hold one thread of thought in a channel, significantly limiting discussion.

Since then, Slack has introduced threaded conversations, but done it in an atrocious manner. The same linear feed in each channel remains, but there’s now a way to reply to specific messages. However, even in this little implementation Slack has done worse than even WhatsApp – by default, unless you check one little checkbox, your reply will only be sent to the person who originally posted the message, and doesn’t really post the message on the group.

And if you click the checkbox, the message is displayed in the feed, but in a rather ungainly manner. And threads are only one level deep (this was one reason I used to prefer LiveJournal over blogspot back in the day – comments could be nested in the former, allowing for significantly superior discussions).

Anyway, the point of this post is not about threads. It’s about another bug/feature of Slack which makes it an extremely difficult tool to use, especially for people like me.

The problem is slack is that it nudges you towards sending shorter messages rather than longer messages. In fact, there’s no facility at all to send a long well-constructed argument unless you keep holding on to Shift+Enter everytime you need a new line. There is a “insert text snippet” feature, but that lacks richness of any kind – like bullet points, for example.

What this does is to force you to use Slack for quick messages only, or only share summaries. It’s possible that this is a design feature, intended to capture the lack of attention span of the “twitter generation”, but it makes it an incredibly hard platform to use to have real discussions.

And when Slack is the primary mode of communication in your company (some organisations have effectively done away with email for internal communications, preferring to put everything on Slack), there is no way at all to communicate nuance.

PS: It’s possible that the metric for someone at Slack is “number of messages sent”. And nudging users towards writing shorter messages can mean more messages are sent!

PS2: DBabble allowed for plenty of nuance, with plenty of space to write your messages and arguments.

 

Nested Ternary Operators

It’s nearly twenty years since I first learnt to code, and the choice of language (imposed by school, among others) then was C. One of the most fascinating things about C was what was simply called the “ternary operator”, which is kinda similar to the IF statement in Excel, ifelse statement in R and np.where statement in Python.

Basically the ternary operator consisted of a ‘?’ and a ‘:’. It was a statement that took the form of “if this then that else something else”. So, for example, if you had two variables a and b, and had to return the maximum of them, you could use the ternary operator to say a>b?a:b.

Soon I was attending programming contests, where there would be questions on debugging programs. These would inevitably contain one question on ternary operators. A few years later I started attending job interviews for software engineering positions. The ternary operator questions were still around, except that now it would be common to “nest” ternary operators (include one inside the other). It became a running joke that the only place you’d see nested ternary operators was in software engineering interviews.

The thing with the ternary operator is that while it allows you to write your program in fewer lines of code and make it seem more concise, it makes the code a lot less readable. This in turn makes it hard for people to understand your code, and thus makes it hard to debug. In that sense, using the operator while coding in C is not considered particularly good practice.

It’s nearly 2018 now, and C is not used that much nowadays, so the ternary operator, and the nested ternary operator, have made their exit – even from programming interviews if I’m not wrong. However, people still continue to maintain this practice of writing highly optimised code.

Now, every programmer who thinks he’s a good programmer likes to write efficient code. There’s this sense of elegance about code written in a rather elegant manner, using only a few lines. Sometimes such elegant code is also more efficient, speeding up computation and consuming less memory (think, for example, vectorised operations in R).

The problem, however, is that such elegance comes with a tradeoff with readability. The more optimised a piece of code is, the harder it is for someone else to understand it, and thus the harder it is to debug. And the more complicated the algorithm being coded, the worse it gets.

It makes me think that the reason all those ternary operators used to appear in those software engineering interviews (FYI I’ve never done a software engineering job) is to check if you’re able to read complicated code that others write!

NRI Diaries: Day 3

The longer I’m here, the less I feel like an NRI and the more I go back to my earlier resident self. You can expect this series to dry out in a few days.

So Saturday started with a reversion of jetlag – I woke up at noon, at my in-laws’ place. One awesome breakfast/lunch/brunch (call it what you want – I ate breakfast stuff at 12:30 pm), it was time to get back home since I had some work at some banks around here.

I decided to take the metro. The wife dropped me by scooter to the Rajajinagar Metro Station. The ticket to South End Circle cost Rs. 30. The lady behind the counter didn’t crib when I gave her Rs. 100, and gave change.

Having used the metro as my primary mode of transport in London for the last nine months, I’m entitled to some pertinent observations:

  • Trains seemed very infrequent. When I went up to the platform, the next train was 8 minutes away. And there was already a crowd building up on the platform
  • Like in London, the platform has a yellow line and passengers are asked to wait behind that. But unlike in London, the moment you go near the yellow line, a guard whistles and asks you to get back. I’m reminded of Ravikiran Rao’s tweetstorm on Jewish walls.
  • For a Saturday afternoon, the train was extremely crowded.
  • My skills from an earlier life of expertly standing and grabbing a seat in a BMTC bus were of no use here, since other passengers also seemed to have that skill
  • My skills from the last few months in knowing where to stand comfortably in a crowded train were put to good use, though. I managed to read comfortably through my journey
  • It took 20 mins to get to South End. Another 10 mins walk home. Not sure this is quicker than taking a cab for the same journey

Afternoon was spent running around banks updating mobile number and Aadhaar. It was all peaceful, except for Punjab National Bank asking for a physical copy of my Aadhaar (which quite defeats the purpose! HDFC told me to update Aadhaar online. ICICI did it through ATM!).

In the evening I let go of some more vestiges of my NRI-ness. I got the water filter at home cleaned and started drinking filtered tap water. And then I went and had chaat at a street gaaDi. I promptly got “spicy burps”. I guess it was the masala powder he added.

I quickly made amends by going to my favourite jilebi stall and belting jilebi.

Then I went to meet fellow-NRI Paddy-the-Pradeep for coffee at Maiya’s in Jayanagar. We ordered bottled water, discussed first world economics and made jokes about NRIs carrying around bottled water. And then we walked out carrying the leftover bottled water as a NRI badge.

On my way home, I went to a nearby bakery and got plain cake, nippaTT and Congress.

All is well.

NRI Diaries: Day 2

NRI Diaries: Day 1

NRI Diaries: Day 2

I know this is a day late, but the reasons for that will be apparent by the end of the post.

Day Two (15th December) started with waking up at 9 am – jetlag had clearly not worn off. I was going to be late for my 10:30 meeting and started getting ready in a hurry only to see a text from the person I was meeting that he was late as well.

Once again I took an auto rickshaw for breakfast. Meter showed Rs. 35. I handed a Rs. 100 note. Driver said “no change”, and didn’t seem to mind when I told him that I’ll get change from the restaurant I planned to eat at and that he should wait. I bought coupons for my food, and brought back Rs. 50 for the auto guy, and he promptly gave me the change.

The meeting in question was on the other side of Silk Board, and I was dreading the commute. Surprisingly, the commute was rather smooth, taking less than 20 minutes from Jayanagar 4th T Block to HSR Layout. Along the way I got to hear the driver’s life story as he was constantly on the phone with a friend of his.

Traffic was worse on the way back from the meeting (started from HSR around 1230 pm). Took nearly an hour to get home (Jayanagar 3rd Block). And along the way I saw this:

I honestly miss this kind of stuff back in the UK, where I find people taking “data science” too seriously (another post on that sometime in the future).

Lunch was swiggied. Main course came from Gramina Thindi, It’s a tiny restaurant and doesn’t have a computer, so it’s not integrated into Swiggy’s ordering system. So swiggy actually sent a guy to the restaurant to place my order, and he waited there while it was being prepared and then brought it home to me.

I totally didn’t mind the Rs. 35 “delivery fee” they charged on top of my Rs. 55 lunch.

Dessert was from Corner House. Cake Fudge was as excellent as usual. Made a mental note to introduce this delicacy to the daughter before this trip is up.

And then it was time to go launch my book. Sales of the book are not exclusive to Amazon any more – it’s also available at Higginbothams on M G Road, which is where the book launch happened.

The launch was at this nice outdoor backyard of the store. I spoke to Pavan Srinath about some of the concepts I’ve described in the book. After that I signed copies, trying hard to get a wisecrack for everyone I signed for. I mostly failed.

The highlight of the launch was this guy zipping across the venue right behind me on a scooter, and then loudly honking. He was followed by another guy on a bike.

After the launch function was over, the wife and I decided to head to Mahesh Lunch Home for dinner. We took an auto. The guy at MG Road demanded Rs. 80 (ordinarily an exorbitant amount) to take us to Richmond Circle. We instantly agreed and got in.

He may have had some sense of seller’s remorse after that – in that he probably priced himself too low. So he drove slowly and, as we got to Richmond Circle, he said it would cost us a further Rs. 20 to take us across the road to Mahesh. We paid up again.

Something’s seriously wrong with Uber in Bangalore it seems. Out of six times I’ve tried using the service, I’ve got a cab within 5 minutes on only one occasion. On a few occasions, it’s been upwards of 10 minutes. And when the app showed that the nearest Uber was 20 mins away, we simply decided to take an auto rickshaw.

Except that we’d not bargained for drivers refusing outright to take us to Rajajinagar. One guy agreed and after we got in, asked for Rs. 300. This time, with our stomachs full, we were less charitable and walked out. Some walking and more waiting later, we were on our way to Rajajinagar, where I spent the night.

Oh, and it appears that the daughter has been afflicted by NRI-itis as well. She bears a red mark on her cheek following a mosquito bite.

NRI Diaries: Day 1

So I arrived in Bangalore this morning, after nine months in London. This makes this my first visit to India as a “Non Resident Indian” (NRI), and since foreign papers quite like getting opinions of India from NRI observers, I thought it makes sense to document my pertinent observations. I should mention upfront, though, that nobody is paying me for these observations.

The day began after a very short night’s sleep (we went to bed at 11 pm British Time and woke up at 7:30 AM India Time, a total of three hours) with a visit to one of our favourite breakfast establishments in Bangalore – Mahalakshmi Tiffin Room.

It was the daughter’s first ever auto rickshaw ride (back when we lived here we had a car and she was really tiny, so didn’t need to take her in an auto). She seemed rather nonchalant about it, occasionally turning her head to look outside. The auto ride cost us Rs 30. We gave Rs 100 and the driver asked us if we didn’t have change. Living outside makes you unlearn the art of change management.

We got our usual table at MLTR and were greeted by a rather usual waiter plonking three glasses of water on our table. We politely declined and requested for Bisleri.

After breakfast, it was time to get connected. I went to a medical shop near my home which I knew offers mobile phone top up services. Topping up the wife’s phone was rather straightforward, though it took some time given the crowd. During my fifteen minutes at the medical shop, at least six people came requesting for mobile phone top ups. Only two came asking for medicines. India seems to be getting healthier and wealthier.

Airtel decided to reassign my number to someone else so I needed a new SIM. I asked the medical shop guy for a Reliance Jio SIM. He spent ten minutes trying to log in to his Jio vendor app, and I gave up and took my business elsewhere. This elsewhere was a really tiny hole in the wall shop, which had a fingerprint reader that enabled the issue of a Jio SIM against Aadhaar authentication. The process was a breeze, except that I consider it weird that my mobile number starts with a 6 (the number I lost was a 9845- series Airtel).

Waiting at the hole-in-the-wall also made me realise that standing at shopfronts is not common practice in London. Thanks to high labour costs, most shops there are “self-service”. It’s also seldom that several people land up at one shopfront in London at the same time!

Losing my old number also meant I had to update the number with banks. I started with State Bank of India. The process was rather simple – took no more than 2 minutes. While at it, I asked about Aadhaar linking of my bank account there. There seems to be some confusion about it.

For example, I heard that if you have multiple accounts with the bank, you should only link one of them with Aadhaar – which defeats the purpose of the exercise, if one exists! Then, joint accounts need only one Aadhaar number to be linked. The linking process also differs based on who you ask. In any case, I encountered one rather helpful officer who completed my Aadhaar linking in a jiffy.

Then, my book is launching tomorrow which means I needed to buy new clothes. I landed up at FabIndia, and as is the practice in forin, I kept saying “hi” and “thank you” to the salespeople, who kept muttering “you’re welcome, sir”. While at it, the missus discovered that FabIndia now has rather explicit sales targets per store, which possibly explains why the salespeople there were more hands on compared to earlier.

Later in the evening, I got a haircut and a head massage. The last time I visited this salon, it was called “noble” (a rather common name for haircutting shops in Bangalore. Like Ganesh Fruit Juice Centres). Now it’s called “nice cuts”. The head massage was fantastic – I miss this kind of service back in the UK. I also borrowed the inlaws’ car and drove it around and even managed to parallel park it – nine months of no driving has done no harm to my driving skills.

Hopefully I’ll have more observations tomorrow.

Profit and politics

Earlier today I came across this article about data scientists on LinkedIn that I agreed with so much that I started wondering if it was simply a case of confirmation bias.

A few sentences (possibly taken out of context) from there that I agree with:

  • Many large companies have fallen into the trap that you need a PhD to do data science, you don’t.
  • There are some smart people who know a lot about a very narrow field, but data science is a very broad discipline. When these PhD’s are put in charge, they quickly find they are out of their league.
  • Often companies put a strong technical person in charge when they really need a strong business person in charge.
  •  I always found the academic world more political than the corporate world and when your drive is profits and customer satisfaction, that academic mindset is more of a liability than an asset.

Back to the topic, which is the last of these sentences. This is something I’ve intended to write for 5-6 years now, since the time I started off as an independent management consultant.

During the early days I took on assignments from both for-profit and not-for-profit organisations, and soon it was very clear that I enjoyed working with for-profit organisations a lot more. It wasn’t about money – I was fairly careful in my negotiations to never underprice myself. It was more to do with processes, and interactions.

The thing in for-profit companies is that objectives are clear. While not everyone in the company has an incentive to increase the bottom-line, it is not hard to understand what they want based on what they do.

For example, in most cases a sales manager optimises for maximum sales. Financial controllers want to keep a check on costs. And so on. So as part of a consulting assignment, it’s rather easy to know who wants what, and how you should pitch your solution to different people in order to get buy-in.

With a not-for-profit it’s not that clear. While each person may have their own metrics and objectives, because the company is not for profit, these objectives and metrics need not be everything they’re optimising for.

Moreover, in the not for profit world, the lack of money or profit as an objective means you cannot differentiate yourself with efficiency or quantity. Take the example of an organisation which, for whatever reason, gets to advice a ministry on a particular subject, and does so without a fee or only for a nominal fee.

How can a competitor who possibly has a better solution to the same problem “displace” the original organisation? In the business world, this can be done by showing superior metrics and efficiency and offering to do the job at a lower cost and stuff like that. In the not-for-profit setup, you can’t differentiate on things like cost or efficiency, so the only thing you can do is to somehow provide your services in parallel and hope that the client gets it.

And then there is access. If you’re a not-for-profit consultant who has a juicy project, it is in your interest to become a gatekeeper and prevent other potential consultants from getting the same kind of access you have – for you never know if someone else who might get access through you might end up elbowing you out.

Seven

It’s a little over seven years ago that we got married. It was a traditional Hindu ceremony. It was so traditional that we began at around 11am and finished with a ceremonial lunch only around 5:30 pm. And tradition meant that the priests hurried through the mantras, not bothering to explain what they were supposed to say (it’s another matter that had they bothered to stop and explain, we would’ve been getting married for another two days).

It was later that I got to know that some of those mantras were rather insightful, though archaic and backward if you go by modern sensibilities. Like this one Mantra the search for which led me to a website titled “6 noble virtues of an ideal wife“. As the website explains, it is from “Neeti Saara”, written by a Telugu poet Baddena in 13th century (yes, some of the wedding rituals are only 800 years old).

I won’t go into explaining these “noble virtues” here, but as I look back at our seven years of marriage, I realise that Pinky has been a brilliant wife. And she has done so while either studying or keeping a (mostly demanding) full time job for most of the duration of our marriage.

I’m reminded of the time when we lived in Rajajinagar, when I was working as an independent management consultant. I would work from home, and having disposed of our cook a few months earlier, I had the task of making my own lunch.

Pinky would have none of it. She would wake up at 5:30 and painstakingly make tall stacks of chapatis (I was going through one of those “I don’t want to eat rice” phases at that time) before she ran to catch her factory bus, so that I could have a good meal. And the dutiful husband I was, I’d finish the full day’s quota in the afternoon itself which meant she would be forced to cook again once she was back after a tiring day and 40-kilometre commute.

I’m also reminded of the time earlier this year when we’d moved to London and I hadn’t yet figured out what I was going to do here. Pinky not only supported our family financially, but also ferry Berry all the way into town each day so that I could figure out life, possibly find a job and finish my book. And on most days it would be Pinky who would cook dinner after another long commute (usually with a screaming baby).

During my consulting life, every time I had to strike a deal or go through a tough negotiation, I would turn to Pinky. Each time she would unfailingly help me sort out my demons and give me sage advice. On several occasions she saved me from pricing too low. When she would see that I was getting into a bad deal, she would firmly pull me back.

She was insanely supportive when in late 2011 I decided to quit my job and lead a portfolio life. She would find her own cute ways of supporting me in every endeavour, like buying me a new fancy notebook when I was going to meet my first prospective big client, or trying to find me a fancy water bottle prior to my bike trip across Rajasthan.

When I would wake up at 4am to catch the first flight out to see outstation clients, she would wake up along with me, make coffee for me and polish my shoes. On two such occasions she wasn’t around. I almost missed my flight on one of those occasions, and missed my flight on the other!

From time to time she plans fun activities for us to do together, like the time she took me to the A-Paul-ogy art gallery, or when she took me for a Japanese meal to Matsuri and totally bossed the menu (before I knew it she’d ordered a host of dishes which made for a wonderful and complete meal!).

In some senses, I feel I haven’t held up my side of the bargain at times. One thing she absolutely enjoys is for us to watch movies together, but we almost never do that since I don’t generally have the patience to watch movies. She would love to spend a Friday evening cuddling on the couch watching something together, but I prefer to be on my computer instead. She loves being surprised, but my ineptitude means that on most occasions I’ve tried it’s been a shock rather than a surprise.

And then I have my occasional bouts of extreme anger, and she’s borne the brunt of it on several occasions. Usually it involves shouting (I’m an absolute shouter and love to went out my frustrations; she’s the quiet types) and I have to try hard to not get violent at times (on some occasions I don’t succeed in restraining myself). On some occasions it starts with something seemingly silly. On others, I fuck up like crazy. Either ways, it occasionally gets ugly – something I’m definitely not proud about.

I know I have driven her insane. I know that my negativity and NED has rubbed off on her. It is normal for a married couple to influence and change each other, and I know I’ve changed her in ways she absolutely hates.

Yet she’s always been the forgiving sorts. She’s stood by me thick and thin through the seven years of our marriage. Thanks to her adventures during her MBA, I’ve managed to increase my country count (and also got to move to a new country!).

And she’s been a wonderful mother to Berry. One old friend who met Pinky for the first time last year later told me, “man, she is so sorted!”. She remains cool, and seemingly without taking much stress, has managed to turn Berry into a bright and naughty toddler – I’ve mostly been a freerider! Oh, and do you know that she writes an absolutely delightful letter to Berry each month?

It’s mostly been a wonderful seven years with Pinky so far! I know we’ve had the odd low moment, and I want to take this opportunity to apologise to her for that. But in my mind, these have been far far outweighed by all the wonderful times we’ve been through, and all the fun we’ve had together! I hope to get another seventy such wonderful years with this wonderful woman!

And for after that, there’s this:

PS: The more perceptive of the readers here will know that this blog (its predecessor, rather) played a not insignificant part in us meeting. One of the posts that drew her attention, and which got us talking was this.

AlphaZero defeats Stockfish: Quick thoughts

The big news of the day, as far as I’m concerned, is the victory of Google Deepmind’s AlphaZero over Stockfish, currently the highest rated chess engine. This comes barely months after Deepmind’s AlphaGo Zero had bested the earlier avatar of AlphaGo in the game of Go.

Like its Go version, the AlphaZero chess playing machine learnt using reinforcement learning (I remember doing a term paper on the concept back in 2003 but have mostly forgotten). Basically it wasn’t given any “training data”, but the machine trained itself on continuously playing with itself, with feedback given in each stage of learning helping it learn better.

After only about four hours of “training” (basically playing against itself and discovering moves), AlphaZero managed to record this victory in a 100-game match, winning 28 and losing none (the rest of the games were drawn).

There’s a sample game here on the Chess.com website and while this might be a biased sample (it’s likely that the AlphaZero engineers included the most spectacular games in their paper, from which this is taken), the way AlphaZero plays is vastly different from the way engines such as Stockfish have been playing.

I’m not that much of a chess expert (I “retired” from my playing career back in 1994), but the striking things for me from this game were

  • the move 7. d5 against the Queen’s Indian
  • The piece sacrifice a few moves later that was hard to see
  • AlphaZero’s consistent attempts until late in the game to avoid trading queens
  • The move Qh1 somewhere in the middle of the game

In a way (and being consistent with some of the themes of this blog), AlphaZero can be described as a “stud” chess machine, having taught itself to play based on feedback from games it’s already played (the way reinforcement learning broadly works is that actions that led to “good rewards” are incentivised in the next iteration, while those that led to “poor rewards” are penalised. The challenge in this case is to set up chess in a way that is conducive for a reinforcement learning system).

Engines such as StockFish, on the other hand, are absolute “fighters”. They get their “power” by brute force, by going down nearly all possible paths in the game several moves down. This is supplemented by analysis of millions of existing games of various levels which the engine “learns” from – among other things, it learns how to prune and prioritise the paths it searches on. StockFish is also fed a database of chess openings which it remembers and tries to play.

What is interesting is that AlphaZero has “discovered” some popular chess openings through the course of is self-learning. It is interesting to note that some popular openings such as the King’s Indian or French find little favour with this engine, while others such as the Queen’s Gambit or the Queen’s Indian find favour. This is a very interesting development in terms of opening theory itself.

Frequency of openings over time employed by AlphaZero in its “learning” phase. Image sourced from AlphaZero research paper.

In any case, my immediate concern from this development is how it will affect human chess. Over the last decade or two, engines such as stockfish have played a profound role in the development of chess, with current top players such as Magnus Carlsen or Sergey Karjakin having trained extensively with these engines.

The way top grandmasters play has seen a steady change in these years as they have ingested the ideas from engines such as StockFish. The game has become far more quiet and positional, as players seek to gain small advantages which steadily improves over the course of (long) games. This is consistent with the way the engines that players learn from play.

Based on the evidence of the one game I’ve seen of AlphaZero, it plays very differently from the existing engines. Based on this, it will be interesting to see how human players who train with AlphaZero based engines (or their clones) will change their game.

Maybe chess will turn back to being a bit more tactical than it’s been in the last decade? It’s hard to say right now!