Welcome to the world of e-commerce, where customer feedback is a goldmine of insights! In this project, you'll dive into the Women's Clothing E-Commerce Reviews dataset, focusing on the 'Review Text' column filled with direct customer opinions.
Your mission is to use text embeddings and Python to analyze these reviews, uncover underlying themes, and understand customer sentiments. This analysis will help improve customer service and product offerings.
The Data
You will be working with a dataset specifically focusing on customer reviews. Below is the data dictionary for the relevant field:
womens_clothing_e-commerce_reviews.csv
| Column | Description |
|---|---|
'Review Text' | Textual feedback provided by customers about their shopping experience and product quality. |
Armed with access to powerful embedding API services, you will process the reviews, extract meaningful insights, and present your findings.
Let's get started!
Install useful libraries
# Run this cell to install ChromaDB if desired
try:
assert version('chromadb') == '0.4.17'
except:
!pip install chromadb==0.4.17
try:
assert version('pysqlite3') == '0.5.2'
except:
!pip install pysqlite3-binary==0.5.2
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
import chromadbLoad the dataset
Load data and perform basic data checks to ensure you are using relevant data for the analysis
# Load the dataset
import pandas as pd
reviews = pd.read_csv("womens_clothing_e-commerce_reviews.csv")
# Display the first few entries
reviews.head()# Start coding here
# Use as many cells as you need.Create Embeddings
import uuid
import chromadb
#creating connection to path
client = chromadb.PersistentClient("embeddings")Create collection
# Creating collection in ChromaDB for storing embeddings if it does not exist
collection = client.get_or_create_collection(
name="womens_collection", # Name of the collection
)
Adding to collection
# Add documents (reviews) to the ChromaDB collection
collection.add(
# Generate a unique ID for each review using uuid4
ids = [str(uuid.uuid4()) for id in reviews["Review ID"]],
# Convert each review text to string (if not already) for storage
documents = [str(review) for review in reviews["Review Text"]],
)extracting embeddings from collection
# Retrieve the existing collection named "womens_collection" from ChromaDB
collection = client.get_collection(
name="womens_collection"
)
# Peek at the first N items in the collection (where N is the number of reviews)
# and extract their embeddings into a pandas DataFrame
embeddings = collection.peek(reviews.shape[0])['embeddings']
Applying dimensionality reduction technique