=========
========= Jan 11, 2017
=========
Yet another all-nighter... what a day it was yesterday/today

For over week I was pulling my hairs out, trying to figure out the Apache Spark bug.
I was finally able to figure out how to fix,
finally! 
Usually Spark crashed after 4 hours, but not today!
===== fixing Apache Spark crashes
(If you don't care about Spark, you can skip the following block of text)
I still don't know the root cause of it (no error logs or debugging info was I able to obtain).
But in case anyone ever finds this post and has a similar issue with PySpark (version 2.2.0 or 2.2.1) then here's a short summary of the problem and how to fix it:
After several hours my Spark just got stuck on a certain job and showed 2/4, it always got stuck at the same number -- not sure if it's related but I use exactly four "foreachRDD" functions to process RDDs from a Kafka's topic through directStream. I first thought that JVM was running out of memory, or there was a memory leak in my code, or a nasty bug in PySpark itself. After having ruled out every scenario and almost getting my IP banned by Google... but in the end
he who seeketh shall find.
When I first installed Apache Spark, I followed a guide - but as usual it was quite outdated. I had installed (through pip install) a quite recent version (2.2.0), and then used the spark submit command to launch the spark driver. But what I did not pay attention to was the "spark streaming kafka package". Apparently it must match your installed Kafka's/Zookeeper's version and Spark's version. By now I had already upgraded spark to 2.2.1, so my spark submit command looks like this (pay attention to the numbers):
Code:
spark-submit --packages org.apache.spark:spark-streaming-kafka-0-8_2.11:2.2.1 yoursparkfile.py
2.2.1 is your Spark version
Then you have to search the Maven website:
https://search.maven.org/#search|ga|1|spark-streaming-kafka
and you will see "spark-streaming-kafka-0-8-assembly_
2.11". We need this one because the "...-0-10-..." is not available for PySpark (yet).
My mistake was that both the Spark version and the Maven artifact numbers were outdated (I had it set to 2.0.0 like wtf). Unfortunately this is not very well documented on Spark's website, and even the many installation tutorials you find on Google don't explain this part very well.
===== Predicting Bitcoin's price using machine learning
I've been busy toying with Keras machine learning all night until this morning.
Previously our system only took two parameters: historical hype and price.
I have now adjusted the code to use an "unlimited" number of new parameters on the fly.
So I have added positive sentiment counts, and negative sentiment counts -- now it has 4 parameters to make predictions by.
And since I had over 18 hours of consistent data (thanks to Spark), I have some nice graphs to show you:
(higher resolution image:
https://i.imgur.com/PxLvUBZ.png )
*) this is a 10-minute interval chart (the x-labels are incorrect on the image) -- every point is exactly 10min apart.
The x-axis's date and time starts at exactly: 2018-01-10 09:00am (EST timezone).
The slightly faded lines (grayish and orange ones) represent respectively from top to bottom: the BTC price, social hype, pos/neg trend.
The two latter ones don't really matter since the Y-scale is too large and I don't intend on predicting pos/neg sentiments either way.
But the hype and price are of interest to me.
I've drawn a green box to indicate which areas were generated/predicted by the machine.
And as you can see they represent a theoretical extension of the real data.
The system tells us that the hype will keep fluctuating up & down, while the price will steadily go up.
However, this prediction is purely random and I chose it because I would like to see the price increase.
In reality there are four core parameters I have to play with, and each one can have a completely different outcome in the prediction.
These are: number of hidden neurons, batch size, number of epochs and window size.
My next task is to study and learn how to find the optimal parameters, then I can make more realistic/accurate predictions.
Thanks for reading!
