import time import random from bandit import Bandit for i in range(250): print i time.sleep(0.01) with open('output-files/stuff.txt', 'wb') as f: f.write("HI!") bandit = Bandit() bandit.metadata.x = 1 bandit.metadata.y2 = 0.83 bandit.metadata.r2 = "hello!" for x in range(10): for y in range(10): for tag in ["a", "b", "c", "d", "e", "f", "g"]: bandit.report(tag, y, random.normalvariate(0, 1)) time.sleep(0.1) # email = job.Email("*****@*****.**", "This is a test email", "Hello self!") # email._write()
import pandas as pd from bandit import Bandit import time bandit = Bandit() df = pd.read_csv("./report-data.csv") for _, row in df.iterrows(): row = row.to_dict() bandit.report(row['tag_name'], row['y']) time.sleep(0.1)
# Nearest Neighbor calculation using L1 Distance # Calculate L1 Distance distance = tf.reduce_sum(tf.abs(tf.add(xtr, tf.neg(xte))), reduction_indices=1) # Prediction: Get min distance index (Nearest neighbor) pred = tf.arg_min(distance, 0) accuracy = 0. # Initializing the variables init = tf.initialize_all_variables() # Launch the graph with tf.Session() as sess: sess.run(init) # loop over test data for i in range(len(Xte)): # Get nearest neighbor nn_index = sess.run(pred, feed_dict={xtr: Xtr, xte: Xte[i, :]}) # Get nearest neighbor class label and compare it to its true label print("Test", i, "Prediction:", np.argmax(Ytr[nn_index]), \ "True Class:", np.argmax(Yte[i])) # Calculate accuracy if np.argmax(Ytr[nn_index]) == np.argmax(Yte[i]): accuracy += 1. / len(Xte) print('accuracy:', accuracy) bandit.report('Accuracty', accuracy) print("Done!") print("Accuracy:", accuracy)
# Loop over all batches for i in range(total_batch): batch_xs, batch_ys = mnist.train.next_batch(batch_size) # Run optimization op (backprop) and cost op (to get loss value) _, c = sess.run([optimizer, cost], feed_dict={ x: batch_xs, y: batch_ys }) # Compute average loss avg_cost += c / total_batch # Display logs per epoch step if (epoch + 1) % display_step == 0: print("Epoch:", '%04d' % (epoch + 1), "cost=", "{:.9f}".format(avg_cost)) bandit.report('Cost', float(avg_cost)) print("Optimization Finished!") # Test model correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1)) # Calculate accuracy accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) print("Accuracy:", accuracy.eval({ x: mnist.test.images, y: mnist.test.labels })) bandit.metadata.accuracy = float( accuracy.eval({ x: mnist.test.images,