jeudi 14 juin 2018

Learning Noise using Neural Networks

I came along this post which is dealing with stock exchange predictions https://medium.com/mlreview/a-simple-deep-learning-model-for-stock-price-prediction-using-tensorflow-30505541d877

It looks like that it performs quite well, so just out of curiosity, I wanted to test the approach against random noise. The random sequences were generated with 1)

import numpy as np
from base64 import b64encode
import random
import os
for i in range(0,1000):
 rand=os.urandom(10)
 print(str(i)+","+str(int.from_bytes(rand, byteorder='big',signed=True)))

and 2)

import numpy as np
from base64 import b64encode
import random
import os
for i in range(0,1000):
 rand=random.random()
 print(str(i)+","+str(rand))

I used the first 500 points as a training set, and the last 500 points as the test set. As a result I got for 1) after optimization MSE Train: 0.0077526495 MSE Test: 0.00782277 First Case Test set

and for 2) after optimization MSE Train: 0.0072974255 MSE Test: 0.007958689 Second Case Test set

, where the blue line is the test set and the orange line is the random number sequence. Even though I cannot exactly predict the random test case, I have the feeling that the NN still works surprisingly well. I did some googleing and I came across the following post https://www.quora.com/Can-a-neural-network-learn-a-pseudo-random-number-generater. There it states that in fact pseudo random numbers can be predicted, but it still puzzles me for multiple reasons: 1) I thought that os.urandom generates good "non-deterministic random number sequences". Is this statement false? 2) The test set of 500 points is quite small. I would have thought that also a "deterministic" random number generator could not be predicted using a NN. 3) If the random numbers which I generate are "not good", how do I generate "good" random numbers?

Maybe I encounter also another issue here which I am not aware of. I would therefore very much appreciate clarifications.

Kind Regards




Aucun commentaire:

Enregistrer un commentaire