<jupyter_start><jupyter_text>In this notebook, we replicate the setup from Brown+19 and apply PCA to the dataset as a simple feature extractor. We use a linear binary classifier to get a benchmark for the complexity classification task.<jupyter_code>import numpy
import matplotlib.pyplot as plt
import sys
sys.path.insert(1, '/home/alg010/ruby/coda/codes/')
import CodaPCA
freqs_hz = numpy.concatenate([
    numpy.arange(700e6, 1300e6, 1e6),
    numpy.arange(1500e6, 1800e6, 1e6)])
assert freqs_hz.shape == (900,)
c_mps = 299792458
wls_m2 = (c_mps / freqs_hz) ** 2<jupyter_output><empty_output><jupyter_text>$$    P(\lambda^2) = P_1 e^{2i(\chi_1 + \phi_1 \lambda^2)} + P_2 e^{2i(\chi_2 + \phi_2 \lambda^2)}$$<jupyter_code># Generate parameters for the Faraday spectra

numpy.random.seed(1)

N = 130000
size = (N, 1)
P1 = numpy.ones(size)
P2 = numpy.random.uniform(0, 1, size=size)
simple = numpy.random.randint(2, size=size, dtype=bool)
P2[simple] = 0
phi_1 = numpy.random.uniform(-50, 50, size=size)
phi_2 = numpy.random.uniform(-50, 50, size=size)
chi_1 = numpy.random.uniform(0, numpy.pi, size=size)
chi_2 = numpy.random.uniform(0, numpy.pi, size=size)
sigma = numpy.random.uniform(0, 0.333, size=size)
noise = (
    numpy.random.normal(
        scale=sigma, size=(N, len(wls_m2))) +
    numpy.random.normal(
        scale=sigma, size=(N, len(wls_m2))) * 1j)
# Then generate the spectra.
P = (
    P1 * numpy.exp(2j * (chi_1 + phi_1 * wls_m2)) +
    P2 * numpy.exp(2j * (chi_2 + phi_2 * wls_m2)))
# Finally, add noise to obtain the noisy spectra.
P_noisy = P + noise
plt.plot(wls_m2, P_noisy[2].real)
plt.plot(wls_m2, P_noisy[2].imag)
plt.plot(wls_m2, abs(P_noisy[2]), c='k')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15163934426229508, 'fraction_numerical': 0.0626463700234192, 'mean_word_length': 4.658940397350993, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '645815', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 757, 'n_tokens_neox': 701, 'n_words': 159, 'path': 'aia/pca-faraday-sim.ipynb', 'repo_name': 'MatthewJA/brushtail', 'size': '1708'}