Test your Machine Learning

In my previous post " Python Machine Learning with Presidential Tweets “, I started messing around with sklearn and text classification. Since then I’ve discovered a great tutorial from SciPy 2015 . This video starts out slow enough for novices, and a reoccurring theme is testing your datasets. After watching a good chunk of this video, I decided to go back to my code and implement a testing phase. Basically I’ll split my data into two pieces, a training set , and a testing set .

Python Machine Learning with Presidential Tweets

I’ve been spending a little bit of time researching Machine Learning , and was very happy to come across a Python library called sklearn . While digging around Google, I came across a fantastic write up on Document Classification by Zac Steward . This article went pretty deep into writing a spam filter using machine learning, and sklearn. After reading the article I wanted to try some of the concepts, but had no interest in writing a spam filter.

SensorTag data merged with Open Weather Maps

About a week ago I worked on SensorTag metrics with Grafana . This week had some interesting weather today here in Austin, and I wanted to see to visualize it as well. Luckily Open Weather Maps offers a free API for gather near real-time weather data based on city code. def __get_open_weather_data(): url_path = 'http://api.openweathermap.org/data/2.5/weather' api_key = '??????????' url = '%s?zip=73301&APPID=%s' res = requests.get(url % (url_path, api_key)) if res: if res.

Arduino meet Raspberry Pi

While at the electronics store the other day, I noticed they had motion detectors on sale for only $4. I decided with my latest obsession of electronic tinkering, picking up a OSEEP Passive Infrared Sensor (PIR) Module might be fun. I guess I should have done a little more reading on the packaging; by the time I was home, I noticed this sensor reported in analog , not digital. This was an issue as the Raspberry Pi only reads digital input.

Raspberry Pi and Official NFL Score Board API

Now that I’ve got my hands on a Raspberry Pi 3 Model B Motherboard , I decided nows a good time to play around with the 16x2 LCD Module Controller HD44780 I had laying around (I’ve had this thing since December 2015). A live NFL (National Football League) score board seemed fitting as the season just started. I found a really good write up on raspberrypi-spy.co.uk about wiring up the controller and Pi, here is the diagram I used:

SensorTag Temperature Readings in Python

I wanted to wrap up my previous post (TI SensorTag Temperature Readings ) with a little python example, thus this write is going to be short and sweet. Using the bluepy python library (written by Ian Harvey) I’ve been able to to capture temperature readings, then covert them to Fahrenheit. To demonstrate I captured a couple temperature samples, a few while sitting on my desk, and a few held up to my air condition vent:

Telegraf and missing CPU interrupts

As I’ve been playing around with Telegraf and Grafana , I’ve noticed CPU interrupts and context switches are not apart of the standard metric gathering. We know vmstat shows this information, and can be shown it in a easy processable list form: $ vmstat -s 1016888 K total memory 497920 K used memory 184412 K active memory 173296 K inactive memory 518968 K free memory 70276 K buffer memory 86416 K swap cache 522236 K total swap 88460 K used swap 433776 K free swap 18175 non-nice user cpu ticks 0 nice user cpu ticks 17799 system cpu ticks 172172 idle cpu ticks 7214 IO-wait cpu ticks 0 IRQ cpu ticks 2412 softirq cpu ticks 0 stolen cpu ticks 227755 pages paged in 986944 pages paged out 2353 pages swapped in 121572 pages swapped out 458705 interrupts 1467529 CPU context switches 1461773910 boot time 3456 forks I decided to hack together a little exec plugin for Telegraf using a Python script, running the script will get you standard out JSON:

Python traceroute style tool

Recently, while talking with a some techies I was asked to explain how traceroute works. I was quick to answer what results I expect back from the command, and how to understand that data, but for the life of me I was having issues recalling how TTL works at the foundation. Later that week I spent some time reading up on it, and click, it all came back. To reinforce this I decided to write some code.

Process Elasticsearch JSON on the shell

Lets throw security out the window for a moment. Say we store user accounts with clear text passwords in Elasticsearch , what is the easiest way to use the results in a shell script? We can begin by creating two accounts, one for admin and one for john : # curl -XPUT localhost:9200/site/people/1?pretty=True -d ' {"name": "admin", "password": "secret", "admin": "true"} ' { "_index" : "site", "_type" : "people", "_id" : "1", "_version" : 1, "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "created" : true } # curl -XPUT localhost:9200/site/people/2?

Telegraf laptop battery plugin

Wanted to expand a little on my previous blog post Custom Telegraf Plugin , and decided to do a simple battery monitor. The end result looks something like this: I decided to read from the file /sys/class/power_supply/BAT0/capacity on my Ubuntu 14.04 machine, this file merely shows the current battery percent: # cat /sys/class/power_supply/BAT0/capacity 62 All that is needed is a little Python script for converting this output to JSON, my script outputs like this: