fraudar package
A wrapper of Fraudar algorithm for the review graph mining project.
The Fraudar has been introduced by Bryan Hooi, et al. in ACM SIGKDD 2016 Conference on Knowledge Discovery & Data Mining (KDD 2016).
This package exports ReviewGraph
class,
which implements interfaces expected in other APIs of
Review Graph Mining project,
and three sub algorithms used in FRAUDER:
aveDegree
computes average degree on a matrix,sqrtWeightedAveDegree
computes square-weighted average degree on a matrix,logWeightedAveDegree
computes logarithm-weighted average degree on a matrix.
ReviewGraph
takes keyword argument algo
to
be set the sub algorithm to be used.
- class fraudar.ReviewGraph(blocks: int = 1, algo: ~typing.Any = <function logWeightedAveDegree>)[source]
Bases:
object
ReviewGraph is a simple bipartite graph representing review relation.
- Parameters:
blocks – how many blocks to be detected. (default: 1)
algo – algorithm used in fraudar, chosen from
aveDegree
,sqrtWeightedAveDegree
, andlogWeightedAveDegree
. (default: logWeightedAveDegree)
- add_review(reviewer: Reviewer, product: Product, rating: float, **_kwargs: Any) float [source]
Add a review from a reviewer to a product.
- Parameters:
reviewer – reviewer who posts the review.
product – product which receives the review.
rating – the review score.
- Returns:
added review score.
- new_product(name: str) Product [source]
Create a new product.
- Parameters:
name – name of the new product.
- Returns:
a new product object.
- new_reviewer(name: str, **_kwargs: Any) Reviewer [source]
Create a new reviewer.
- Parameters:
name – name of the new reviewer.
- Returns:
a new reviewer object.
- products: Final[list[fraudar.graph.Product]]
Collection of products.
- reviewers: Final[list[fraudar.graph.Reviewer]]
Collection of reviewers.
- reviews: Final[defaultdict[Product, dict[fraudar.graph.Reviewer, float]]]
Collection of reviews.
reviews is a dictionary of which key is a product and value is another dictionary of which key is a reviewer and value is a rating from the reviewer to the product.
Submodules
fraudar.graph module
Provide a review graph which runs Fraudar algorithm.
- class fraudar.graph.Node(graph: ReviewGraph, name: str)[source]
Bases:
object
Node of the ReviewGraph.
A node has a name and a link to the graph. It also implements
__hash__()
function so that each node can be stored in dictionaries.- Parameters:
graph – graph object this node belongs to.
name – name of this node.
- graph: Final[ReviewGraph]
The graph object this node belongs to.
- class fraudar.graph.Product(graph: ReviewGraph, name: str)[source]
Bases:
Node
A node type representing a product.
Use
ReviewGraph.new_product()
to create a new product object instead of using this constructor directory.- Parameters:
graph – graph object this product belongs to.
name – name of this product.
- class fraudar.graph.ReviewGraph(blocks: int = 1, algo: ~typing.Any = <function logWeightedAveDegree>)[source]
Bases:
object
ReviewGraph is a simple bipartite graph representing review relation.
- Parameters:
blocks – how many blocks to be detected. (default: 1)
algo – algorithm used in fraudar, chosen from
aveDegree
,sqrtWeightedAveDegree
, andlogWeightedAveDegree
. (default: logWeightedAveDegree)
- add_review(reviewer: Reviewer, product: Product, rating: float, **_kwargs: Any) float [source]
Add a review from a reviewer to a product.
- Parameters:
reviewer – reviewer who posts the review.
product – product which receives the review.
rating – the review score.
- Returns:
added review score.
- new_product(name: str) Product [source]
Create a new product.
- Parameters:
name – name of the new product.
- Returns:
a new product object.
- new_reviewer(name: str, **_kwargs: Any) Reviewer [source]
Create a new reviewer.
- Parameters:
name – name of the new reviewer.
- Returns:
a new reviewer object.
- products: Final[list[fraudar.graph.Product]]
Collection of products.
- reviewers: Final[list[fraudar.graph.Reviewer]]
Collection of reviewers.
- reviews: Final[defaultdict[Product, dict[fraudar.graph.Reviewer, float]]]
Collection of reviews.
reviews is a dictionary of which key is a product and value is another dictionary of which key is a reviewer and value is a rating from the reviewer to the product.
- class fraudar.graph.Reviewer(graph: ReviewGraph, name: str, anomalous_score: float = 0)[source]
Bases:
Node
A node type representing a reviewer.
Use
ReviewGraph.new_reviewer()
to create a new reviewer object instead of using this constructor directory.- Parameters:
graph – graph object this reviewer belongs to.
name – name of this reviewer.