This commit is contained in:
Mateusz 2024-05-16 14:30:49 +02:00
parent bf33351acc
commit 5ec1581437
3 changed files with 1363 additions and 1356 deletions

File diff suppressed because it is too large Load Diff

13
run.py
View File

@ -1,6 +1,8 @@
import pandas as pd import pandas as pd
from gensim.models import KeyedVectors from gensim.models import KeyedVectors
from sklearn.model_selection import train_test_split
import tensorflow as tf import tensorflow as tf
from keras.optimizers import Adam
import numpy as np import numpy as np
@ -41,6 +43,10 @@ def main():
[text_to_vector(text, word2vec, vector_size) for text in test_A_dataset["Text"]] [text_to_vector(text, word2vec, vector_size) for text in test_A_dataset["Text"]]
) )
train_vectors, val_vectors, train_labels, val_labels = train_test_split(
train_vectors, train_dataset["Class"], test_size=0.1, random_state=42
)
# Train a simple neural network # Train a simple neural network
model = tf.keras.Sequential( model = tf.keras.Sequential(
[ [
@ -52,15 +58,16 @@ def main():
) )
model.compile( model.compile(
optimizer="adam", optimizer=Adam(learning_rate=1e-3),
loss="binary_crossentropy", loss="binary_crossentropy",
metrics=["accuracy"], metrics=["accuracy"],
) )
model.fit( model.fit(
train_vectors, train_vectors,
train_dataset["Class"], train_labels,
epochs=10, validation_data=(val_vectors, val_labels),
epochs=30,
batch_size=16, batch_size=16,
) )

File diff suppressed because it is too large Load Diff