<jupyter_start><jupyter_text>Conv1D reference: https://www.datatechnotes.com/2020/02/classification-example-with-keras-cnn.html<jupyter_code>import tensorflow as tf
import keras
import pandas as pd
from keras.models import Sequential
from keras.layers import Dense, Conv1D, Flatten, MaxPooling1D
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from numpy import unique
# basic structure for the CNN (parameters and layer specifications still need to be modified to fit Nasir et al., 2021)
model = Sequential()
model.add(Conv1D(64, 2, activation="relu", input_shape=(4,1)))
model.add(Dense(16, activation="relu"))
model.add(MaxPooling1D())
model.add(Flatten())
model.add(Dense(3, activation = 'softmax'))
model.compile(loss = 'sparse_categorical_crossentropy', 
     optimizer = "adam",               
              metrics = ['accuracy'])
model.summary()<jupyter_output>Model: "sequential_5"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv1d_5 (Conv1D)            (None, 3, 64)             192       
_________________________________________________________________
dense_4 (Dense)              (None, 3, 16)             1040      
_________________________________________________________________
max_pooling1d_2 (MaxPooling1 (None, 1, 16)             0         
_________________________________________________________________
flatten_2 (Flatten)          (None, 16)                0         
_________________________________________________________________
dense_5 (Dense)              (None, 3)                 51        
=================================================================
Total params: 1,283
Trainable params: 1,283
Non-trainable params: 0
____________________________________________________[...]
{'fraction_non_alphanumeric': 0.14181818181818182, 'fraction_numerical': 0.033766233766233764, 'mean_word_length': 4.068421052631579, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '39906', 'license': 'MIT', 'n_tokens_mistral': 505, 'n_tokens_neox': 450, 'n_words': 118, 'path': 'testing_stuff/Testing_Things_for_Fake_News_Classifier.ipynb', 'repo_name': 'maleepicface/brianhelenfakenews', 'size': '1925'}