Advertisement
Guest User

Untitled

a guest
May 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. # Import
  2. import tensorflow as tf
  3. import numpy as np
  4. import pandas as pd
  5. from sklearn.preprocessing import MinMaxScaler
  6. import matplotlib.pyplot as plt
  7.  
  8. # Import data
  9. data = pd.read_csv('tmp/01_data/data_stocks.csv')
  10. # Drop date variable
  11. data = data.drop(['DATE'], 1)
  12. # Dimensions of dataset
  13. n = data.shape[0]
  14. p = data.shape[1]
  15. # Make data a numpy array
  16. data = data.values
  17.  
  18. with tf.python_io.TFRecordWriter("csv.tfrecord") as writer:
  19. for row in data:
  20. features, label = row[1:], row[0]
  21. example = tf.train.Example()
  22. example.features.feature["features"].float_list.value.extend(features)
  23. example.features.feature["label"].float_list.value.append(label)
  24.  
  25. writer.write(example.SerializeToString())
  26.  
  27.  
  28. print ("ok")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement