David Lichtenberg Machine learning and python delivered straight to your brain.

Detecting Lane Lines in Python with OpenCV

I recently built a lane detection tool for the first project of the Self Driving Car Nano Degree program through Udacity. The goal of the project was to detect lane lines on overhead camera video footage taken while a person was driving.

Flu Night Thoughts

There is something insane about neural networks. I’m sitting here on my bed at 9:23PM, with the flu, watching the numbers roll down my screen. Hmm. I can’t get even close to the results I got with xgboost. What if I change the learning rate and let it run longer? What if I add decay for the learning rate and an extra hidden layer. What if I let it run for an extra hundred epochs. I know this isn’t how professionals train networks. They automate training with this param and that param. They create a master that spins up all these different network configurations to see which is best. Me, I’m just playing the lottery. But, all of a sudden, my totally poop emoji model can compete. I mean, it’s still not doing as well as xgboost, but maybe I can use it in a second layer ensemble with xgboost to push my accuracy over the edge. It’s like they’re just magic. I mean, I understand how it’s implemented, but it’s beautiful. I just hope it doesn’t crash my chrome again. I’ll just minimize the window until its done.

Getting Started With Keras

Keras is a high level framework for building neural networks on top of Tensorflow or Theano. Knowing how to use Keras (or a alternative to it) will speed up your prototyping process when working with Neural Networks. It’s also a good place for beginners to start, as it doesn’t require much code to get a neural network running. In Keras, your first neural network can be as simple as this:

Expert Python: Decorators

Hey! What’s up? Have you ever decorated a function before in python? You probably have if you’ve used any of the popular web frameworks. Both Django and Flask rely heavily on them. Decorating looks like this:

A love letter to mypy

I love mypy. Optional Static Types are a game changer for python. They have melted away my least favorite thing about my favorite language. It is HARD to keep track of what things are supposed to go in and come out of functions. Documentation can be stale or non existent (although type hints can also be non-existent, its tougher for them to be stale because your code won’t pass the type check). I often find myself dropping into the debugger or running snippets of code in jupyter just to have some sense of what type of data is flowing through where. This can becomes even more challenging when you are collaborating on a large codebase.

Teach a new branch old commits

I was recently using an open source project and, like software often doesn’t, it didn’t do what I expected. So, I opened it up and started fiddling with the code to see if I could make it work. Soon enough, I had an improvement, so I quickly committed the code. Excited by my positive results, i kept fiddling and found myself with more improvement, so I committed more code. I found myself with what could be a reasonably helpful pull request to the projects owner, but heck darn it, I did it all in master. I forgot to make a new branch for my work. How often do you do this? Every now and then.

Use a named tuple instead of a data class

Do you ever find yourself writing classes simply to organize your data. The classes don’t have any business logic. They just show that certain fields belong together. Think of a point on a two dimensional graph: A point doesn’t need to do anything, but it has an x and y that belong together. Your point class could look like this:

Machine Learning Toolkit: Installation

Want to get started with machine learning in python? In this series, We’ll show you the tools you need. We’ll go over what they all do, how to get them, and introduce their most important features. In this post we’ll go over installation, so you’ll be able to interact with the tools while you are learning about them. In the next post we’ll go over what everything actually is and how to use it. Finally, take you through the process of creating a model end to end.

Most of SQL on one page

To be honest, I don’t write SQL that often. Every time I do, it’s been so long that I’ve totally forgotten the syntax and need to relearn it. As a result, I’ve started just writing down the fundamentals so it becomes faster and faster to relearn each time. It’s actually been pretty helpful to have for me, so maybe it will be helpful to you next time you have to SQL your little heart out. Actually SQL syntax feels more elegant than I remember it.

Return an Empty List Instead of Null

Time for vegetables. In this post, we’ll discuss how to improve code style, avoid bugs, and improve clarity.

Commands For Vim Macros

In the examples below <REGISTER> can be substituted for any character on your keyboard.

Intellij Quickstart

This is a guide for quickly getting productive in Intellij. It’s a mix of the notes I took while first learning the tool, and some insights reached after extensive use of the tool. Don’t expect much talk of settings twiddling or code coverage tools.