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:

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

update() float[source]

Update anomalous scores by running a greedy algorithm.

Returns:

0

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.

fraudar.aveDegree(M, nodeSusp=None)[source]
fraudar.logWeightedAveDegree(M, nodeSusp=None)[source]
fraudar.sqrtWeightedAveDegree(M, nodeSusp=None)[source]

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.

name: Final[str]

Name of this node.

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.

property summary: float

Summary of ratings given to 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:
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.

update() float[source]

Update anomalous scores by running a greedy algorithm.

Returns:

0

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.

anomalous_score: float

anomalous score of this reviewer.