text_plain_output_1.png
from tensorflow.keras.layers.experimental.preprocessing import TextVectorization

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

import tensorflow as tf

data = pd.read_csv('../input/womens-ecommerce-clothing-reviews/Womens Clothing E-Commerce Reviews.csv', index_col=0)

data.shape

data = data[~data['Review Text'].isnull()]
data.shape

tf.__version__

labels = tf.keras.utils.to_categorical(data['Recommended IND'])
output_shape = labels.shape[1]
(labels, output_shape)

v_size = 4000
max_len = 100
e_dim = 64
batch_size = 256

pre_processing_layer = TextVectorization(max_tokens=v_size, output_sequence_length=max_len, name='Notes_preprocessing_layer')

pre_processing_layer.adapt(X_train)
vocab = pre_processing_layer.get_vocabulary()

model = tf.keras.models.Sequential([tf.keras.layers.Input(shape=(1,), dtype=tf.string, name='text_input'), pre_processing_layer, tf.keras.layers.Embedding(input_dim=len(vocab), output_dim=e_dim), tf.keras.layers.Masking(mask_value=0), tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(64)), tf.keras.layers.Dense(16, activation='relu'), tf.keras.layers.Dense(output_shape, activation='softmax')])
metrics = [tf.keras.metrics.CategoricalAccuracy()]
model.summary()