r/MLQuestions • u/midnightFreddie • Feb 27 '16
How to single-node ML lab? For text log classification.
So I've spent time this week on regex filters and field extractions for Logstash to read my log files and insert the logs and extracted fields into Elasticsearch. My application is very log-noisy and I was weeding out the "normal" errors to better identify actual issues, so I've iteratively been identifying patterns of the most common remaining log entries to end up with the more rare ones.
I showed the progress to coworkers, and one asked if machine learning could do the classification for me and free me up to better interpret the meaning. Hmmm.... So a few dozen Internet pages later...
I'm wanting to install Mahout or Spark/Mlib to kick the tires, feed it some logs and see if I can figure out what to ask next. But much of the help material on installing on a cluster. I just want to set something up on a single machine and feed it up to a gigabyte of log files and see what it I can do with it.
So am I on the right track? Can Mahout or Spark/MLib run on a single machine, or should I be looking at something else?
1
u/midnightFreddie Feb 28 '16 edited Feb 28 '16
Crickets over the weekend so far. But I got Apache Spark installed and doing a couple of simple things on a single machine, and the actual steps aren't difficult at all:
Have Java with JAVA_HOME set appropriately
Download Spark precompiled with Hadoop client
Untar the Spark tarball into a directory
Run things in the bin folder
On Windows there were some errors even though there are cmd/bat versions of the commands in bin. I think I need extra libraries. But on a bare Ubuntu 14.04 container plus Java 8 and Spark it's running with no extra steps so far.
This page has some example commands.
This section showing language classification of tweets (YouTube presentation included) is where I'm going to start my tinkering. It demonstrates tokenizing and classifying tweets into clusters that end up being more or less language collections, but I think this can do what I've been trying to manually do: classify log entry types into clusters, and then I can focus on the small clusters as rare log entry types.
I think my steps are going to be:
Use my existing Logstash field extractions against a couple of non-problem days' logs
Store that in some intermediate data store...the tweet exercise uses SQL; with my relatively small data set I'll see if I can use text dumps or just pull it back out of Elasticsearch. If those fail, MongoDb?
Featurize the log text. I may omit the timestamp and thread pool info; or try both with and without. I'll probably start with the HashingTF method as the example uses, but the Word2Vec method looks worth trying out for this purpose to my untrained eye.
Do K-Means clustering against the featurized log data
...
Profit
Well, actually then I'll see what size each cluster is and look for small-cluster or unmatched cluster (if that's a thing) against the rest of the log data.