← Go Back

Ponzi Scheme Detection

This program checks if an investment scheme looks like a Ponzi. It uses NLP to pull features out of the text, scores the risk using a small neural network, and classifies the result using a random forest. Output is one of: Ponzi, Likely Ponzi, or Not Ponzi.

GitHub

Project Structure

File/FolderDescription
train.pyMain script for training or running inference on one scheme.
models/Contains the Keras return risk model and scaler.
data/Text samples labeled as Ponzi, Likely, or Not Ponzi.
ponzi_scheme_classifier.pklTrained random forest saved after training.

Dependencies

Installation

git clone https://github.com/Vijay-31-08-2005/ponzi-scheme-detection.git
cd ponzi-scheme-detection
pip install -r requirements.txt

Setup Commands

python -m spacy download en_core_web_sm
import nltk
nltk.download('vader_lexicon')

Dataflow Pipeline

[.txt scheme file or form input]
        ↓
  parse_scheme_text()
    - Named Entity Recognition (spaCy)
    - Question Answering (HuggingFace)
    - Heuristics + Regex
    - Sentiment Analysis (VADER)
    - Semantic Scam Score (Sentence-BERT)
        ↓
  Extracted Features:
    - company_name
    - promised_return_percent
    - return_frequency_days
    - time_to_roi_days
    - minimum_deposit_usd
    - referral_pressure
    - whitepaper_available
    - team_members
    - sentiment_score
    - scam_keyword_density
    - crypto_only
        ↓
  calculate_return_risk()
    - Uses 4 ROI stats
    - Keras model outputs risk_score ∈ [0, 1]
        ↓
  Random Forest Classifier
    - Input: all features + risk_score
    - Output:
        - classification (Ponzi / Likely / Not)
        - class probabilities
  

Usage

Train the Return Risk Neural Network

python models/return_risk.py

This trains on return_risk_training_data.csv and saves:

Train the Ponzi Classifier

python train.py

Loads all .txt files from data/, extracts features, scores them, and fits the Random Forest classifier.

Running

Start the Web App

python run.py

Then go to http://127.0.0.1:5000

Steps:

  1. Paste your scheme description
  2. Click “Analyze Scheme”
  3. See risk score + prediction
  4. Click “Show More” for the raw breakdown

Web App Demo

Web App Demo

Run Inference on a Single File

python train.py path/to/scheme.txt

Sample Input

Skyline Development Fund pays a stable 4.5% monthly return, with capital doubled in just under 500 days. Minimum investment: $10,000. Our whitepaper outlines our urban development strategy, with detailed insights into our projects. Founders: Olivia Greene (Real Estate Director), Samuel Adams (Finance Manager). Investments are backed by prime real estate developments in growing metropolitan areas. Fully compliant with local regulations. No referral programs. Fiat and stablecoin payments accepted. Track your investment growth through our investor portal.

Sample Output

Parameters:
company_name: Skyline Development Fund
promised_return_percent: 4.0
return_frequency_days: 30
time_to_roi_days: 500
minimum_deposit_usd: 10000
referral_pressure: 1
whitepaper_available: 1
team_members: 1
sentiment_score: 0.6705
scam_keyword_density: 0.0
crypto_only: 0

Risk Score: 0.027123991

Classification: Not Ponzi

Probabilities:
Not Ponzi: 0.0472
Likely Ponzi: 0.9459
Ponzi: 0.0068

Comments