Half Human, Half Machine, All Learning

Spread the Love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Okay, I need to apologize — for I have been lying to you all this time.

Even though this blog series is called, “Making Machine Learning More Human,” I’ve actually spent very little time talking about machine learning.  If this were a neurology blog, or a psychology blog, or a pedagogy blog, or even a zoology blog, 90% of what I’ve written would remain the same.

It’s the “machine” in machine learning that sets this discipline apart from the others.  Whereas those fields focus on carbon-based learning organisms, we’re the only field that is uniquely concerned with silicon-based entities.  What makes machine learning especially fascinating is that while carbon-based lifeforms evolved the ability to learn, silicon-based systems never did.  We have to give them that ability.  And the way to do that is by becoming machine whisperers.

And the best path to get there is to study computer science.  So what is computer science exactly?  It’s a sub-branch of mathematics that tries to cram the infiniteness and continuousness of all of math into a finite and discrete box.  Needless to say, that’s an unpossible task.  Yet, computer scientists spend their entire careers tilting at such windmills.  Why?  Because we’re insane.

Dude!  You’re insane!”

“Huh?  Why would you say that?”

“Well, first off, you’re talking to me — a horse!”

“Oh!  That’s because not only am I a machine whisperer, I’m a horse whisperer, too!”

“Horse whisperer?!  Wait a minute — are you the sick creep who’s been whispering sweet-nothings in my ear while I’m sleeping?!”

(image by falco from Pixabay)

Look, I get it.  Most of you have no interest in joining us in the loony-bin.  You just want to visit, get what you need, and get the HELL out.  For you folks, if you want to gain anything from machine learning, then at an absolute minimum you would need to develop some good programming skills.

In this post and in the next few, I’ll discuss a few important programming concepts that you need to know.  If you incorporate them into your work, you’ll improve your coding skills by leaps and bounds.

The Dunning-Kruger Effect

Programming is both a supervised and an unsupervised learning problem.  It’s supervised because the program you’re writing has to be correct.  You need to make sure it functions properly and is doing what it’s supposed to be doing.

But being correct is not enough.  The program must also be readable.

I interact with a lot of people who, despite not having any software development training, seem to think that they’re the Pablo Picassos of programming.  They’d proudly show me their work, completely oblivious that it’s pure crap.  My thoughts would go, “Oh, boy.  This code is going to give the poor computer an epileptic seizure!”  Sadly, it’s the Dunning-Kruger effect.

In these instances, I feel like the parent whose child is showing him a picture she’s drawn.  He wants to tell her, “Sweetie, this drawing is garbage.  The only place it belongs in is the trash can.”  But he doesn’t, because she’s put so much effort into it, and it would break her little heart to hear the sad truth.  Instead, he tapes it to the fridge and treats it like a masterpiece on display at the Metropolitan Museum of Art.

Computer programs are stories that you tell not just to the computer, but to other programmers, to your children, to your grandchildren, and even to yourself six months from now when you will have forgotten what you’ve written.  While it’s true that there is no right way or wrong way to code — as long as your program is bug-free — there IS, however, a pretty way and an ugly way.

The sheer ugliness of some of the programs that I’ve seen would offend the sensibilities of artists everywhere.

Well, maybe not Jackson Pollock.  His painting, Number 31, is literally spaghetti code!

Even if you don’t care about other programmers, or your children, or your grandchildren, at least do it for yourself.  I guarantee that six months after you write a program, you’ll need to dig it back up to make changes.  You’ll save your future self a lot of pain and headache if you write in a clear and concise manner.

I won’t be discussing the supervised learning aspects of programming, since there are plenty of technical books, websites, and other resources available to teach you how to write correct and bug-free code.  Instead, I’ll delve into how to write readable code.

The Elements of Style:&nbsp&nbspThe Programmer's Edition

Like stories, a computer program contains two elements — nouns and verbs.  In programming, we refer to nouns as data ( or alternatively, variables ), and verbs as functions.

Yep, thhaaat’s riigghhtt!  A function is just mathspeak for a verb.  In grade school, when your teacher first introduced the concept of functions, she probably wrote this on the chalkboard:

f( x ) = y

Then clumsily defined it as, “the function, f(  ), is a mapping that transforms x into y.”  Well, the only way a noun like x can turn into a y is through the actions of a verb.  Here’s an example:

f( youAtHome ) = youAtTheMarket

What might f(  ) be that would change your original state of being at home to now being at the market?  Here’s an easy one:

go_to_market( youAtHome ) = youAtTheMarket

Here are a few more:

run_to_market( youAtHome ) = youAtTheMarket
drive_to_market( youAtHome ) = youAtTheMarket
take_bus_to_market( youAtHome ) = youAtTheMarket  /* make sure it's not the 2525! */

And if you live in the Star Trek universe, f(  ) can even be:

teleport_to_market( youAtHome ) = youAtTheMarket

So, the next time a math nerd comes up to you and starts babbling about functions, DON’T PANIC!  Just remember that functions are verbs, and you’ll be okay.  But if he prattles on about surjectives, injectives, bijectives, etc., then punch him in the face.  They’re simply fancy terms for different types of verbs — and he’s being utterly obnoxious.

The usual convention is to name variables with noun words or noun phrases.  Here are a few examples:

dog
cat
catWhoConstantlyCoughsUpFurballs
felixTheCat
manOnAMission
waltWhitman
leavesOfGrass
trafficLight

Functions are normally named with verb words or verb phrases:

walk( )
run( )
laugh( )
cry( )
raise_the_roof( )
phone_home( )
stand_in_line_for_three_days_to_buy_the_latest_iPhone( )
tilt_at_windmills( )

Of course, many programmers don’t stick to these conventions — not even seasoned ones.  While you don’t need to either, it’s still a very good idea to do so.  Things will be less confusing, as it’ll help you keep straight what’s going on.

In previous posts, I used the term function a number of times, especially when talking about trained models.  Why are trained models considered functions?  Yep, exactly!  Because they’re all verbs!  When you learn a new skill, you’re adding a verb to your repertoire.  If you have communications skills, then you have the ability to communicate.  When you learn German, you’re developing the ability to speak and read German.  You learn to ride a bicycle.  Common sense is the ability to understand what is the right thing to do in various social contexts.

In addition, I’ve used the term algorithm.  It’s just another fancy word for verb.  More specifically, it’s a summary of all the steps that one has to take in order to complete an action.  In go_to_market( ),

go_to_market( oldState )
{ exit_front_door( ); walk_three_steps_to_left( ); smell_the_pretty_flowers_at_the_corner_florist( ); cross_street( ); ... walk_four_steps_to_right( ); enter_thru_the_front_door( ); return newState; }

The algorithm is all the stuff between the curly braces.  So, a machine learning algorithm is all the steps a machine has to take in order to learn.

Know Your Audience

Writing computer programs is easier in many ways than writing stories.  A programmer’s audience tends to be fairly homogenous.  The programmer can usually assume that it’s mainly composed of people who are in a limited range of professions and who are comfortable with technical jargon.  An author, unfortunately, can’t make these assumptions.  His audience very likely comes in all shapes and sizes, and from all types of backgrounds.  Even genre writers have to accept that they’re writing for a varied crowd.  Readers of mystery books, for example, are not all, say, police detectives.  And teen fiction novels, such as Harry Potter and Twilight, have sizable adult audiences.

On the other hand, coding is actually a lot tougher than writing.  Authors can pretty much assume that their readers are all human.  Programmers, on the other hand, have to write for both humans and computers.  Unlike people, computers can’t go out and experience the world.  They just sit at your desk all day.  Staring at you when you work, and staring at your chair when you’re not.  They can’t approach a program with a posteriori knowledge the way humans can.

The Devil Is In The Details

Unfortunately, this means that you have to provide a tremendous amount of detail in everything you code.  Computers absolutely love that.  Since they can’t experience the world on their own, they have to do it vicariously through your program.  Humans, on the other hand, absolutely hate minutiae.  Since they’ve gone_to_the_market(  ) numerous times already, they don’t need step-by-step instructions on how to get there.  Writing for computers necessarily forces your program to resemble a Charles Dickens novel — but you still need to make it look like a Dr. Seuss book for human readers.

Most novice programmers I work with don’t quite understand this.  They would dump all the details into the main parts of their programs — as if some verb exploded all over their code:

wake_up( youInBed ) = youAtHome;
brush_teeth( youAtHome ) = youAtHomeWithBrushedTeeth;
get_dressed( youAtHomeWithBrushedTeeth ) = youAtHomeDressed;

…

exit_front_door( youAtHomeDressed ) = youInFrontOfHome;
walk_three_steps_to_left( youInFrontOfHome ) = youThreeStepsFromHome;
smell_the_pretty_flowers_at_the_corner_florist( youThreeStepsFromHome ) =
    youSmellingFlowers;
cross_street( youSmellingFlowers ) = youOnOtherSideOfStreet;

…

walk_four_steps_to_right( youExitingThePark ) = youApproachingTheMarket;
enter_thru_front_door( youApproachingTheMarket ) = youAtTheMarket;

…

pay_with_cash( youReadyToCheckout ) = youPurchasedGroceries;
exit_thru_front_door( youPurchasedGroceries ) = youOutsideTheMarket;
walk_ten_steps_to_corner( youOutsideTheMarket ) = youAtTheCorner;

…

step_on_boardwalk( youApproachingTheBeach ) = youOnTheBroadwalk;
walk_seven_steps_to_stairs( youOnTheBroadwalk ) = youOnTheStairs;
go_down_stairs( youOnTheStairs ) = youOnTheBeach;
step_on_sand( youOnTheBeach ) = youOnTheBeachWithSandInYourToes;

…

walk_to_friends_car( youMeetFriend ) = youAtFriendsCar;
open_rear_door( youAtFriendsCar ) = youEnteringFriendsCar;
enter_friends_car( youEnteringFriendsCar ) = youInFriendsCar;

…

exit_friends_car( youLaughingWithFriend ) = youOutsideFriendsCar;
walk_to_front_door_of_friends_house( youOutsideFriendsCar ) =
    youOutsideFriendsHouse;
enter_friends_house( youOutsideFriendsHouse ) = youInFriendsHouse;

…

exit_friends_house( youSayingGoodByeToFriend ) = youOutsideFriendsHouse;
walk_seven_steps_to_bus_stop( youOutsideFriendsHouse ) = youAtBusStop;
wait_for_bus( youAtBusStop ) = youStillAtBusStop;
enter_bus( youStillAtBusStop ) = youOnTheBus;

…

exit_bus( youStillOnTheBus ) = youThreeStepsFromHome;
walk_three_steps_to_front_door( youThreeStepsFromHome ) =
    youInFrontOfHome;
enter_front_door( youInFrontOfHome ) = youAtHome;

Uhh, what the heck is this about?!  It’s as if they have never heard of functions.

Those who have, however, don’t seem to understand how to use them properly.  They would arbitrarily push a chunk of unrelated code into a haphazardly-created function.

/* program */
wake_up( youInBed ) = youAtHome;
brush_teeth( youAtHome ) = youAtHomeWithBrushedTeeth;
get_dressed( youAtHomeWithBrushedTeeth ) = youAtHomeDressed;

go_to_market_then_the_beach_then_your_friends_house_then_head_home
    ( youAtHomeDressed ) = youStillOnTheBus;

exit_bus( youStillOnTheBus ) = youThreeStepsFromHome;
walk_three_steps_to_front_door( youThreeStepsFromHome ) =
    youInFrontOfHome;
enter_front_door( youInFrontOfHome ) = youAtHome;
/* function */
go_to_market_then_the_beach_then_your_friends_house_then_head_home
    ( oldState )
{

    …

    exit_front_door(  );
    walk_three_steps_to_left(  );
    smell_the_pretty_flowers_at_the_corner_florist(  );
    cross_street(  );

    …

    walk_four_steps_to_right(  );
    enter_thru_front_door(  );

    …

    pay_with_cash(  );
    exit_thru_front_door(  );
    walk_ten_steps_to_corner(  );

    …

    step_on_boardwalk(  );
    walk_seven_steps_to_stairs(  );
    go_down_stairs(  );
    step_on_sand(  );

    …

    walk_to_friends_car(  );
    open_rear_door(  );
    enter_friends_car(  );

    …

    exit_friends_car(  );
    walk_to_front_door_of_friends_house(  );
    enter_friends_house(  );

    …

    exit_friends_house(  );
    walk_seven_steps_to_bus_stop(  );
    wait_for_bus(  );
    enter_bus(  );

    …

    return newState;
}

Uhh, again, what the heck is going on?  How did you magically go from being at home to then being on the bus?  What bus?

A better approach would be to group the steps that form common themes into separate functions, such as:

/* program */
wake_up( youInBed ) = youAtHome;
go_to_market( youAtHome ) = youAtTheMarket;
go_to_beach( youAtTheMarket ) = youAtTheBeach;
visit_friend( youAtTheBeach ) = youAtFriendsHouse;
go_home( youAtFriendsHouse ) = youAtHome;
/* function */
wake_up( oldState )
{
    …

    return newState;
}
/* function */
go_to_market( oldState )
{
    …

    return newState;
}
/* function */
go_to_beach( oldState )
{
    …

    return newState;
}
/* function */
visit_friend( oldState )
{
    …

    return newState;
}
/* function */
go_home( oldState )
{
    …

    return newState;
}

People reading this will immediately get the gist of the story.  If they want more information, they can crack open any function for more details.

Now that you understand the basics of a computer program, it’s time to organize your code into a coherent story.  In the next post, I’ll discuss the three most popular programming paradigms in use today.

( illustration assembled from images available at Pixabay )

Would you like some green eggs and ham?
Could you eat them in a box
that’s atop some rocks?
Should you eat them with a fox,
who’s wearing your socks?

Yes, I would like some green eggs and ham.
I could eat them in a box
that’s atop some rocks.
I should eat them with a fox,
who’s wearing my socks.
But ONLY if you tell me —
what exactly IS green eggs and ham?

Well, it’s just regular eggs and ham
that’s been sitting out for a week … .

0 0 votes
Rate This Article!
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x