One of these things is not like the other…

Categories: Journal, Machine Learning
Comments: Comments Off
Published on: August 20, 2018

HAL8999 – 3/100

  • Chapter 2 of Hands on ML
    • Cost functions
    • virtualenv setup
    • code to get the dataset

The chapter follows a rudimentary machine learning project from business case to final product. California census data is analyzed to build a model which will predict media housing price in a district based on other factors using a linear regression model with a Root Mean Square Error (RMSE) function to measure performance i.e. as a cost function.

\(\displaystyle RMSE(X, h) = \sqrt{\frac{1}{m}\sum_{i=1}^{m}(h(x^{(i)}) – y^{(i)})^{2}}\)

The function h is the “hypothesis” function which operates on the feature vector \(x^{(i)}\). RMSE isn’t the only cost function by any stretch of the imagination but it seems to get a lot of use.

From this point the author goes through the dev environment setup process I went through a few days ago and it’s pretty clear from the instructions that the work is being done on a Mac. 

The code to download the housing tarball is a little sloppy and would have downloaded it every time I ran the cell so I added a simple test to only do the download if the file didn’t already exist.


Steak and ML

Categories: Journal, Machine Learning
Comments: Comments Off
Published on: August 19, 2018

Achievement: HAL 8999 – 2/100

  • Completed chapter 1 of Hands On ML and worked through the exercises
  • Modified yesterdays example to also do both k-nearest-neighbors with both three and four neighbors. Four neighbors was further from the linear regression than three demonstrating that more is not always better.

Short list but Ch1 is something of an overview so a lot of concepts get thrown in with not a lot of context or depth of discussion so I found I got to the end and had a hard time connecting what I’d read with the specific questions asked at the end of the chapter. I ended up paging back through the chapter to locate the answers to questions which were oddly specific as opposed to focusing on the broad underlying concepts.

The fact that I did a chunk of the reading while grilling tri-tip and elote and then later when in the post steak and mexican corn food coma might also be part of why and ended up paging back through the chapter so much.

Sort yourself out

Categories: Journal, Machine Learning
Comments: Comments Off
Published on: August 18, 2018

Achievement: HAL 8999 – 1/100

  • Set up virtualenv for HAL8999
  • Installed sklearn, pandas, numpy, matplotlib
  • Unable to install tensorflow since I’m on python 3.7 and the pip installs only work for 3.6 and earlier. I can sort that out later.
  • Read up through Example 1-1 in Hands-On Machine Learning
    • Author is a little fast and loose with the example code and imports

I ended up burning close to an hour figuring out why my plot and model didn’t match the author’s even though we were using the same data. The issue turns out that I’d left out the following line when massaging / mangling the data:

It’s not immediately clear to me why presorting the values would make any difference but the unsorted dataframe included values well outside the range used in the author’s jupyter notebook. My guess is that by using the unsorted data I was applying the wrong GDP values to the wrong countries and so some outlier data made it into the model. Clearly my pandas-fu is weak. Po would be sad.

Also, Visual Studio Code is oddly pickier about the import of sklearn.linear_model and refused to initialize the model unless I specified the whole sklearn.linear_model.LinearRegression() where Jupyter was fine with linear_model.LinearRegression().

HAL 8999

Categories: Journal, Machine Learning
Tags: No Tags
Comments: Comments Off
Published on: August 18, 2018

Some druids apparently wandered by and cast Wall of Thorns in my yard so I spent a good sized chunk of the morning clearing blackberry brambles.  While my hands were busy being impaled by the thorns which unerringly find the weak points in my gloves I got to thinking about some of the things on my internal to do list as well as my achievement list which I’ve been falling down on.

Since I’m already learning machine learning on an informal basis anyway I may as well be like one of the cool kids and do that “100 days of machine learning challenges”. Since “100 days of machine learning” is a relatively uninspiring name and makes things sound like a slog, the HAL 8999 achievement was born. One hour of ML or ML related math per day, every day, for 100 days with an associated blog post to keep the record clear.

Displaying Markdown and Latex in Jupyter output cells

Categories: Journal
Tags: ,
Comments: Comments Off
Published on: August 14, 2018

Just out of curiosity I started looking into how to get jupyter to display text and math formatted as markdown and latex in output cells. This got into my head when I was looking at symbolic integration and differentiation of functions and how to format the output in a more civilized manner. I don’t have the full solution to the question but formatting output as markdown turned out to be ridiculously easy since the heavy lifting had already been done.

Displaying markdown and Latex in jupyter output cells


  • And of course the new WordPress editor is helpfully mangling both the code highlighting and output. Trust me, it works. I’ll have to sort out how to get “Gutenberg” to do the right thing later.
  • Thrashing around a bit now get’s the code highlighted but now the crayon tag is visible. Still no love for the actual Latex.
  • Rolling back to the old editor and fixing these posts. I’ll deal with the gutenberg editor issues when I’m dragged kicking and screaming to it

So far this morning

Categories: Journal, Projects
Comments: Comments Off
Published on: August 11, 2018

So far this morning I’ve

  • Gotten jupyter notebooks running natively on my workstation rather than using the linux subsystem as a workaround
  • Learned how to integrate functions in python using scipy
  • Got exporting of jupyter notebooks to html working properly
  • Built a scale model of the terrain around my home town in Unity
  • Gained three levels on my warlock

Now I’m going to put my pants on.

Integrating Functions

Quick example on integrating functions with jupyter, matplotlib, numpy, and scipy

Import the required libraries

Define your function

For this example we’ll be using \(f(x) = e^{-x}sin(3x)\) as our function.

Set the range for your plot and integration

To plot \(f(x)\) we get an array of linearly spaced values from numpy, pass that array and our function to the plot function, and show the plot.

Evalating the integral \(\int_{0}^{2\pi}e^{-x}sin(3x)\) simply requires passing our function and the range of the intgral to scipy’s quad function which will return a tuple of the integral and the estimated error.

Integral: 0.29943976718048754
Estimated error 5.05015300411582e-13


Categories: Journal
Comments: Comments Off
Published on: August 6, 2018

There comes a point when it’s clear that you’re not the central figure in your kid’s life. It’s a good thing. You know it’s going to happen someday. You accept it as a natural part of growing up.

The problem is, that moment sneaks up on you when you least expect it and then punches you in the kidney without the slightest warning. Sure, they still want to do things with you but, the fact is, you’re no longer at the top of the priority list and, in fact, you’re further down that list than you’d like to admit.

God, it hurts.

But, it’s good. It’s necessary. And I’d be the worst kind of parent if I manipulated my kid into doing things that make me happy rather than the things that make her happy. So, here I sit, going through another block of python code while she talks and laughs with her friends in the next room rather than playing video games with me.

It’s the right thing but damn if it doesn’t suck ass.

Plugin testing

Categories: Journal
Tags: ,
Comments: Comments Off
Published on: August 5, 2018

One of the benefits of coming back to an existing wordpress blog rather than continuing to try to roll my own in is that I can easily piggyback on other people writing plugins to solve the same problems. So far, the Crayon and MathJax-Latex plugins seem to fit the bill.

Testing syntax highlighting

Testing Latex / Math

J(\theta) &= \frac{1}{m}\sum_{i=1}^{m}Cost(h_\theta(x)^{(i)},y^{(i)}) \\
Cost(h_\theta(x),y) &= -log(h_\theta(x))& y=1 \\
Cost(h_\theta(x),y) &= -log(1-h_\theta(x))& y=0

Three years of silence

Categories: Family, Journal, Social Media
Tags: No Tags
Comments: Comments Off
Published on: August 5, 2018

I’ve been disconnected from social media for two years now. I still occasionally shitpost on reddit but that’s a habit I’ve largely broken myself of. I find, however, that I do need to find someplace to write things down that is both isolated enough from the internet that I don’t get much traffic but public enough that it’s accessible to the people who matter so I’ve dusted off this old wordpress blog. I shuttered it about the time I withdrew from most social media engagement and put the house in AR up for sale for the move to OR; too much to do, too little time.

Going back through the posts and republishing what had been previously made private simply reaffirms that keeping some form of journal is a good idea. I’ve been reminded of things I’d forgotten and identified trends and behaviors that you don’t see in your day to day grind. The short notes about life with my wife and daughter are what took me most by surprise. The reminders of how my little girl has been growing up and how much I love my wife hit hard.

I don’t get the last three years of silence back. I don’t know what I’ve forgotten but the value of keeping some sort of journal, even if it’s just to jog my own memory, is clear.

First world problems

Categories: Life
Tags: No Tags
Comments: Comments Off
Published on: July 23, 2015

I don’t know when this phrase entered my vocabulary. The only recollection I have of it is a comment that I can’t remember by a person I can’t recall on a messages board I’m uncertain of: definitely a first world problem. That little phrase so accurately and powerfully put into perspective the minor irritation the poster was referring to that it immediately became a reflexive yardstick in my own mind.

The grocery store is out of the yogurt I like, definitely a first world problem. Someone is wrong in the internet, definitely a first world problem. I’m out of the artificial sweetener I like, definitely a first world problem. There is a login queue for the MMO I’m playing, absolutely a first world problem.

Looking it up in google it’s clear that this is a meme that has soaked into my mind through osmosis. Reddit has a firstworldproblems board and #tagdef has a definition for it.

It’s like coming across something in your house that you didn’t buy and didn’t borrow. You’re not entirely sure how and why it got to be there and yet it fits with the decor.

«page 2 of 14»
Welcome , today is Wednesday, January 20, 2021