0% found this document useful (0 votes)
5 views77 pages

Analyzing Fake Reviews with Machine Learning

Uploaded by

surekham1619
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views77 pages

Analyzing Fake Reviews with Machine Learning

Uploaded by

surekham1619
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CHAPTER 1

INTRODUCTION

1.1 General Introduction:

Introduction to the Problem of Fake Reviews

consumer behavior, driving sales, and impacting businesses' reputations. The


rise of e-commerce platforms such as Amazon, eBay, and others has revolutionized
the way consumers shop and interact with products and services. A key feature of
these platforms is the ability to read and write product reviews, which serve as a
form of social proof, influencing purchasing decisions. Consumers often rely on
reviews to assess the quality of a product or service before making a purchase. In
fact, studies show that a large percentage of consumers trust online reviews as much
as personal recommendations. As a result, reviews have become an essential part of
e-commerce platforms, shaping

However, the increasing reliance on reviews has led to a growing problem:


fake reviews. Fake reviews can be either positive or negative but are usually
misleading and deceptive. Fake positive reviews are written to artificially inflate the
ratings of a product, while fake negative reviews may attempt to harm a competitor’s
reputation. These fraudulent reviews can have severe consequences, such as
distorting consumer decision-making, misleading consumers into purchasing subpar
products, or undermining businesses with unfair negative ratings. As e-commerce
platforms expand globally, the challenge of identifying and mitigating fake reviews
has become even more pressing.

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.

The Importance of Addressing Fake Reviews

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.

Additionally, the presence of fake reviews complicates regulatory


frameworks. Some countries have started to impose fines or sanctions on businesses
and individuals who write fake reviews. For instance, the United States Federal
Trade Commission (FTC) has issued guidelines and fines related to deceptive
reviews. Many e-commerce platforms, including Amazon, have introduced measures
to detect and remove fake reviews, but they face significant challenges in doing so at
scale. Developing effective systems that can handle millions of reviews in real time,
with high accuracy, is essential to the continued trust and growth of e-commerce
platforms.

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.

Challenges in Detecting Fake Reviews

Detecting fake reviews presents several challenges. One of the primary


challenges is the diversity of fake reviews. Fraudsters are becoming increasingly
sophisticate in their attempts to bypass detection systems. For example, they may
use fake accounts to post reviews, try to mimic natural human writing styles, or
generate fake reviews using automated systems. Additionally, some reviews may
3
appear legitimate on the surface but may exhibit subtle signs of inauthenticity that
are difficult to detect.

Another challenge is the sheer volume of reviews that must be processed. E-


commerce platforms receive millions of reviews daily, making manual review
inspection unfeasible. Therefore, machine learning-based methods, particularly those
that employ large-scale data analytics, are essential for real-time identification and
removal of fake reviews.

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.

Machine Learning Techniques for Fake Review Detection

Given the complexity of detecting fake reviews, machine learning techniques


have become a powerful tool in identifying fraudulent content. Machine learning
algorithms can be trained on labeled datasets containing both fake and real reviews
to classify new, unseen reviews automatically.

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.

Hybrid models that combine multiple algorithms, such as combining Decision


Trees with Random Forest, are also being explored. These models aim to take
advantage of the strengths of each algorithm to improve overall classification
accuracy. For instance, Decision Trees provide interpretability, while Random
Forests offer better accuracy and stability by mitigating the limitations of individual
trees.

Other methods, such as Support Vector Machines (SVM), Naive Bayes


classifiers, and deep learning approaches, have also been used to detect fake reviews.
These techniques can analyze complex patterns in review content and reviewer
behavior and are effective in handling large datasets with a high level of complexity.

1.2 Objectives:

The main objective of our project is,

● 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 +

RF models in predicting fake review compared to baseline methods and


traditional techniques.

5
● Analyze and address the challenges associated with the informal, nuanced, and

context-dependent nature of social media language, including slang,


abbreviations, and reviews.

● Compare the effectiveness of the hybrid DT + RF model with the LR model and

traditional fake review analysis techniques to identify strengths and limitations of


each approach.

CHAPTER 2
SYSTEM PROPOSAL

2.1 EXISTING SYSTEM:


In existing system, fake review of online products has evolved through
various approaches, each with its strengths and limitations. Traditional fake product
review systems often rely on rule-based methods or simpler machine learning
algorithms. Rule-based systems use predefined lists of words and phrases associated
with positive or negative sentiments. These systems, while straightforward and easy
to implement, face significant limitations. They struggle with the informal and
diverse nature of social media language, such as slang, abbreviations, and emojis,
which can lead to inaccurate review classification. Additionally, rule-based
approaches lack the ability to understand the context in which words are used,
making them less effective in handling nuanced sentiments. On the other hand,
machine learning-based systems such as Support Vector Machines (SVM) and Naive
Bayes classifiers have been employed to improve accuracy. These methods learn
from labeled training data to classify review and can handle a broader range of
textual features compared to rule-based systems. Despite their advantages, these
algorithms have limitations as well. SVMs, for instance, can be computationally
6
expensive and may not perform well with very large datasets or complex feature
interactions. Naive Bayes, while efficient, assumes independence between features,
which is often not the case in textual data, leading to suboptimal performance in
capturing fake review nuances.

2.1.1 DISADVANTAGES:

● Struggle with informal language, slang, abbreviations, and emojis commonly

used in social media.

● Lack the ability to understand the context or nuances of expressions, leading

to potential misclassifications.

● Require extensive manual effort to create and maintain lexicons and rules.

● Difficulty in scaling to handle large volumes of diverse text data efficiently.

● Can be slow and resource-heavy, especially with large datasets or high-

dimensional feature spaces.

● The decision boundary created by SVMs can be complex, making it hard to

interpret how classifications are made.

● 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

textual data, potentially leading to reduced accuracy

2.1 PROPOSED SYSTEM:

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:

• Decision Tree can handle large datasets efficiently.

• The experimental result is high when compared with existing system.

• Time consumption is low.

• Lack of ability to be spatially invariant to the input data.


• Implementing text cleaning techniques like removing stop words, stemming,
punctuation removal, tokenization, and padding enhances the quality of the
text data, making it more suitable for analysis.
• Integration of Hybrid Models: By combining Decision Tree with RF, the
proposed system benefits from the strengths of both models. Decision Trees
handle non-linear relationships and complex feature interactions well, while
Logistic Regression adds robustness to classification tasks, leading to more
accurate and reliable predictions.

9
2.2 LITERATURE SURVEY:

1. Title: The Market for Fake Reviews, 2022

Author: Sherry He, Brett Hollenbeck, Davide Proserpio

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:

● Time consumption is high

10
2. Title: Fake Reviews Detection: A Survey, 2021

Author: RAMI MOHAWESH 1 , SHUXIANG XU 1 , SON N. TRAN 1 , ROBERT


OLLINGTON1 , MATTHEW SPRINGER 1 , YASER JARARWEH 2 , AND
SUMBAL MAQSOOD1

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:

● Despite the advantages of the proposed method, it focused on suspicious

periods rather than reducing expensive computations in the scoring phase.

11
● Furthermore, Hand annotated techniques need many human resources, and

adding metadata such as IP address can boost the proposed model’s


performance

Disadvantage:

● The process is implemented without removing unwanted data.

3. Title: Identifying Groups of Fake Reviewers Using a Semisupervised


Approach, 2021
Author: Punit Rathore; Jayesh Soni; Nagarajan Prabakar; Marimuthu Palaniswami;
Paolo Santi
Methodology:
Online product reviews have become increasingly important in digital consumer
markets where they play a crucial role in making purchasing decisions by most
consumers. Unfortunately, spammers often take advantage of online reviews by
writing fake reviews to promote/demote certain products. Most of the previous
studies have focused on detecting fake reviews and individual fake reviewer-ids.
However, to target a particular product, fake reviewers work collaboratively in
groups and/or create multiple fake ids to write reviews and control the sentiments of
the product. This article addresses the problem of finding such fake reviewer groups.
More specifically, we propose a top-down framework for candidate fake reviewer
groups’ detection based on the DeepWalk approach on reviewers’ graph data and a
(modified) semisupervised clustering method, which can incorporate partial
background knowledge. We validate our proposed framework on a real review
dataset from the Google Play Store, which has partial ground-truth information about
2207 fraud reviewer-ids out of all 38 123 reviewer-ids in the dataset. Our
experimental results demonstrate that the proposed approach is able to identify the
candidate spammer groups with reasonable accuracy. The proposed approach can
also be extended to detect groups of opinion spammers in social media (e.g. fake
12
comments or fake postings) with temporal affinity, semantic characteristics, and
sentiment analysis.

Advantages:

● The process is implemented with removing unwanted data.

● Time consumption is low.

Disadvantages:

● It doesn’t efficient for large number of data.

4. Title: A systematic literature review on machine learning applications for


consumer sentiment analysis using online reviews, 2021

Author: Praphula KumarJainaRajendraPamulaaGautamSrivastava


Methodology: Consumer sentiment analysis is a recent fad for social media-related
applications such as healthcare, crime, finance, travel, and in academia.
Disentangling consumer perception to gain insight into the desired objective and
reviews is significant. With the advancement of technology, a massive amount of
social web data increasing in volume, subjectivity, and heterogeneity becomes
challenging to process manually. Machine learning (ML) techniques have been
utilized to handle this difficulty in real-life applications. This paper presents a study
to determine the usefulness, scope, and applicability of this alliance of ML
techniques for consumer sentiment analysis (CSA) for online reviews in the domain
of hospitality and tourism. We show a systematic literature review to compare,
analyse, explore, and understand the attempts and directions to find research gaps in
illustrating the future scope of this pairing. The primary objective is to read and
analyse the use of ML techniques for consumer sentiment analysis on online reviews
in the domain of hospitality and tourism. This research has significant implications
for service providers in terms of developing managerial strategies for consumers in

13
terms of selecting services that meet their needs. Furthermore, there is high impact
for researchers in terms of prospective research directions.

Advantages:

● Less time consumption

Disadvantages:

● Less accurate

5. Title: Fake Reviews Detection using Supervised Machine Learning,


Author: Ahmed M. Elmogy1, Usman Tariq2, Atef Ibrahim4
Methodology: With the continuous evolve of E-commerce systems, online reviews
are mainly considered as a crucial factor for building and maintaining a good
reputation. Moreover, they have an effective role in the decision making process for
end users. Usually, a positive review for a target object attracts more customers and
lead to high increase in sales. Nowadays, deceptive or fake reviews are deliberately
written to build virtual reputation and attracting potential customers. Thus,
identifying fake reviews is a vivid and ongoing research area. Identifying fake
reviews depends not only on the key features of the reviews but also on the
behaviors of the reviewers. This paper proposes a machine learning approach to
identify fake reviews. In addition to the features extraction process of the reviews,
this paper applies several features engineering to extract various behaviors of the
reviewers. The paper compares the performance of several experiments done on a
real Yelp dataset of restaurants reviews with and without features extracted from
users behaviors. In both cases, we compare the performance of several classifiers;
KNN, Naive Bayes (NB), SVM, Logistic Regression and Random forest. Also,
different language models of n-gram in particular bi-gram and tri-gram are taken into
considerations during the evaluations. The results reveal that KNN(K=7)
outperforms the rest of classifiers in terms of f-score achieving best f-score 82.40%.

14
The results show that the f-score has increased by 3.80% when taking the extracted
reviewers behavioral features into consideration.

Advantages:

● To the best of our knowledge, no approaches have dived deeply in extracting

features that reflect the reviewers’ behaviors. These features will highly
influence the effectiveness of the fake reviews detection process.

Disadvantage:

● Training time of SVM algorithm takes high.

6. "Sentiment Analysis for Fake Review Detection in Online Platforms"

Year: 2023

Authors: Daniel Kim, Olivia Turner

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

SYMBOL SYMBOL NAME

Use Case

Actor

Control flow

Decision Start

Start Node

End State

Action state

List of Symbols

16
3.1 SYSTEM ARCHITECTURE:

FIGURE 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.

3.2 FLOW CHART:

FIGURE 3.2: FLOW CHART

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.

3.3 DATA FLOW DIAGRAM:


3.3.1 Level 0:

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:

UML stands for Unified Modelling Language. UML is a standardized general-


purpose modelling language in the field of object-oriented software engineering. The
standard is managed, and was created by, the Object Management Group.

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 Unified Modelling Language is a standard language for specifying,


Visualization, Constructing and documenting the artifacts of software system, as
well as for business modelling and other non-software systems.

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:

The Primary goals in the design of the UML are as follows:

1. Provide users a ready-to-use, expressive visual modeling Language so that they


can develop and exchange meaningful models.

2. Provide extendibility and specialization mechanisms to extend the core concepts.

3. Be independent of particular programming languages and development process.

4. Provide a formal basis for understanding the modeling language.

5. Encourage the growth of OO tools market.


22
3.4.1 USE CASE DIAGRAM:

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.

UML use case diagrams are ideal for:

● Representing the goals of system-user interactions

● Defining and organizing functional requirements in a system

● Specifying the context and requirements of a system

● Modelling the basic flow of events in a use case

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.

● Associations: A line between actors and use cases. In complex diagrams, it is


important to know which actors are associated with which 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.

FIGURE 3.4.1: USE CASE DIAGRAM


The use case diagram illustrates the interactions between users and the fake review
classification system. Key actors include Data Scientists, who perform tasks such as
Data Selection, Data Preprocessing, and Model Training. End Users interact with the
system to provide text input and receive Classification Results. The system supports
functionalities like Text Preprocessing, Vectorization, Model Evaluation, and

24
Prediction. The diagram highlights how users engage with various components to
achieve accurate and insightful text classification.

3.4.2 ACTIVITY DIAGRAM:


This shows the flow of events within the system. The activities that occur within a
use case or within an objects behaviour typically occur in a sequence. An activity
diagram is designed to be simplified look at what happens during an operations or a
process. Each activity is represented by a rounded rectangle the processing within an
activity goes to compilation and then an automatic transmission to the next activity
occurs. An arrow represents the transition from one activity to the next. An activity
diagram describes a system in terms of activities. Activities are the state that
represents the execution of a set of operations.

These are similar to flow chart diagram and dataflow.

Initial state: which state is starting the process?

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.

Transition: A transition is a directed relationship between a source state vertex and


a target state vertex. It may be part of a compound transition, which takes the static
machine from one static configuration to another, representing the complete response
of the static machine to a particular event instance.

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.

FIGURE 3.4.2: ACTIVITY DIAGRAM

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.

3.4.3 SEQUENCE DIAGRAM:


Sequence diagrams document the interactions between classes to achieve a result,
such as a use case. Because UML is designed for object-oriented programming, these
communications between classes are known as messages. The Sequence diagram
lists objects horizontally, and time vertically, and models these messages over time.

Graphical Notation: In a Sequence diagram, classes and actors are listed as


columns, with vertical lifelines indicating the lifetime of the object over time.

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.

Activation: Activations, modelled as rectangular boxes on the lifeline, indicate when


the object is performing an action.

Message: Messages, modelled as horizontal arrows between Activations.

27
FIGURE 3.4.3: SEQUENCE DIAGRAM

The sequence diagram depicts the interactions between system components


throughout the classification process. It starts with the User initiating data input,
which is then handled by the System to perform Data Preprocessing. The processed
data undergoes Text Preprocessing and Vectorization. Following this, the system

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:

An Entity Relationship (ER) Diagram is a type of flowchart that illustrates how


“entities” such as people, objects or concepts relate to each other within a system.

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

A definable thing—such as a person, object, concept or event—that can have data


stored about it. Think of entities as nouns. Examples: a customer, student, car or
product. Typically shown as a rectangle.

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 categories: Entities are categorized as strong, weak or associative. A strong


entity can be defined solely by its own attributes, while a weak entity cannot. An
associative entity associates entities (or elements) within an 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.

For example, the named student might register for a course.

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.

Relationships are typically shown as diamonds or labels directly on the connecting


lines.

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.

3.3.5 CLASS DIAGRAM:

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.

Class: Classes are building blocks in object-oriented programming. A class is


depicted using a rectangle divided into three section.

The top section is name of class; the middle section defines the properties of class.
The bottom section list the methods of the class.

Association: An Association is a generic relationship between two classes, and is


modelled by a line connecting the two classes.

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

4.2 MODULES DESCRIPTION:

4.2.1: DATA SELECTION:

• The data for this study is sourced from the fake product review dataset
available on Kaggle.

• Dataset Link: ([Link]


dataset)

• 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.

4.2.2: DATA PREPROCESSING:

● Data preprocessing is a crucial step to ensure the dataset is clean and ready for

analysis.

● Handling Missing Values: Missing values in the dataset can lead to

inaccuracies in the analysis.

● Methods such as imputation (replacing missing values with mean, median, or

mode) or removal of records with missing values are employed to handle these
gaps in the data.

● Label Encoding: To convert categorical variables (such as gender and

emotions) into numerical format, label encoding is used.

● This process assigns a unique integer to each category, enabling machine

learning algorithms to process these variables effectively.

4.2.3 TEXT PREPROCESSING:

● In this step, we can implement the different Natural Language Processing

techniques.

● NLP is a field in machine learning with the ability of a computer to

understand, analyze, manipulate, and potentially generate human language.

● Cleaning (or pre-processing) the data typically consists of a number of steps:

● Remove punctuation: Punctuation can provide grammatical context to a

sentence which supports our understanding.

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.

● Tokenization: Tokenizing separates text into units such as sentences or

words. It gives structure to previously unstructured text. eg: Plata o Plomo->


‘Plata’,’o’,’Plomo’.

● 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:

● In this step, we can implement the different vectorization method such as

count vectorization.

● Vectorizing is the process of encoding text as integer’s i.e. numeric form to

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

only numerical data.

● CountVectorizer creates a matrix in which each unique word is represented

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.

4.2.5: DATA SPLITTING:

● 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

performance of the algorithm in order to see how well it works.

● In our process, we considered 70% of the input dataset to be the training data and

the remaining 30% to be the testing data.

● Data splitting is the act of partitioning available data into two portions, usually

for cross-validator purposes.

● One Portion of the data is used to develop a predictive model and the other to

evaluate the model's performance.

● Separating data into training and testing sets is an important part of evaluating

data mining models.

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:

• In our process, we can implement the machine learning algorithm such as


random forest and hybrid algorithms such as decision tree and logistic
regression.

• Random Forest: This ensemble learning method constructs multiple decision


trees and merges their outputs to improve classification accuracy and prevent
overfitting. It is robust and effective for complex datasets.

• Hybrid Model (Voting Classifier): A hybrid model combines multiple


algorithms, such as Decision Tree and Logistic Regression, using a voting
classifier.

• 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.

Random Forest is an ensemble learning method primarily used for classification


and regression tasks. It operates by constructing multiple decision trees during
training and outputs the mode (for classification) or mean (for regression) of the
individual trees' predictions. This technique is popular for its robustness, versatility,
and ease of use, making it a go-to method for various machine learning problems.

How It Works

● Bootstrap Aggregation (Bagging): Random Forest uses a technique called


bagging (Bootstrap Aggregating) to improve model performance. It involves

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

● Robustness to Overfitting: By averaging multiple decision trees, Random


Forest reduces the risk of overfitting, which is a common issue with single
decision trees.
● High Accuracy: It generally provides high accuracy for both classification
and regression tasks due to its ensemble nature and feature randomness.
● Handling of Large Datasets: Random Forest can handle large datasets with
numerous features effectively and efficiently.
● Feature Importance: It provides a measure of feature importance, helping in
understanding which features contribute most to the predictions.
● Versatility: It can be used for a wide range of tasks including classification,
regression, and anomaly detection.

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

● Tree Structure: A Decision Tree is structured as a tree where:

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

● Interpretability: Decision Trees are easy to interpret and understand, as they


represent decisions in a straightforward, hierarchical manner.
● No Need for Data Normalization: They do not require scaling or
normalization of data, as they handle data of varying scales and units
effectively.
● Handles Both Numerical and Categorical Data: Can be used for datasets
with both types of attributes, making them versatile.
● Feature Selection: Automatically performs feature selection by choosing the
most informative features for splitting the data.
● Non-Linearity: Capable of capturing non-linear relationships between
features and target variables without requiring transformation of the features.

Logistic Regression is a statistical method used for binary classification problems,


where the goal is to predict the probability of a binary outcome based on one or more
predictor variables. Despite its name, it is a classification algorithm rather than a
regression algorithm. It is widely used due to its simplicity, interpretability, and
effectiveness in various applications.

42
How It Works

● Model Equation: The core of Logistic Regression is the logistic function,


also known as the sigmoid function, which maps predicted values to
probabilities.
● Probability Prediction: The logistic function outputs a value between 0 and 1,
which is interpreted as the probability of the positive class. For binary
classification, the model predicts class membership based on whether the
probability is above or below a certain threshold (usually 0.5).
● Cost Function: The model is trained using the maximum likelihood estimation
method. The cost function, also known as the log-loss or binary cross-entropy,
measures the difference between the predicted probabilities and the actual
class labels. The goal is to minimize this cost function through optimization
algorithms such as Gradient Descent.
● Optimization: Logistic Regression uses optimization techniques to find the
best-fitting parameters (coefficients) for the model. Gradient Descent is
commonly used to iteratively update the coefficients to minimize the cost
function.

Advantages

● Simplicity and Interpretability: Logistic Regression is easy to implement and


understand. The coefficients of the model can be interpreted as the impact of
each feature on the probability of the positive class.
● Probabilistic Output: Provides probabilistic predictions, which can be useful
for decision-making and assessing the confidence of predictions.

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).

4.2.7: RESULT GENERATION:

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

Precision is defined as the number of true positives divided by the number of


true positives plus the number of false positives.
Precision=TP/ (TP+FP)

● 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

review is fake or real input based on users input.

● The final model is deployed to classify incoming comments, providing insights

into user input review and enabling the development of personalized content
strategies.

45
CHAPTER 5

SYSTEM REQUIREMENTS
5.1 HARDWARE REQUIREMENTS:

● System : Pentium IV 2.4 GHz

● Hard Disk : 200 GB

● Mouse : Logitech.

● Keyboard : 110 keys enhanced

● Ram : 4GB

5.2 SOFTWARE REQUIREMENTS:

● O/S : Windows 10.

● Language : Python

● Front End : HTML,CSS

● Framework : STREAMLIT

● Software used :Anaconda Navigator – Spyder

5.3 SOFTWARE DESCRIPTION:

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.

5.3.2 Features of Python

● Simple

Python is a simple and minimalistic language. Reading a good Python


program feels almost like reading English, although very strict English! This pseudo-
code nature of Python is one of its greatest strengths. It allows you to concentrate on
the solution to the problem rather than the language itself.

● Easy to Learn

As you will see, Python is extremely easy to get started with. Python has an
extraordinarily simple syntax, as already mentioned.

● Free and Open Source

Python is an example of a FLOSS (Free/Libré and Open Source Software). In


simple terms, you can freely distribute copies of this software, read its source code,
make changes to it, and use pieces of it in new free programs. FLOSS is based on the
47
concept of a community which shares knowledge. This is one of the reasons why
Python is so good - it has been created and is constantly improved by a community
who just want to see a better Python.

● 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 use Python on GNU/Linux, Windows, FreeBSD, Macintosh, Solaris,


OS/2, Amiga, AROS, AS/400, BeOS, OS/390, z/OS, Palm OS, QNX, VMS, Psion,
Acorn RISC OS, VxWorks, PlayStation, Sharp Zaurus, Windows CE and PocketPC!

You can even use a platform like Kivy to create games for your computer and
for iPhone, iPad, and Android.

● Interpreted

This requires a bit of explanation.

A program written in a compiled language like C or C++ is converted from the


source language i.e. C or C++ into a language that is spoken by your computer
(binary code i.e. 0s and 1s) using a compiler with various flags and options. When

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

Python supports procedure-oriented programming as well as object-oriented


programming. In procedure-oriented languages, the program is built around
procedures or functions which are nothing but reusable pieces of programs. In
object-oriented languages, the program is built around objects which combine data
and functionality. Python has a very powerful but simplistic way of doing OOP,
especially when compared to big languages like C++ or Java.

● 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.

5.3.3 Streamlit framework:

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

with widgets like sliders, dropdowns, and text inputs.

● Data Visualization: It integrates seamlessly with popular data visualization

libraries like Matplotlib, Plotly, and Altair.

● Widgets: Streamlit provides a variety of widgets to collect user input and make

your apps interactive.

● Deployment: Streamlit apps can be deployed easily on the web through services

like Streamlit Sharing, Heroku, or AWS.

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

[Link], [Link], and [Link].

Introduction to SQLite :

SQLite

It is a self-contained, high-reliability, embedded, full-featured, public-domain,


SQL database engine. It is the most used database engine in the world. It is an in-
process library and its code is publicly available. It is free for use for any purpose,
51
commercial or private. It is basically an embedded SQL database engine. Ordinary
disk files can be easily read and write by SQLite because it does not have any
separate server like SQL. The SQLite database file format is cross-platform so that
anyone can easily copy a database between 32-bit and 64-bit systems. Due to all
these features, it is a popular choice as an Application File Format.

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

1. The transactions follow ACID properties i.e. atomicity, consistency, isolation,


and durability even after system crashes and power failures.

2. The configuration process is very easy, no setup or administration needed.

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.

4. Sometimes it is faster than the direct file system I/O.

5. It supports terabyte-sized databases and gigabyte-sized strings and blobs.

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.

7. Complete database can be stored in a single cross-platform disk file.

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.

2. It is used as an alternative for open to writing XML, JSON, CSV or some


proprietary format into disk files used by the application.

3. As it has no complication for configuration and easily stores file in an ordinary


disk file, so it can be used as a database for small to medium sized websites.

4. It is faster and accessible through a wide variety of third-party tools, so it has


great application.

5.4 TESTING PRODUCTS:

System testing is the stage of implementation, which aimed at ensuring that


system works accurately and efficiently before the live operation commence.
Testing is the process of executing a program with the intent of finding an error. A
good test case is one that has a high probability of finding an error. A successful
test is one that answers a yet undiscovered error.

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.

5.4.1 UNIT TESTING:


53
Unit testing is the testing of each module and the integration of the overall
system is done. Unit testing becomes verification efforts on the smallest unit of
software design in the module. This is also known as ‘module testing’.
The modules of the system are tested separately. This testing is carried out during
the programming itself. In this testing step, each model is found to be working
satisfactorily as regard to the expected output from the module. There are some
validation checks for the fields. For example, the validation check is done for
verifying the data given by the user where both format and validity of the data
entered is included. It is very easy to find error and debug the system.

5.4.2 INTEGRATION TESTING:

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.

5.4.3 TESTING TECHNIQUES/STRATEGIES:

● WHITE BOX 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.

● BLACK BOX TESTING:

1. Black box testing is done to find incorrect or missing function

2. Interface error

3. Errors in external database access

4. Performance errors.

5. Initialization and termination errors

In ‘functional testing’, is performed to validate an application conforms to its


specifications of correctly performs all its required functions. So this testing is also
called ‘black box testing’. It tests the external behaviour of the system. Here the
engineered product can be tested knowing the specified function that a product has
been designed to perform, tests can be conducted to demonstrate that each function
is fully operational.

5.4.4 SOFTWARE TESTING STRATEGIES

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 TESTING:

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.

5.5 TEST CASES:

Test Case 1: Handling Missing Values

56
● Description: Test the system's ability to handle and impute missing values in the

dataset.

● Input: A dataset with randomly missing values in the text fields.

● Expected Outcome: The system should correctly identify and handle missing

values, either by imputing them or excluding affected rows without causing


errors.

● Rationale: Ensures that missing values do not adversely affect the preprocessing

or training process.
Test Case 2: Label Encoding Verification

● Description: Verify that label encoding correctly converts categorical sentiment

labels into numeric values.

● Input: A dataset with sentiment labels such as "OR" and "CG".

● Expected Outcome: Labels are correctly converted into numeric values (e.g., 0

for CG, 1 for OR).

● Rationale: Ensures that the conversion from string labels to numeric values is

accurate and consistent.

Test Case 3: Text Cleaning (Stop Words Removal)

● 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

cleaner and more relevant text data.


57
● Rationale: Confirms that the stop word removal process is functioning as

intended.

Test Case 4: Stemming and Lemmatization

● Description: Verify the stemming and lemmatization processes on the text

data.

● Input: Text containing different forms of a word (e.g., "running", "ran",

"runner").

● Expected Outcome: Words should be reduced to their root forms (e.g., "run").

● Rationale: Ensures that text normalization techniques are applied correctly.

Test Case 5: Vectorization Accuracy

● Description: Check the accuracy of count vectorization on the text data.

● Input: Sample text data and the corresponding count vectorized output.

● Expected Outcome: The count vectorization should correctly represent the

text data in numerical form, reflecting word counts accurately.

● Rationale: Verifies that the vectorization process is correctly transforming

text into numerical features.


Test Case 6: Train-Test Split Validation

● 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

and test datasets, maintaining the original distribution of labels.

● Rationale: Ensures that the data splitting process is performed correctly and

that training and test sets are representative.


Test Case 7: Model Training with Logistic Regression

● Description: Test the training process of the Logistic Regression model.

● Input: Cleaned and vectorized training data.

● Expected Outcome: The Logistic Regression model should train successfully,

with an ability to learn patterns from the data.

● Rationale: Confirms that the Logistic Regression algorithm is implemented

and trained properly.

Test Case 8: Hybrid Model (Decision Tree + Random Forest)

● Description: Evaluate the performance of the hybrid model combining

Decision Tree and Random Forest.

● Input: Cleaned and vectorized training data.

● Expected Outcome: The hybrid model should be able to train effectively, and

its performance should be comparable to or better than individual models.

● Rationale: Assesses the integration of Decision Tree and Logistic Regression

models and their combined effectiveness.

59
Test Case 9: Sentiment Prediction Accuracy

● Description: Test the system’s ability to predict review correctly based on

user input.

● Input: Sample user input with known sentiment (e.g., "I love this product!"

for fake).

● Expected Outcome: The system should correctly classify the sentiment as

fake or real.

● Rationale: Validates the end-to-end functionality of the sentiment analysis

system in predicting sentiments from new input.

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

from sklearn.model_selection import train_test_split

from [Link] import RandomForestClassifier

from sklearn import linear_model

from sklearn import metrics

import [Link] as plt

import os

import numpy as np

import warnings

[Link]("ignore")

from sklearn import preprocessing

# ===-------------------------= INPUT DATA --------------------

63
dataframe=pd.read_csv("fake reviews [Link]")

print("--------------------------------")

print("Data Selection")

print("--------------------------------")

print()

print([Link](15))

#-------------------------- PRE PROCESSING --------------------------------

#------ checking missing values --------

print("----------------------------------------------------")

print(" Handling Missing values ")

print("----------------------------------------------------")

print()

print([Link]().sum())

64
res = [Link]().sum().any()

if res == False:

print("--------------------------------------------")

print(" There is no Missing values in our dataset ")

print("--------------------------------------------")

print()

else:

print("--------------------------------------------")

print(" Missing values is present in our dataset ")

print("--------------------------------------------")

print()

dataframe = [Link](0)

resultt = [Link]().sum().any()

65
if resultt == False:

print("--------------------------------------------")

print(" Data Cleaned !!! ")

print("--------------------------------------------")

print()

print([Link]().sum())

# ---- LABEL ENCODING

print("--------------------------------")

print("Before Label Encoding")

print("--------------------------------")

df_class=dataframe['label']

df_class_lab=dataframe['label'].unique()

66
import pickle

with open('[Link]', 'wb') as f:

[Link](df_class_lab, f)

print(dataframe['label'].head(15))

print("--------------------------------")

print("After Label Encoding")

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

Common questions

Powered by AI

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 .

You might also like