This project implements a machine learning pipeline to detect fraudulent credit card transactions. It includes dimensionality reduction via clustering, classification using a weak learner (decision stump), and iterative refinement with AdaBoost.
Given a set of transaction summaries and known labels (clean or fraud), this system builds a model to predict whether new transactions are fraudulent. Each transaction records spending at a set of physical locations (shops, restaurants, etc.). The pipeline consists of:
- Clustering: Groups nearby map locations using Euclidean distance to reduce the dimensionality of transaction data.
- Weak Learning: Trains a simple classifier (decision stump) to make predictions slightly better than random guessing.
- Boosting: Iteratively refines predictions using AdaBoost, focusing on inputs that previous learners misclassified.
- Implements k-means-style clustering.
- Input:
Point2D[](map locations), integerk(number of clusters). - Output: A mapping from
m-dimensional transaction summaries tok-dimensional cluster summaries.
- Implements a decision stump classifier.
- Trained on reduced transaction data (
n x k), labels (0or1), and sample weights. - Outputs a binary predictor to classify new samples as
cleanorfraud.
- Implements AdaBoost using decision stumps.
- Input: original transaction data (
n x m),Point2D[]locations, integerk(number of clusters). - Internally:
- Reduces dimensionality using
Clustering. - Trains weak learners iteratively.
- Adjusts sample weights based on misclassification.
- Aggregates predictions using majority vote.
- Reduces dimensionality using
- Transaction Summary:
int[]of lengthm, representing spending at each location. - Label:
0(clean) or1(fraud). - Map Locations:
Point2D[]coordinate array. - Weights:
double[]of lengthn; initialized to1/nand updated each round.
To classify a new transaction:
- Reduce its dimension using the
Clusteringobject. - Get predictions from all trained weak learners.
- Use majority voting to decide the final label.
- In case of a tie, predict
0(clean).
- In case of a tie, predict
- Java 8 or later
- algs4.jar from the Princeton Algorithms library
-
Required for the
Point2Ddata type and utility classes. -
Add it to your project’s classpath during compilation and execution:
javac -cp .:algs4.jar *.java java -cp .:algs4.jar BoostingAlgorithm
-