James Martini archive

Category : Journal (54)

Steak and ML

Categories: Journal, Machine Learning
Tags:
Comments: No Comments
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
Tags:
Comments: No Comments
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: No Comments
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: No Comments
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.

[/crayon]

Displaying markdown and Latex in jupyter output cells

$\phi$

  • 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.

So far this morning

Categories: Journal, Projects
Tags:
Comments: No Comments
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

Dissappointed

Categories: Journal
Tags:
Comments: No Comments
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 github.io 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

[python]
# hello_world.py

class HelloWorld():
“””An unnecessarily complex hello world”””
def __init__(self):
print(“Hello world”)

if __name__ == “__main__”:
hello = HelloWorld()
[/python]

Testing Latex / Math

$$
\begin{align}
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
\end{align}
$$

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.

This is the beginning of the song

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

Cultural identity pings

Bad Buddhist: I don’t like prostration

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

I was looking at some photos taken at a recent festival at Bodghaya and one of them were of the boards used by people making multiple prostrations. I’ve meditated with people who similarly, although less frequently, prostrate themselves. I never prostrate myself.

I understand many of the reasons for prostration but it never feels like anything other than an ostentatious display when public and a meaningless gesture when private. I’m sure that’s part of my western upbringing. Looking at the common rationals for prostration, it isn’t surprising that I’m not inclined to bow my head and bend my back: accumulation of merit, veneration of the Buddha, cultivating humility / negating pride.

The accumulation of merit has always struck me as a very simplistic way to get people to do good things when they might not otherwise be disposed to it. The performance of good deeds in the hopes of a better reincarnation smacks of the belief in something that is actually reincarnated. This runs counter to my own belief that I’m simply a temporary confluence of flesh, mind, thought and experience; that what lives on after I die are simply the echos and ripples of my thoughts and actions, not me. Good deeds aren’t for me, they’re for other people and if that moves the needle on the cosmic balance enough that I benefit indirectly, that’s my better life. Not the next life, this one.

Venerating the Buddha is similarly not a strong motivation to bow. Bowing before someone or some thing to venerate it just isn’t a big part of my cultural experience. My view of Siddhartha Gautama is closer to how a basketball fan might view Michael Jordan. I recognize the accomplishment and feel the desire to emulate it but, just as most basketball fans don’t bow to effigies of Jordan. My veneration takes the form of reaffirming my commitment and taking refuge.

Finally, the real reason I don’t want to prostrate myself is that I don’t want to bow my head or bend my back for anyone. I’m not vain but I am prideful. I should bow for no other reason than to cultivate humility. The trap there is when does prostration stop being an exercise in humility and become a display.

«page 1 of 6
Welcome , today is Monday, August 20, 2018