Analyzing Fake Reviews with Machine Learning
Analyzing Fake Reviews with Machine Learning
INTRODUCTION
Fake reviews are not only a nuisance for consumers but also a growing
concern for companies. For legitimate businesses, fake reviews skew the actual
feedback data, making it more challenging to assess the true quality of their products
1
or services. This affects their marketing strategies, customer satisfaction analysis,
and even product development. For consumers, fake reviews lead to misguided
decisions that can result in dissatisfaction, loss of money, and potential safety risks,
especially when reviews are related to high-value products like electronics or
pharmaceuticals.
Addressing the issue of fake reviews is critical for multiple reasons. First, e-
commerce platforms and businesses depend on the authenticity of reviews to
maintain trust with their customers. Consumers' trust is paramount in the digital age,
and fake reviews erode this trust, resulting in negative impacts on the platform’s
credibility and user experience.
Second, with the increasing volume of online transactions, fake reviews are
becoming harder to detect. Automated systems that can efficiently and accurately
identify fake reviews are essential to maintaining the integrity of e-commerce. This
has sparked significant interest in developing advanced machine learning and natural
language processing techniques to automatically detect fraudulent reviews.
2
Overview of the Amazon Product Review Dataset
Amazon’s product review dataset provides a valuable resource for tackling the
fake review problem. Amazon is one of the largest e-commerce platforms in the
world, with millions of products and reviews. The dataset contains rich information
about product reviews, including the review text, the reviewer’s information, rating,
and sometimes product metadata. This dataset is publicly available and has been
widely used in various studies focused on review classification, sentiment analysis,
and fraud detection.
The dataset includes numerous features that can be used to classify reviews as
either real or fake. These features might include textual information such as the
content of the review itself, reviewer details such as frequency of reviews, product
details such as category or price, and even behavioral features such as the timing of
the reviews. By leveraging these features, machine learning models can be trained to
distinguish between genuine reviews and fraudulent ones.
For example, fake reviews often contain overly positive or excessively generic
language, as well as patterns like multiple reviews from the same user within a short
period. Such reviews can be identified through the analysis of text patterns, the
sentiment of the review, and the history of the reviewer. In contrast, genuine reviews
tend to exhibit more nuanced and context-specific language that reflects a real
consumer experience.
Furthermore, the features that distinguish real reviews from fake ones are not
always straightforward. Fake reviews may be deliberately crafted to avoid detection,
and some real reviews may exhibit patterns that are typical of fake ones. For
instance, a reviewer may leave multiple reviews in a short period for products they
have not genuinely used, which could appear suspicious but is actually a common
behavior for legitimate users. This means that false positives, where real reviews are
mistakenly flagged as fake, need to be minimized to ensure the system remains
effective.
Several approaches have been explored in recent years, each with varying
degrees of success. One of the most common algorithms used is Logistic Regression,
which works by learning the relationship between review features and the likelihood
of a review being fake. Logistic Regression is a relatively simple but effective
technique, especially when combined with feature engineering.
4
Another promising approach is ensemble methods, such as Random Forest and
Decision Trees. These models combine multiple decision paths to make more
accurate predictions. Random Forest, for example, builds many decision trees and
aggregates their results to reduce overfitting and increase generalization, making it
more robust than a single decision tree.
1.2 Objectives:
● Create and implement a fake review analysis model using Logistic Regression
and a hybrid Decision Tree (DT) + Random Forest approach to classify the
review into fake or real categories.
● Assess the accuracy, precision, recall, and F1-score of the LR and hybrid DT +
5
● Analyze and address the challenges associated with the informal, nuanced, and
● Compare the effectiveness of the hybrid DT + RF model with the LR model and
CHAPTER 2
SYSTEM PROPOSAL
2.1.1 DISADVANTAGES:
to potential misclassifications.
● Require extensive manual effort to create and maintain lexicons and rules.
● May struggle with very large datasets, leading to longer training times and
decreased efficiency.
● Assumes that features are independent of each other, which is often not true in
7
The proposed system aims to address the pervasive issue of fake product and
service reviews on e-commerce platforms, particularly focusing on the Amazon
product review dataset. In the context of e-commerce, where reviews play a critical
role in influencing consumer decisions, the need for a reliable and efficient system to
detect and eliminate fake reviews is essential. The system is designed to
automatically classify reviews as either "real" or "fake" using advanced machine
learning algorithms, ensuring that only authentic and trustworthy feedback remains
accessible to consumers. At the core of the proposed system are three machine
learning models: Logistic Regression, a hybrid model combining Decision Tree and
Random Forest, and an additional classification technique, such as Support Vector
Machine (SVM) or Naive Bayes. These algorithms are selected due to their
robustness in classification tasks and their ability to process large datasets
effectively. Logistic Regression is employed for its simplicity and efficiency in
binary classification tasks, where reviews are classified as fake or real based on
various extracted features. The Decision Tree and Random Forest hybrid model is
introduced to leverage the advantages of ensemble learning, providing higher
accuracy and better generalization capabilities. By combining individual decision
trees, the model reduces the risk of overfitting, which is a common problem in
machine learning models that deal with complex datasets. The system extracts a
variety of features from the dataset to train these models, including review text,
reviewer history, product metadata, and behavioral patterns. For instance, textual
features from the reviews are analyzed using natural language processing (NLP)
techniques to detect anomalies in writing style, sentiment, and structure, which are
typical of fake reviews. Features such as overly generic phrases, excessively positive
or negative language, and repetitive patterns can signal fraudulent content. Reviewer
history is another crucial feature, as fake reviewers often exhibit unusual patterns,
such as posting multiple reviews within a short time frame or leaving reviews for
products they have never purchased. Product metadata, including product category,
price, and brand, is also used to identify suspicious patterns, such as a large number
8
of overly positive reviews for low-priced or less popular products, which may
indicate a coordinated effort to manipulate the ratings. Once the features are
extracted and the models are trained, the system processes incoming reviews in real
time, flagging those that are predicted to be fake. Reviews flagged as fake are
automatically removed or quarantined for further manual review, ensuring that only
legitimate feedback is displayed to consumers. The system is designed to
continuously improve through retraining, allowing it to adapt to new tactics used by
fraudsters and ensuring long-term effectiveness in identifying fake reviews.
Additionally, the models are evaluated using performance metrics such as precision,
recall, F1 score, and accuracy, to ensure that the system minimizes false positives
(real reviews flagged as fake) while maximizing the detection of actual fake reviews.
2.2.1 ADVANTAGES:
9
2.2 LITERATURE SURVEY:
Methodology:
We study the market for fake product reviews on [Link]. Reviews are
purchased in large private groups on Facebook and other sites. We hand-collect data
on these markets and then collect a panel of data on these products’ ratings and
reviews on Amazon, as well as their sales rank, advertising, and pricing policies. We
find that a wide array of products purchase fake reviews, including products with
many reviews and high average ratings. Buying fake reviews on Facebook is
associated with a significant but short-term increase in average rating and number of
reviews. We exploit a sharp but temporary policy shift by Amazon to show that
rating manipulation has a large causal effect on sales. Finally, we examine whether
rating manipulation harms consumers or whether it is mainly used by high-quality
products in a manner like advertising or by new products trying to solve the cold-
start problem. We find that after firms stop buying fake reviews, their average
ratings fall and the share of one-star reviews increases significantly, particularly for
young products, indicating rating manipulation is mostly used by low-quality
products.
Advantages:
● Prediction is accurate.
Disadvantage:
10
2. Title: Fake Reviews Detection: A Survey, 2021
Methodology:
In e-commerce, user reviews can play a significant role in determining the revenue
of an organisation. Online users rely on reviews before making decisions about any
product and service. As such, the credibility of online reviews is crucial for
businesses and can directly affect companies’ reputation and profitability. That is
why some businesses are paying spammers to post fake reviews. Consequently, the
techniques for detecting fake reviews have extensively been explored in the past
twelve years. However, there still lacks a survey that can analyse and summarise the
existing approaches. To bridge up the issue, this survey paper details the task of fake
review detection, summing up the existing datasets and their collection methods. It
analyses the existing feature extraction techniques. Further, we conduct a benchmark
study to investigate the performance of different neural network models and
transformers that have not been used for fake review detection yet. The experimental
results on two benchmark datasets show that RoBERTa performs about 7% better
than the state-of-the-art methods in a mixed domain for the deception dataset with
the highest accuracy of 91.2%, which can be used as a baseline for future studies.
Finally, we highlight the current gaps in this research area and the possible future
directions.
Advantages:
11
● Furthermore, Hand annotated techniques need many human resources, and
Disadvantage:
Advantages:
Disadvantages:
13
terms of selecting services that meet their needs. Furthermore, there is high impact
for researchers in terms of prospective research directions.
Advantages:
Disadvantages:
● Less accurate
14
The results show that the f-score has increased by 3.80% when taking the extracted
reviewers behavioral features into consideration.
Advantages:
features that reflect the reviewers’ behaviors. These features will highly
influence the effectiveness of the fake reviews detection process.
Disadvantage:
Year: 2023
Methodology: This study proposes using sentiment analysis to detect fake reviews
by examining the emotional tone and sentiment consistency in reviews. The authors
apply sentiment classification models like BERT and GPT to analyze the sentiment
polarity of reviews and identify suspicious reviews with contradictory sentiment.
The research shows that fake reviews often exhibit extreme sentiment or mixed
emotional tones, which can be detected with high accuracy using sentiment analysis
tools.
Demerits: Sentiment analysis may not always detect nuanced or subtle fake reviews
that maintain a neutral or balanced tone.
15
CHAPTER 3
SYSTEM DIAGRAMS
Use Case
Actor
Control flow
Decision Start
Start Node
End State
Action state
List of Symbols
16
3.1 SYSTEM ARCHITECTURE:
The architecture diagram outlines the workflow for processing and classifying fake
review analysis dataset. Data Selection involves acquiring the dataset. Data
Preprocessing handles missing values and label encoding. Text Preprocessing
includes cleaning and standardizing text through stop words removal, stemming, and
tokenization. The cleaned text is then converted into numerical format using
Vectorization. The data is Split into training and test sets. Classification models,
such as Logistic Regression and a hybrid of Decision Tree and Random Forest, are
17
trained and evaluated. Result Generation computes performance metrics, and
Prediction applies the trained models to classify new data, providing difficulty level
insights.
The flow diagram presents the sequential process for fake review analysis dataset
classification. It starts with Data Selection, where the dataset is sourced. Data
18
Preprocessing follows, addressing missing values and encoding labels. Next, Text
Preprocessing cleans and standardizes the text. The processed text undergoes
Vectorization to convert it into numerical format. The data is then Split into training
and test sets. In the Classification phase, models like LR and a hybrid of Decision
Tree and RF are trained and evaluated. Result Generation calculates performance
metrics, and Prediction uses the models to classify new inputs, providing insights
into fake review levels.
In the Data Flow Diagram (DFD) Level 0, the Data Selection phase involves
acquiring relevant datasets from repositories or sources, which are then input into the
system. This is followed by Data Preprocessing, where the raw data undergoes
cleaning and transformation processes to handle missing values, standardize formats,
and prepare it for further analysis. The diagram outlines the flow from data
acquisition through preprocessing, ensuring that the data is accurately prepared for
subsequent stages of processing and analysis.
19
3.3.2 Level 1:
In the Data Flow Diagram (DFD) Level 1, the Data Selection process retrieves and
imports datasets from various sources into the system. This data is then subjected to
Data Preprocessing, which involves handling missing values, encoding labels, and
other preparatory tasks to ensure data quality. Following this, Text Preprocessing is
applied, including text cleaning steps like tokenization, removing stop words, and
stemming, to prepare the data for analysis. This diagram illustrates the sequential
flow of data through these stages, ensuring it is refined and ready for the next phases
of processing.
20
3.3.3 Level 2:
In the Data Flow Diagram (DFD) Level 2, the workflow starts with Data Selection,
where relevant datasets are gathered. The data then moves through Data
Preprocessing, addressing issues such as missing values and label encoding. Text
Preprocessing follows, including tasks like tokenization, stemming, and stop words
removal. Next, Vectorization converts text into numerical format for analysis. The
data is then Split into training and testing sets. Classification models are trained and
evaluated using these sets. Finally, Result Generation calculates performance
metrics, and Prediction provides insights based on the trained models, completing
the end-to-end process.
21
3.4 UML DIAGRAMS:
The goal is for UML to become a common language for creating models of object
oriented computer software. In its current form UML is comprised of two major
components: a Meta-model and a notation. In the future, some form of method or
process may also be added to; or associated with, UML.
The UML represents a collection of best engineering practices that have proven
successful in the modelling of large and complex systems. The UML is a very
important part of developing objects oriented software and the software development
process. The UML uses mostly graphical notations to express the design of software
projects.
GOALS:
Use-case diagrams describe the high-level functions and scope of a system. These
diagrams also identify the interactions between the system and its actors. The use
cases and actors in use-case diagrams describe what the system does and how the
actors use it, but not how the system operates internally.
A use case is a list of actions or event steps typically defining the interactions
between a role (known in the Unified Modelling Language (UML) as an actor) and a
system to achieve a goal. The actor can be a human or other external system.
Notations:
● Use cases: Horizontally shaped ovals that represent the different uses that a user
might have.
● Actors: Stick figures that represent the people actually employing the use cases.
● System boundary boxes: A box that sets a system scope to use cases. All use
cases outside the box would be considered outside the scope of that system. For
example, Psycho Killer is outside the scope of occupations in the chainsaw
example found below.
23
● Packages: A UML shape that allows you to put different elements into groups.
Just as with component diagrams, these groupings are represented as file folders.
24
Prediction. The diagram highlights how users engage with various components to
achieve accurate and insightful text classification.
Action State: An action state represents the execution of an atomic action, typically
the invocation of an operation. An action state is a simple state with an entry action
whose only exit transition is triggered by the implicit event of completing the
execution of the entry action.
Final state: A final state represents the last or "final" state of the enclosing
composite state. There may be more than one final state at any level signifying that
the composite state can end in different ways or conditions.
When a final state is reached and there are no other enclosing states it means that the
entire state machine has completed its transitions and no more transitions can occur.
25
Decision: A state diagram (and by derivation an activity diagram) expresses decision
when guard conditions are used to indicate different possible transitions that depend
on Boolean conditions of the owning object.
The activity diagram outlines the workflow for classifying fake review text data. It
begins with Data Selection and progresses through Data Preprocessing to handle
missing values and encode labels. The next steps involve Text Preprocessing,
including cleaning and tokenization, followed by Vectorization to convert text into
numerical format. The data is then Split into training and test sets. Model Training
and Evaluation follow, using algorithms like LR and hybrid models. Finally,
26
Prediction generates results and Performance Metrics are computed to assess the
system's accuracy and effectiveness.
Object: Objects are instances of classes, and are arranged horizontally. The pictorial
representation for an Object is a class (a rectangle) with the name prefixed by the
object.
Lifeline The Lifeline identifies the existence of the object over time. The notation
2for a Lifeline is a vertical dotted line extending from an object.
27
FIGURE 3.4.3: SEQUENCE DIAGRAM
28
Trains and Evaluates classification models, such as LR and hybrid models. Finally,
Predictions are generated and Results are returned to the user. The diagram
illustrates the flow of data and the sequence of operations for effective text
classification.
3.4.4 ER DIAGRAM:
ER Diagrams are most often used to design or debug relational databases in the
fields of software engineering, business information systems, education and research.
Also known as ERDs or ER Models, they use a defined set of symbols such as
rectangles, diamonds, ovals and connecting lines to depict the interconnectedness of
entities, relationships and their attributes.
They mirror grammatical structure, with entities as nouns and relationships as verbs.
Notation:
Entity
Entity type: A group of definable things, such as students or athletes, whereas the
entity would be the specific student or athlete. Other examples: customers, cars or
products.
29
Entity set: Same as an entity type, but defined at a particular point in time, such as
students enrolled in a class on the first day.
Other examples: Customers who purchased last month, cars currently registered in
Florida. A related term is instance, in which the specific person or car would be an
instance of the entity set.
Entity keys: Refers to an attribute that uniquely defines an entity in an entity set.
Entity keys can be super, candidate or primary. Super key: A set of attributes (one
or more) that together define an entity in an entity set.
Candidate key: A minimal super key, meaning it has the least possible number of
attributes to still be a super key. An entity set may have more than one candidate
key. Primary key: A candidate key chosen by the database designer to uniquely
identify the entity set. Foreign key: Identifies the relationship between entities.
Relationship
How entities act upon each other or are associated with each other. Think of
relationships as verbs.
The two entities would be the student and the course, and the relationship depicted is
the act of enrolling, connecting the two entities in that way.
30
FIGURE 3.4.4: ER DIAGRAM
The ER diagram outlines the relationships between entities in the fake review
classification system. It includes entities such as Dataset, Preprocessed Text, Model,
and User. The diagram shows how the Dataset is linked to Preprocessed Text
through data transformation processes. Models are associated with Preprocessed
31
Text to perform classification tasks. The User interacts with the system to provide
input and receive Classification Results. The ER diagram illustrates how these
entities are connected and how data flows between them to support the classification
process.
Class diagrams identify the class structure of a system, including the properties and
methods of each class. Also depicted are the various relationships that can exist
between classes, such as an inheritance relationship.
Part of the popularity of Class diagrams stems from the fact that many CASE tools,
such as Rational XDE, will auto-generate code in a variety of languages, these tools
can synchronize models and code, reducing the workload, and can also generate
Class diagrams from object-oriented code.
Graphical Notation: The elements on a Class diagram are classes and the
relationships between them.
The top section is name of class; the middle section defines the properties of class.
The bottom section list the methods of the class.
This line can be qualified with the type of relationship, and can also feature
multiplicity rule (e.g. one-to-one, one-to-many, many-to-many) for the relationship.
32
FIGURE 3.4.5: CLASS DIAGRAM
The class diagram illustrates the structure of the fake product review classification
system by detailing its core classes and their relationships. Key classes include Data
Handler, responsible for managing dataset loading and preprocessing, Text
Processor, which handles text cleaning and tokenization, and Vectorizer, which
33
transforms text into numerical vectors. Model Trainer and Model Evaluator are
tasked with training and evaluating classification models, such as LR and hybrid
models. The Prediction Engine generates classification results based on the trained
models. The diagram highlights the attributes and methods of each class and their
interactions to achieve the system’s objectives.
34
CHAPTER 4
IMPLEMENTATION
4.1 MODULES:
• Data Selection
• Data Preprocessing
• Text Preprocessing
• Vectorization
• Data Splitting
• Classification
• Result Generation
• Prediction
• The data for this study is sourced from the fake product review dataset
available on Kaggle.
• This dataset contains user comments along with corresponding ratings and
categories, which are essential for understanding user review analysis.
• Here we can fetch or read or load the collected data by using the panda’s
packages.
35
• Our dataset, is in the form of ‘.csv’ file extension.
● Data preprocessing is a crucial step to ensure the dataset is clean and ready for
analysis.
mode) or removal of records with missing values are employed to handle these
gaps in the data.
techniques.
36
● But for our vectorizer which counts the number of words and not the context,
it does not add value, so we remove all special characters. eg: How are you?-
>How are you.
● Remove stopwords: Stopwords are common words that will likely appear in
any text. They don’t tell us much about our data so we remove them. e.g.:
silver or lead is fine for me-> silver, lead, fine.
● Stemming: Stemming helps reduce a word to its stem form. It often makes
sense to treat related words in the same way. It removes suffices, like “ing”,
“ly”, “s”, etc. by a simple rule-based approach.
4.2.4: VECTORIZATION:
count vectorization.
create feature vectors so that machine learning algorithms can understand our
data.
● Both are methods for converting text data into vectors as model can process
by a column of the matrix, and each text sample from the document is a row in
the matrix.
● The value of each cell is nothing but the count of the word in that particular
37
text sample.
● This technique converts the text into a matrix of token counts. Each word in
the text is represented as a feature, and the frequency of each word in the text
is captured in the matrix.
● This helps in transforming textual data into a form suitable for machine
learning algorithms.
● During the machine learning process, data are needed so that learning can take
place.
● In addition to the data required for training, test data are needed to evaluate the
● In our process, we considered 70% of the input dataset to be the training data and
● Data splitting is the act of partitioning available data into two portions, usually
● One Portion of the data is used to develop a predictive model and the other to
● Separating data into training and testing sets is an important part of evaluating
38
● Typically, when you separate a data set into a training set and testing set, most of
the data is used for training, and a smaller portion of the data is used for testing.
4.2.6: CLASSIFICATION:
• The voting classifier aggregates the predictions from each model to make a
final decision. This approach leverages the strengths of each individual model
to improve overall performance.
How It Works
39
generating multiple subsets of the training data through random sampling with
replacement. Each subset is used to train a separate decision tree.
● Feature Randomness: For each decision tree, a random subset of features is
considered when splitting nodes, which introduces diversity among the trees
and reduces overfitting. This randomness helps in making the model more
generalizable to new data.
● Decision Trees Construction: Each decision tree in the forest is built using a
different subset of the data and features. The depth of these trees is usually
unrestricted, allowing them to grow until they reach a stopping criterion or are
fully developed.
● Voting/Averaging: For classification tasks, the final prediction is determined
by majority voting among the trees. For regression tasks, it is the average of
the predictions from all trees.
Advantages
40
A Decision Tree is a supervised machine learning algorithm used for classification
and regression tasks. It models decisions and their possible consequences in a tree-
like graph, where each internal node represents a decision based on a feature, each
branch represents the outcome of the decision, and each leaf node represents a class
label (for classification) or a continuous value (for regression). The algorithm's
simplicity and interpretability make it a popular choice for many machine learning
problems.
How It Works
o Root Node: Represents the entire dataset and is split into two or more
homogeneous sets.
o Internal Nodes: Represent features or attributes of the dataset. Each
node splits the data based on a decision rule.
o Branches: Represent the outcome of the decision rules, leading to child
nodes.
o Leaf Nodes: Represent the final outcome or prediction, which can be a
class label in classification tasks or a continuous value in regression
tasks.
● Splitting Criteria: The decision to split a node is based on criteria that
maximize the separation of the classes or minimize the error in predictions.
Common criteria include:
o Gini Index: Measures the impurity of a node. Lower values indicate
purer nodes.
o Entropy and Information Gain: Entropy measures the disorder in the
data, and Information Gain measures the reduction in entropy due to a
split.
41
o Mean Squared Error (MSE): Used for regression tasks, measuring the
variance within the node.
● Tree Construction: The tree is built using a recursive process called recursive
partitioning. Starting from the root node, the dataset is split based on the best
criterion, and this process continues recursively for each child node until a
stopping criterion is met, such as a maximum depth or minimum number of
samples per leaf.
Advantages
42
How It Works
Advantages
43
● Efficiency: Computationally efficient and fast to train, making it suitable for
large datasets.
● No Assumptions on Distribution: Unlike some other algorithms, Logistic
Regression does not require assumptions about the distribution of the input
features.
● Feature Selection: Can be regularized to prevent overfitting and select
important features, especially with techniques like L1 regularization (Lasso).
The Final Result will get generated based on the overall classification and prediction.
The performance of this proposed approach is evaluated using some measures like,
● Accuracy
Accuracy of classifier refers to the ability of classifier. It predicts the class label
correctly and the accuracy of the predictor refers to how well a given predictor can
guess the value of predicted attribute for a new data.
AC= (TP+TN)/ (TP+TN+FP+FN)
● Precision
● Recall
Recall is the number of correct results divided by the number of results that
should have been returned. In binary classification, recall is called sensitivity. It can
be viewed as the probability that a relevant document is retrieved by the query.
44
Recall=TP/ (TP+FN)
4.2.8 Prediction:
● After training and evaluating the models, the system is used to predict user’s
into user input review and enabling the development of personalized content
strategies.
45
CHAPTER 5
SYSTEM REQUIREMENTS
5.1 HARDWARE REQUIREMENTS:
● Mouse : Logitech.
● Ram : 4GB
● Language : Python
● Framework : STREAMLIT
5.3.1 Python
46
Python is one of those rare languages which can claim to be both simple and
powerful. You will find yourself pleasantly surprised to see how easy it is to
concentrate on the solution to the problem rather than the syntax and structure of the
language you are programming in. The official introduction to Python is Python is an
easy to learn, powerful programming language. It has efficient high-level data
structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many
areas on most platforms. I will discuss most of these features in more detail in the
next section.
● Simple
● Easy to Learn
As you will see, Python is extremely easy to get started with. Python has an
extraordinarily simple syntax, as already mentioned.
● High-level Language
When you write programs in Python, you never need to bother about the low-
level details such as managing the memory used by your program, etc.
● Portable
Due to its open-source nature, Python has been ported to (i.e. changed to make
it work on) many platforms. All your Python programs can work on any of these
platforms without requiring any changes at all if you are careful enough to avoid any
system-dependent features.
You can even use a platform like Kivy to create games for your computer and
for iPhone, iPad, and Android.
● Interpreted
48
you run the program, the linker/loader software copies the program from hard disk to
memory and starts running it.
Python, on the other hand, does not need compilation to binary. You just run
the program directly from the source code. Internally, Python converts the source
code into an intermediate form called bytecodes and then translates this into the
native language of your computer and then runs it. All this, actually, makes using
Python much easier since you don't have to worry about compiling the program,
making sure that the proper libraries are linked and loaded, etc. This also makes your
Python programs much more portable, since you can just copy your Python program
onto another computer and it just works!
● Object Oriented
● Extensible
If you need a critical piece of code to run very fast or want to have some piece
of algorithm not to be open, you can code that part of your program in C or C++ and
then use it from your Python program.
49
● Embeddable
You can embed Python within your C/C++ programs to give scripting
capabilities for your program's users.
● Extensive Libraries
The Python Standard Library is huge indeed. It can help you do various things
involving regular expressions, documentation generation, unit testing, threading,
databases, web browsers, CGI, FTP, email, XML, XML-RPC, HTML, WAV files,
cryptography, GUI (graphical user interfaces), and other system-dependent stuff.
Remember, all this is always available wherever Python is installed. This is called
the Batteries Included philosophy of Python.
Besides the standard library, there are various other high-quality libraries
which you can find at the Python Package Index.
Streamlit is an open-source Python library that makes it easy to create and share
beautiful, custom web apps for machine learning and data science. It allows you to
build interactive web applications straight from Python scripts. Here are some of the
key features and concepts related to Streamlit:
Key Features
● Ease of Use: Streamlit enables you to create web applications by writing only
Python code. You don’t need any HTML, CSS, or JavaScript knowledge.
50
● Real-time Interactivity: Streamlit apps can automatically update as users interact
● Widgets: Streamlit provides a variety of widgets to collect user input and make
● Deployment: Streamlit apps can be deployed easily on the web through services
Basic Concepts
● Script Execution: Streamlit runs your entire script from top to bottom each time
you interact with a widget, which means the state of your app is reset each time
unless you use caching.
● Widgets: Widgets like sliders, text inputs, buttons, and checkboxes allow users to
provide input.
● Layout: You can organize the layout of your app using layout primitives like
Introduction to SQLite :
SQLite
History:
It was designed by D. Richard Hipp for the purpose of no administration required for
operating a program. In August 2000. As it is very lightweight compared to others
like MySql and Oracle, it is called SQLite. Different versions of SQLite are released
since 2000.
Features of SQLite
3. All the features of SQL are implemented in it with some additional features
like partial indexes, indexes on expressions, JSON, and common table
expressions.
6. Almost all OS supports SQLite like Android, BSD, iOS, Linux, Mac, Solaris,
VxWorks, and Windows (Win32, WinCE, etc. It is very much easy to port to
other systems.
Applications of SQLite
52
1. Due to its small code print and efficient usage of memory, it is the popular
choice for the database engine in cell phones, PDAs, MP3 players, set-top
boxes, and other electronic gadgets.
Testing is vital to the success of the system. System testing makes a logical
assumption that if all parts of the system are correct, the goal will be successfully
achieved. . A series of tests are performed before the system is ready for the user
acceptance testing. Any engineered product can be tested in one of the following
ways. Knowing the specified function that a product has been designed to from,
test can be conducted to demonstrate each function is fully operational. Knowing
the internal working of a product, tests can be conducted to ensure that “al gears
mesh”, that is the internal operation of the product performs according to the
specification and all internal components have been adequately exercised.
Data can be lost across an interface, one module can have an adverse
effect on the other sub function, when combined, may not produce the desired
major function. Integrated testing is systematic testing that can be done with
sample data. The need for the integrated test is to find the overall system
performance. There are two types of integration testing. They are:
i) Top-down integration testing.
ii) Bottom-up integration testing.
White Box testing is a test case design method that uses the control structure
of the procedural design to drive cases. Using the white box testing methods, we
54
Derived test cases that guarantee that all independent paths within a module have
been exercised at least once.
2. Interface error
4. Performance errors.
VALIDATION TESTING:
55
After the culmination of black box testing, software is completed assembly
as a package, interfacing errors have been uncovered and corrected and final series
of software validation tests begin validation testing can be defined as many,
But a single definition is that validation succeeds when the software functions in a
manner that can be reasonably expected by the customer
User acceptance of the system is the key factor for the success of the system.
The system under consideration is tested for user acceptance by constantly keeping
in touch with prospective system at the time of developing changes whenever
required.
OUTPUT TESTING:
After performing the validation testing, the next step is output asking the
user about the format required testing of the proposed system, since no system
could be useful if it does not produce the required output in the specific format. The
output displayed or generated by the system under consideration. Here the output
format is considered in two ways. One is screen and the other is printed format.
The output format on the screen is found to be correct as the format was designed
in the system phase according to the user needs. For the hard copy also output
comes out as the specified requirements by the user. Hence the output testing does
not result in any connection in the system.
56
● Description: Test the system's ability to handle and impute missing values in the
dataset.
● Expected Outcome: The system should correctly identify and handle missing
● Rationale: Ensures that missing values do not adversely affect the preprocessing
or training process.
Test Case 2: Label Encoding Verification
● Expected Outcome: Labels are correctly converted into numeric values (e.g., 0
● Rationale: Ensures that the conversion from string labels to numeric values is
● Description: Test the removal of stop words from the text data.
● Input: Text containing common stop words (e.g., "the", "is", "and").
● Expected Outcome: Stop words should be removed from the text, resulting in
intended.
data.
"runner").
● Expected Outcome: Words should be reduced to their root forms (e.g., "run").
● Input: Sample text data and the corresponding count vectorized output.
● Description: Validate the splitting of data into training and test sets.
58
● Input: A dataset of text and labels.
● Expected Outcome: The dataset should be correctly split into separate training
● Rationale: Ensures that the data splitting process is performed correctly and
● Expected Outcome: The hybrid model should be able to train effectively, and
59
Test Case 9: Sentiment Prediction Accuracy
user input.
● Input: Sample user input with known sentiment (e.g., "I love this product!"
for fake).
fake or real.
60
CHAPTER 6
CONCLUSION
In conclusion, the proposed system for detecting and deleting fake product and
service reviews from e-commerce platforms, particularly utilizing the Amazon
product review dataset, aims to significantly enhance the credibility and
trustworthiness of online reviews. By leveraging advanced machine learning
algorithms such as Logistic Regression, hybrid models combining Decision
Trees and Random Forest, and additional classification techniques, the system
offers a robust and scalable solution to identify and filter out fraudulent reviews.
Through the extraction of key features like review text, reviewer behavior, and
product metadata, the system is able to detect subtle patterns indicative of fake
reviews, ensuring that only genuine consumer feedback remains visible to
prospective buyers. The impact of this system extends beyond just improving
consumer decision-making; it also fosters a more transparent and fair e-
commerce environment by preventing the manipulation of product ratings. For
businesses, this translates to more accurate customer insights, enabling better
product development and marketing strategies based on authentic feedback.
Furthermore, the ability of the system to scale with large datasets and adapt to
emerging fraud tactics ensures its long-term effectiveness in maintaining the
integrity of online reviews. As e-commerce continues to grow, the need for
reliable review systems will only intensify. The implementation of such
machine learning-based solutions is essential not only for protecting consumers
from deceptive practices but also for promoting a trustworthy and ethical online
marketplace. Ultimately, the proposed system plays a critical role in restoring
consumer confidence, ensuring that online reviews fulfill their true purpose—
helping customers make informed, confident purchasing decisions.
61
CHAPTER 7
FUTURE ENHANCEMENT
While the proposed system offers a strong foundation for detecting and
removing fake reviews, there are several avenues for future work that could
further enhance its effectiveness and scope. One potential area for improvement
is the incorporation of more advanced natural language processing (NLP)
techniques, such as deep learning-based models, including transformers and
neural networks, to better understand the nuanced language used in fake
reviews. These models could help identify more sophisticated tactics employed
by fraudsters, such as the use of fake profiles or the generation of review
content by AI systems. Integrating sentiment analysis and contextual
understanding of reviews could also provide a deeper layer of classification,
distinguishing between genuine negative reviews from fake ones designed to
sabotage competitors. Another promising direction is the integration of
multimodal data beyond just textual content. This could involve analyzing other
types of data, such as image or video content associated with reviews, which
may also reveal patterns indicative of fraud. For example, fake reviews often
come with stock images or unrealistic product photos, which could be detected
through image recognition models. Similarly, expanding the system to evaluate
the social network of reviewers—such as connections between review accounts
—could help flag coordinated fake review campaigns, often orchestrated
through fake social media profiles or fake review farms. Moreover, the system
could benefit from continuous learning, where models are updated regularly
with new data to adapt to emerging fraud techniques. This could involve
implementing an active learning framework, where the system not only detects
fake reviews but also learns from new patterns of fraud as they emerge,
ensuring it stays relevant in a rapidly evolving landscape.
62
CHAPTER 8
SAMPLE CODING
# ====================== IMPORT PACKAGES ==============
import pandas as pd
import time
import os
import numpy as np
import warnings
[Link]("ignore")
63
dataframe=pd.read_csv("fake reviews [Link]")
print("--------------------------------")
print("Data Selection")
print("--------------------------------")
print()
print([Link](15))
print("----------------------------------------------------")
print("----------------------------------------------------")
print()
print([Link]().sum())
64
res = [Link]().sum().any()
if res == False:
print("--------------------------------------------")
print("--------------------------------------------")
print()
else:
print("--------------------------------------------")
print("--------------------------------------------")
print()
dataframe = [Link](0)
resultt = [Link]().sum().any()
65
if resultt == False:
print("--------------------------------------------")
print("--------------------------------------------")
print()
print([Link]().sum())
print("--------------------------------")
print("--------------------------------")
df_class=dataframe['label']
df_class_lab=dataframe['label'].unique()
66
import pickle
[Link](df_class_lab, f)
print(dataframe['label'].head(15))
print("--------------------------------")
print("--------------------------------")
label_encoder = [Link]()
dataframe['label']=label_encoder.fit_transform(dataframe['label'])
print(dataframe['label'].head(15))
CHAPTER 9
SCREENSHOTS
67
68
69
70
71
72
73
74
75
76
CHAPTER 10
REFERENCES
1. Castillo c., Donato D., "A reference collection for web spam", SIGIR Forum
2006, 40(2), ppll-24.
2. Wang, Guan, Sihong Xie, Bing Liu, and Philip S. Yu., "Identify Online Store
Review Spammers via Social Review Graph", ACM Transactions on
Intelligent Systems and Technology, 2012.
3. Sun, Huan, Alex Morales, and Xifeng Yan., "Synthetic review spamming
and defense", Proceedings of the 19th ACM SIGKDD international
conference on Knowledge discovery and data mining - KDD 13, 2013.
4. Sharma, Kuldeep, and King-Ip Lin., "Review spam detector with rating
consistency check", Proceedings of the 51st ACM Southeast Conference on -
ACMSE 13, 2013.
5. Xu, Chang, "Detecting collusive spammers in online review communities",
Proceedings of the sixth workshop on Ph D students in information and
knowledge management - PIKM 13, 2013.
6. Lau, Raymond Y. K., S. Y. Liao, Ron Chi-Wai Kwok,Kaiquan Xu, Yunqing
Xia, and Yuefeng Li. "Text mining and probabilistic language modeling for
online review spam detection", ACM Transactions on Management
Information Systems, 2011.
7. Liu, Y. Cao, C.-Y. Lin, Y. Huang, and M. Zhou, "Low-quality product
review detection in opinion summarization", In EMNLP-CoNLL, 2007.
8. Xie, Sihong, Guan Wang, Shuyang Lin, and Philip S. Yu. "Review spam
detection via temporal pattern discovery", Proceedings of the 18th ACM
SIGKDD international conference on Knowledge discovery and data mining
- KDD 12, 2012.
77
Techniques include logistic regression for binary classification and hybrid models combining Decision Trees and Random Forest for ensemble learning . These techniques are efficient in processing large datasets and handling complex feature interactions, reducing the risk of overfitting and improving prediction accuracy . Natural language processing (NLP) aids in analyzing textual features, while behavioral analysis evaluates reviewer patterns, contributing to effective real-time processing and detection . These capabilities ensure the timely identification and removal of fake reviews while maintaining accuracy .
Fake reviews are a significant problem because they erode trust in e-commerce platforms, which rely heavily on user reviews as social proof influencing consumer behavior and purchasing decisions . For businesses, fake reviews distort actual feedback data, complicating the assessment of product quality, marketing strategies, and product development . For consumers, these reviews can lead to misguided purchasing decisions, resulting in dissatisfaction, financial loss, and even safety risks, as seen with high-value products like electronics and pharmaceuticals . The prevalence of fake reviews also presents regulatory challenges and complicates the enforcement of authenticity on such platforms .
Failing to address fake reviews effectively can lead to diminished consumer trust, compromising the platform's credibility and user experience . This distrust can result in reduced platform engagement, ultimately affecting sales and revenue . The platform's reputation may also suffer legal and financial repercussions as regulatory frameworks increasingly target deceptive practices with fines and sanctions . Persisting fake reviews could further complicate compliance with emerging regulations, leading to additional operational challenges .
The main challenges include the diversity and sophistication of fake reviews, as fraudsters often mimic natural human writing styles or use automated systems to generate reviews . The volume of reviews is another challenge, making manual inspection unfeasible. Machine learning models address these challenges by employing natural language processing to detect anomalies in writing styles, sentiment analysis to recognize overly generic or extreme language, and behavioral analysis to spot patterns like multiple reviews from the same user in short timeframes . Additionally, these models are trained using large datasets like Amazon's product review dataset, which provides various features such as review text, reviewer history, and product metadata .
Hybrid models combining Decision Trees and Random Forest improve accuracy by leveraging ensemble learning, which provides better generalization capabilities than individual models . Decision Trees handle non-linear relationships and complex feature interactions well, while the Random Forest component reduces overfitting by combining outputs from multiple trees . This integration allows the system to make more accurate and reliable predictions, benefiting from the strengths of both approaches .
Sentiment analysis is valuable because fake reviews often show extreme sentiment or mixed emotional tones, which sentiment analysis tools can detect with high accuracy . This analytical approach can identify overly positive or negative language, a common trait in fake reviews, providing a robust filter for suspicious content . However, sentiment analysis struggles with nuanced or well-balanced fake reviews, which can maintain a neutral tone yet still be deceptive .
Features extracted include textual information like writing style, language sentiment, and repeated patterns. Fake reviews often contain excessively positive or negative language and overly generic phrases . Reviewer history is analyzed for patterns such as frequent reviews in short periods, which may suggest fraudulent behavior . Additionally, product metadata, like the category, price, and frequency of positive reviews, can indicate manipulation, especially if a low-priced or unpopular product receives many favorable reviews .
UML aids in developing and documenting systems through its standardized language for creating visual models, which helps specify, visualize, and construct software systems . UML diagrams like use-case and sequence diagrams model functional requirements, system-user interactions, and message flows, clarifying the system's design and processes . These models assist in organizing system development, ensuring comprehensive analysis and clear documentation, which are crucial for complex systems such as fake review detection platforms .
Amazon's product review dataset is a valuable resource offering comprehensive data, including review text, reviewer information, and product metadata, making it suitable for research in review classification, sentiment analysis, and fraud detection . The dataset's features, such as review frequency, content, and sentiment, along with metadata like product category and price, allow machine learning models to be trained to differentiate between genuine and fake reviews . This facilitates the development and testing of algorithms that can process large datasets in real time, enhancing detection accuracy .
Regulatory frameworks play a critical role by imposing fines and guidelines to discourage deceptive practices. For instance, the United States Federal Trade Commission (FTC) has issued guidelines and fines for fake review practices . In response, e-commerce platforms like Amazon have implemented measures to detect and remove fake reviews, incorporating automated systems for real-time identification and manually reviewing flagged content . These platforms also invest in machine learning and natural language processing techniques to improve detection efficiency and maintain consumer trust .