This is a data table component that visualizes Credit Card fraud detection and spedning data using the MUI Data Table library.
Clone the repo onto your local machine using this command
git clone https://github.com/UF-COM-OR/irbDashboard.gitOnce inside the directory run the following command to install the dependencies to run the Dashboard.
npm install --legacy-peer-depsThen to run the application on the local host run this command
npm run devThe product should look like this
To set up the flask application open up a new terminal tab and then run these commands
python -m venv venv
.\venv\Scripts\activate
pip install -r requirements.txtThen finally run
python src/app.pyThe backend uses a pre-trained Keras model to predict whether a transaction is fraudulent. The model is based on a shallow neural network architecture. The model was trained on a dataset of credit card transactions that includes both legitimate and fraudulent activities. Here are some key aspects of the model:
- Input Features: The model uses PCA-transformed features from the transaction data, along with the transaction
AmountandTimeas inputs. - Architecture: The neural network consists of several dense layers, with ReLU activation functions and dropout for regularization.
- Training: The model was trained using TensorFlow, with binary cross-entropy as the loss function and the Adam optimizer.
The Keras model is loaded in the Flask app using the following code snippet:
python
Copy code
`from tensorflow.keras.models import load_model
keras_model = load_model('src/shallow_nn_b_final.keras')`
The model was evaluated using the Area Under the Precision-Recall Curve (AUPRC) due to the highly imbalanced nature of the dataset. The model achieved high precision in detecting fraudulent transactions, making it suitable for real-world applications where minimizing false positives is critical.
The frontend is designed to visualize transaction data in an interactive data table and provide real-time predictions using the backend model. Below is an overview of the key components:
This directory contains the page components of the webpage.
html
Copy code
`import React from 'react'; import Table from '../components/table';
const TablePage = () => { return
; };export default TablePage;`
This is where you would add additional components like a navbar. Since this GitHub repo contains only the table, there is only one page inside here, which corresponds to the table page. When more pages are added to this repo, this is the directory where these pages will be kept.
This code defines a React component that displays two data tables using Material-UI (MUI) and React Router. The component allows switching between two sets of data using tabs.
- React: For creating the component.
- react-router-dom: For handling routing and navigation within the application.
- mui-datatables: For rendering responsive data tables.
- @mui/material/styles: For creating custom themes with Material-UI.
- @mui/material/Tabs and @mui/material/Tab: For creating the tabs that switch between the data tables.
- Data Imports: The data to be displayed in the tables (
myIRBDataandwesternIRBData).
- getStatusColor: Determines the color of a table cell based on the value (e.g., 'Missing', 'Closed', 'Approved', 'Changed').
- columns: Defines the columns for the
myIRBDatatable, including custom rendering for status values. - westernIRBColumns: Defines the columns for the
westernIRBDatatable, including custom rendering for status values.
- getMuiTheme: Creates a custom theme for MUI components with specific typography and color palette.
- MyIRBDataTable: A functional component that renders the
myIRBDatatable usingMUIDataTable. - WesternIRBDataTable: A functional component that renders the
westernIRBDatatable usingMUIDataTable.
- Table: The main functional component that:
- Uses
useLocationfromreact-router-domto track the current route. - Renders the tabs (
myIRB DataandWestern IRB Data) using MUITabsandTabcomponents. - Uses
RoutesandRoutefromreact-router-domto switch between theMyIRBDataTableandWesternIRBDataTablebased on the current path.
- Uses
-
Styling and Theme:
getMuiTheme: Customizes the MUI theme to use specific colors and typography.ThemeProvider: Applies the custom theme to all MUI components within theTablecomponent.
-
Tabs:
- Tabs Component: Contains two tabs for switching between the two datasets.
- Tab 1: "myIRB Data" - Links to the root path
/. - Tab 2: "Western IRB Data" - Links to
/western-irb.
- Tab 1: "myIRB Data" - Links to the root path
- Tabs Component: Contains two tabs for switching between the two datasets.
-
Routes:
- Route for
/: Renders theMyIRBDataTablecomponent. - Route for
/western-irb: Renders theWesternIRBDataTablecomponent.
- Route for
When the user navigates to the application:
- Initial View: The application displays the
myIRBDatatable by default. - Switching Tabs: Clicking on the "Western IRB Data" tab changes the route to
/western-irband displays thewesternIRBDatatable. - Custom Styling: The table cells are styled based on the data values using the
getStatusColorfunction.
- Tabs: The
TabsandTabcomponents create the visual tabs at the top of the table. - Table Data: The
MUIDataTablecomponents (MyIRBDataTableandWesternIRBDataTable) display the actual data in table format. - Custom Styles: Custom styles are applied to table cells based on the data values using the
getStatusColorfunction and the theme created bygetMuiTheme.
This project uses Tailwind CSS and Google Fonts, all of which can be seen in index.css. Tailwind CSS provides utility-first CSS classes for rapid UI development, while Google Fonts adds custom fonts for better typography.
This project was developed as part of a learning exercise in building a full-stack application that integrates a machine learning model into a web interface. Special thanks to the creators of Flask, React, and MUI for their excellent tools and libraries.
