import pandas as pd
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt

historic = pd.read_csv("2016_2.csv", header=0) #2016_2.csv is the heavily cut version of 2016.csv
rain = pd.read_csv("2016_labels.csv", header=0)
rain2 = pd.get_dummies(rain)

rain

#as before, x contains the data of the training set. (need to decide which columns should be kept)
x = tf.placeholder(tf.float32, [None, 6])

n = 2    #numbers of days back the algo can see (not currently implemented)

#weights for the two states, percipitation vs dry (could easily add an additional state for rain vs snow)
W = tf.Variable(tf.zeros([6, 2]))
b = tf.Variable(tf.zeros([2]))

#predicted percipitation result
y = tf.nn.softmax(tf.matmul(x, W) + b)
#actual result
y_ = tf.placeholder(tf.float32, [None, 2])

cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))

train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
#The actual training is defined here. The algorithm being used is gradient descent, although this may be changed 
#depending on user preference/the task at hand. 

init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)

historic

"""
Explanation: Vanilla rain prediction
Currently this is done using only some elements of the data, super quick and dirty
End of explanation
"""


tf.reduce_sum(x)

"""
Explanation: Code from past tutorial, take from it as needed
import tensorflow as tf
x = tf.placeholder(tf.float32, [None, 784])
there are 784 pixels in any image, note that the matrix has been flattened.
'None' simply means that the number of rows in this 2d array can be anything
W = tf.Variable(tf.zeros([784, 10]))
For each of the ten digits, W contains the weights that we expect for each pixel
b = tf.Variable(tf.zeros([10]))
The bias term required to build the softmax model
y = tf.nn.softmax(tf.matmul(x, W) + b)
this is a [None,10] matrix, which gives the likelihood for every digit produced by our model
y_ = tf.placeholder(tf.float32, [None, 10])
this is the actual digit shown, used for training
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
calculating the cross-entropy of the model. The reduce_mean and reduce_sum functions do NOT perform
optimizations, but rather they simply reduce the dimensionality of the input according to certain rules.
More about these functions can be read here:
https://www.tensorflow.org/api_docs/python/math_ops/reduction#reduce_sum
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
The actual training is defined here. The algorithm being used is gradient descent, although this may be changed
depending on user preference/the task at hand.
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
this section initializes the environment, and is required to run the previously defined operations
for i in range(100000):
  batch_xs, batch_ys = mnist.train.next_batch(100)
  sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})
Here we're running the training over 1000 iterations
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))
these last few lines are simply to test the accuracy of our model
End of explanation
"""


