text_plain_output_1.png
from keras.preprocessing.text import Tokenizer

from tensorflow.keras.preprocessing.sequence import pad_sequences

from tensorflow.keras.preprocessing.text import Tokenizer

import cudf as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

import tensorflow as tf

train_df = pd.read_csv('/kaggle/input/sentiment-analysis-on-movie-reviews/train.tsv.zip', sep='\t')
test_df = pd.read_csv('/kaggle/input/sentiment-analysis-on-movie-reviews/test.tsv.zip', sep='\t')

train_df.shape

test_df.shape

train_df.isnull().sum()

test_df.isnull().sum()

train_df.isnull().any().any()

test_df.isnull().any().any()

train = train_df.to_pandas()

test = test_df.to_pandas()

X_train = train['Phrase']
y_train = train['Sentiment']
tokenize = Tokenizer()
tokenize.fit_on_texts(X_train.values)

X_test = test['Phrase']
X_train = tokenize.texts_to_sequences(X_train)
X_test = tokenize.texts_to_sequences(X_test)

max_sequence_len = max([len(s.split()) for s in train['Phrase']])
X_train = pad_sequences(X_train, max_sequence_len, padding='pre')
X_test = pad_sequences(X_test, max_sequence_len, padding='pre')

import tensorflow as tf
embedding_dimension = 100
input_val = len(tokenize.word_index) + 1
model_ANN = tf.keras.Sequential([tf.keras.layers.Embedding(input_val, embedding_dimension, input_length=max_sequence_len), tf.keras.layers.Flatten(), tf.keras.layers.Dense(256, activation='relu'), tf.keras.layers.Dense(5, activation='softmax')])

model_ANN.summary()