<jupyter_start><jupyter_text>Titanic File<jupyter_code>import tensorflow as tf
from tensorflow import keras
import numpy as np
titanic_file_path = tf.keras.utils.get_file("train.csv",  "https://storage.googleapis.com/tf-datasets/titanic/train.csv")
titanic_csv_ds = tf.data.experimental.make_csv_dataset(
    titanic_file_path, batch_size=5,
    label_name="survived",
    num_epochs=1,
    ignore_errors=True
)

for batch, label in titanic_csv_ds.take(1):
  for key, value in batch.items():
    print(f"{key:20s}: {value}")
  print()
  print(f"{'label':20s}: {label}")<jupyter_output>sex                 : [b'female' b'male' b'male' b'male' b'female']
age                 : [34. 24. 34. 58. 24.]
n_siblings_spouses  : [1 0 1 0 0]
parch               : [1 0 1 0 0]
fare                : [32.5     7.8958 14.4    29.7    83.1583]
class               : [b'Second' b'Third' b'Third' b'First' b'First']
deck                : [b'unknown' b'unknown' b'unknown' b'B' b'C']
embark_town         : [b'Southampton' b'Southampton' b'Southampton' b'Cherbourg' b'Cherbourg']
alone               : [b'n' b'y' b'n' b'y' b'y']

label               : [1 0 0 0 1]<jupyter_text>Decompressing on the Fly<jupyter_code>traffic_volume_csv_gz = tf.keras.utils.get_file(
    'Metro_Interstate_Traffic_Volume.csv.gz', 
    "https://archive.ics.uci.edu/ml/machine-learning-databases/00492/Metro_Interstate_Traffic_Volume.csv.gz",
    cache_dir='.', cache_subdir='traffic')
traffic_volume_csv_gz_ds = tf.data.experimental.make_csv_dataset(
    traffic_volume_csv_gz, 
    batch_size=256,
    label_name='traffic_volume',
    num_epochs=1,
    compression_type="GZIP"
)

for batch, label in traffic_volume_csv_gz_ds.take(1):
  for key, value in batch.items():
    print(f"{key:20s}: {value[:5]}")
  print()
  print(f"{'label':20s}: {label[:5]}")<jupyter_output>holiday             : [b'None' b'None' b'None' b'None' b'None']
temp                : [278.45 258.79 295.52 268.31 288.93]
rain_1h             : [0.   0.   7.54 0.   1.68]
snow_1h             : [0. 0. 0. 0. 0.]
clouds_all          : [90 63 76 90 44]
weather_main        : [b'Clouds' b'Clouds' b'Thunderstorm' b'Haze' b'Rain']
weather_description : [b'overcast clouds' b'broken clouds' b'proximity thunderstorm' b'haze'
 b'moderate rain']
date_time           : [b'2012-10-07 13:00:00' b'2013-01-03 05:00:00' b'2013-06-22 03:00:00'
 b'2013-02-26 02:00:00' b'2013-10-12 00:00:00']

label               : [6640 2383  380  229 1297]
{'fraction_non_alphanumeric': 0.14963797264682221, 'fraction_numerical': 0.083266291230893, 'mean_word_length': 2.935126582278481, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '468610', 'license': 'Apache-2.0', 'n_tokens_mistral': 1137, 'n_tokens_neox': 987, 'n_words': 189, 'path': 'Important-Notes/Batching and Shuffling Data/single_file.ipynb', 'repo_name': 'Ace5584/Machine-Learning-Notes', 'size': '2486'}