0

I'm training a neural network to predict the number of views on a question based on number of answers, comments, and days passed. My data in csv file looks like that:

answers, comments, days_passed, Views

2, 5, 20, 300

From above data, I'm using first 3 columns as features and last column as label.And my file contains 3000 entries.I've modified this code to train my neural network: here

but I'm getting an error while cross-validation.That's how my code looks like:

filename_queue = tf.train.string_input_producer(["file0.csv"])

reader = tf.TextLineReader()
key, value = reader.read(filename_queue)

# Default values, in case of empty columns. Also specifies the type of the
# decoded result.
record_defaults = [[1], [1], [1], [1]]
col1, col2, col3, col4 = tf.decode_csv(value, record_defaults=record_defaults)
features = tf.stack([col1, col2, col3])

with tf.Session() as sess:
  # Start populating the filename queue.
  coord = tf.train.Coordinator()
  threads = tf.train.start_queue_runners(coord=coord)

  for i in range(3000):
    # Retrieve a single instance:
    x, y = sess.run([features, col4])

  coord.request_stop()
  coord.join(threads)
 
X_train, X_test, Y_train, Y_test = cross_validation.train_test_split(x, y, test_size=0.2, random_state=42)

I'm getting following error on the last line(cross_validation.train_test_split):

enter image description here

Community
  • 1
  • 1
Nargis
  • 739
  • 7
  • 30
  • a pastebin of the whole error would be more helpful - there is often a more sensible message at the start of the traceback – dv3 May 25 '17 at 20:56
  • @dv3 that's the whole message, just this line missing(multilayer_reg.py", line 45, in x, y, test_size=0.2, random_state=42)). I feel like problem is in x & y variables, but couldn't figure out the exact problem – Nargis May 25 '17 at 21:02
  • @dv3 by using this loop(for i in range(3000)), I'm expecting that my all features will be stored in variable 'X' and all labels in variable 'Y' but it seems like X and Y contain just 1st entry. – Nargis May 25 '17 at 21:12
  • Why don't you first split your file into Testing and Training CSVs using train_test_split and then use TF to do training on the Train file and testing on the test file? – VS_FF May 25 '17 at 21:32

0 Answers0