<jupyter_start><jupyter_text>Further Exploration of AT-TPC DataNow you will have the opportunity to further explore the Argon 46 data from the AT-TPC. This will be a much more open-ended opportunity for you to play with the data and try new things.Before getting started, make sure you are using a GPU-enabled runtime in Google Colab. Go to "Runtime" $\rightarrow$ "Change runtime type", then make sure "GPU" is selected for "Hardware accelerator".  SetupThis is where you can import any Python libraries that you may want to use.<jupyter_code>import os

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import h5py

# This is simply an alias for convenience
layers = tf.keras.layers

# Prevent TensorFlow from showing us deprecation warnings
tf.logging.set_verbosity(tf.logging.ERROR)<jupyter_output><empty_output><jupyter_text>We also define some utility functions that will be helpful.<jupyter_code>def get_attpc_class(label):
    """Gets the class name for a given label.
    
    Arguments:
        label (int): The integer target label.
        
    Returns:
        The name of the class that corresponds to the given label.
    """
    return ['proton', 'carbon', 'junk'][label]

def load_attpc_data():
    """Loads in the AT-TPC data.
        
    Returns:
        A tuple of the form ((real_features, real_targets), (simulated_features, simulated_targets))
    """
    simulated_data_origin = 'https://github.com/CompPhysics/MachineLearningMSU/raw/master/Day2_materials/data/simulated-attpc-events.h5'
    real_data_origin = 'https://github.com/CompPhysics/MachineLearningMSU/raw/master/Day2_materials/data/real-attpc-events.h5'
    
    simulated_path = tf.keras.utils.get_file('simulated-attpc-data.h5', origin=simulated_data_origin)
    real_path = tf.keras.utils.get_file('real-attpc-data.h5', origin=real_data_origin)
    
    with h5py.File(simulated_path, 'r') as h5:
        simulated_features = h5['features'][:]
        simulated_targets = h5['targets'][:]
        
    with h5py.File(real_path, 'r') as h5:
        real_features = h5['features'][:]
        real_targets = h5['targets'][:]
    
    return (real_features, real_targets), (simulated_features, simulated_targets)<jupyter_output><empty_output><jupyter_text>Loading the AT-TPC dataWe load in the real and simulated AT-TPC data below.<jupyter_code>(real_features, real_targets), (simulated_features, simulated_targets) = load_attpc_data()<jupyter_output><empty_output><jupyter_text>If running this notebook on Google Colab, you will not be able to fit all 50,000 simulated events in RAM after they have been normalized. Run the cell below to use only 10,000.<jupyter_code>sim_features = sim_features[:10000]
sim_targets = sim_targets[:10000]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09287257019438445, 'fraction_numerical': 0.01331893448524118, 'mean_word_length': 4.459724950884087, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '167325', 'license': 'CC0-1.0', 'n_tokens_mistral': 899, 'n_tokens_neox': 850, 'n_words': 257, 'path': 'Day2_materials/notebooks/exploring_attpc_data.ipynb', 'repo_name': 'ndavila/MachineLearningMSU', 'size': '2778'}