Giter Club home page Giter Club logo

ieee-fraud-detection's Introduction

IEEE Fraud Detection with Anomaly Detection Algorithms

IEEE Fraud Detection is a competition that you are predicting the probability that an online transaction is fraudulent, as denoted by the binary target isFraud. The data is broken into two files identity and transaction, which are joined by TransactionID. Not all transactions have corresponding identity information.

This repo provides training hyperparameter optimization and evaluation scripts for IEEE Fraud Detection data with XGBoost and CatBoost algorithms.

Inspect CatBoost notebook and XGBoost notebook for detailed demo.

Usage

  • Clone:
git clone https://github.com/fcakyon/ieee-fraud-detection.git
  • Prepare conda environment:
conda env create -f environment.yml
conda activate frauddetection
  • Fir XGBoost or CatBoost model:
python train_xgboost.py
python train_catboost.py

Detailed Usage

  • After downloading the data to ./data folder, you can get the preprocessed data via get_data() method in preprocessing.py module:
from preprocessing import get_data

float: val_split = 0.2 # splits %80 of data for train and %20 for val
bool: apply_label_encoding = True # applies label encoding to categorical features
bool: fillna = True # fills missing values with -999

data = get_data(val_split, apply_label_encoding, fillna)
  • After initializing CatBoost or XGBoost classifier, perform automatic hyperparameter optimization via perform_random_search() or perform_bayes_search() in hyperparam_optimizing.py module:
from hyperparam_optimizing import perform_bayes_search, CATBOOST_BAYESSEARCH_PARAMS
import catboost as cb

# define xgboost or catboost instance
estimator = cb.CatBoostClassifier(
    n_estimators=200,
    learning_rate=0.05,
    metric_period=500,
    od_wait=500,
    task_type="CPU",
    depth=8,
) 

# parse get_data() output
X_train = data["X_train"]
X_val = data["X_val"]
y_train = data["y_train"]
y_val = data["y_val"]

# define parameter grid
param_grid = CATBOOST_BAYESSEARCH_PARAMS

# define scoring metric, full list can be seen at https://scikit-learn.org/stable/modules/model_evaluation.html
scoring = 'roc_auc'

# perform bayes parameter search for catboost classifier
best_estimator = perform_bayes_search(
    estimator, X_train, X_val, y_train, y_val, param_grid, scoring
)
  • After fitting a model, print results such as accuracy, auc score, confusion matrix, f1 scores using calculate_scores() method from scoring.py module:
from scoring import calculate_scores

scores = calculate_scores(estimator=best_estimator, X_val=X_val, y_val=y_val)

ieee-fraud-detection's People

Contributors

fcakyon avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.