<jupyter_start><jupyter_text>1. Load and preprocess 1D signals<jupyter_code>import numpy as np
import matplotlib.pyplot as plt

# load one dimensional data
x = np.linspace(-np.pi, np.pi, 201)
sin_x = np.sin(x)
array_sin = [sin_x for i in range(10)]
labels = np.random.rand(10) 
plt.plot(sin_x)
import os
os.chdir(r'C:\Users\D.Albert-Weiss\Desktop\Codes\DataPreprocessing\lib')
from pipeline import Pipeline
from augmentation.augment import *

p = Pipeline(np.array(array_sin), labels, dim='2D')

augmentation = list(p.pipe([
    FlipHorizontally1D.calc,
    FlipVertically1D.calc,
    ShuffleWindows1D(2).calc,
    ]))
augmentation = np.array(augmentation).T

#extract signals and images
signals = [augmentation[0][i] for i in range(augmentation.shape[1])]
labels = [augmentation[1][i] for i in range(augmentation.shape[1])]
# Create 2x2 sub plots
gs = gridspec.GridSpec(2, 2)
gs.update(right=0.68, wspace=0.5)

plt.figure()
ax = plt.subplot(gs[0, 0]) # row 0, col 0
plt.plot(sin_x)

ax = plt.subplot(gs[0, 1]) # row 0, col 1
plt.plot(signals[0])

ax = plt.subplot(gs[1, :]) # row 1, span all columns
plt.plot(signals[20])<jupyter_output><empty_output><jupyter_text>2. Load and preprocess 2D data<jupyter_code>from tensorflow import keras

#(x_train, labels), (x_test, y_test) = keras.datasets.mnist.load_data()
(x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data()
x_train = x_train[:400]
y_train = y_train[:400]
import os
os.chdir(r'C:\Users\D.Albert-Weiss\Desktop\Codes\DataPreprocessing\lib')
from pipeline import Pipeline
from augmentation.augment import *

p = Pipeline(x_train[:400], y_train[:400], dim='2D')

#piped = list(p.pipe([Standardize().calc]))
                     #Randomize().calc
                     #Standardize().calc
                     #CropRegion(0,3).calc
#                     ]))

augmentation = list(p.pipe([
    FlipVertically2D.calc,
    FlipHorizontally2D.calc,
    RandomPuzzle(3,3).calc,
    Mixup(0.3).calc
    ]))
augmentation.shape<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14603960396039603, 'fraction_numerical': 0.03217821782178218, 'mean_word_length': 4.276762402088773, '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': '274096', 'license': 'MIT', 'n_tokens_mistral': 825, 'n_tokens_neox': 774, 'n_words': 151, 'path': 'notebooks/Data Augmentation for different data types.ipynb', 'repo_name': 'dalbertweiss/DataPreprocessing', 'size': '2020'}