Advertisement
Anthematics

tensorflow starter.

May 27th, 2020
721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. import functools
  2. import tensorflow as tf
  3. import numpy as np
  4. import os
  5.  
  6. train_dataset_file = open("./StarterData/1504218.csv")
  7.  
  8. CSV_COLUMNS = ['Date', 'Time', 'System Setting', 'System Mode', "Calendar Event", "Program Mode", "Cool Set Temp (F)", "Heat Set Temp (F)", "Current Temp (F)",
  9.                 "Current Humidity (%RH)", "Outdoor Temp (F)", "Wind Speed (km/h)", "Cool Stage 1 (sec)", "Heat Stage 1 (sec)", "Fan (sec)", "DM Offset", "Thermostat Temperature", "Thermostat Humidity (%RH)"]
  10. feature_names = CSV_COLUMNS[:-1]
  11. label_column = 'Current Temp (F)'
  12.  
  13. np.set_printoptions(precision=3, suppress=True)
  14.  
  15. def get_dataset(file_path, **kwargs):
  16.     dataset = tf.data.experimental.make_csv_dataset(
  17.         file_path,
  18.         batch_size=32,
  19.         label_name=label_column,
  20.         na_value="?",
  21.         num_epochs=1,
  22.         ignore_errors=True,
  23.         **kwargs)
  24.     return dataset
  25.  
  26. temp_dataset = get_dataset(train_dataset_file, column_names = CSV_COLUMNS)
  27.  
  28. def show_batch(dataset):
  29.     print('data')
  30.     for batch, label in dataset.take(1):
  31.         for key, value in batch.items():
  32.             print("{:20s} {}".format(key, value.numpy()))
  33.  
  34.  
  35. show_batch(temp_dataset)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement