I’m trying to build my own e-commerce website and in the process I’m trying to map various products from different platforms to their respective categories. I implemented a tensor flow sequential model to do the above task. I trained model with products and categories but when I give new list of products the trained model is not giving expected results. Can someone suggest an efficient way to achieve above requirement.
Hi @hanisha_nandigam, Could you please provide more context on which type of data(image, text) you are using for training the model, and what are the evaluation metrics values you have got while training and evaluating the model. Thank You.
Hi @Kiran_Sai_Ramineni , I’m using text data for training, training the model with product names and their respective categories, please find the code snippet below
category_to_index = {category: i for i, category in enumerate(set(product_categories))}
labels = [category_to_index[category] for category in product_categories]
label_encoder.fit(product_categories)
# Step 2: Text Preprocessing
tokenizer = Tokenizer(num_words=100000)
tokenizer.fit_on_texts(product_names)
sequences = tokenizer.texts_to_sequences(product_names)
word_index = tokenizer.word_index
# Pad sequences to have the same length
data = pad_sequences(sequences, maxlen=10)
# Convert labels to categorical (one-hot encoding)
num_classes = len(category_to_index)
labels = to_categorical(labels, num_classes=num_classes)
split_index = int(0.7 * len(data))
X_train, X_val = data[:split_index], data[split_index:]
y_train, y_val = labels[:split_index], labels[split_index:]