Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation


◦ Code better, collaborate faster!

◦ Developed with the software and tools below.


Table of Contents


Overview

The repository contains a deep learning model for single-visit analysis. It includes notebooks for data preprocessing, model building, and evaluation. The code enables fast execution without evaluation on each epoch. Other features include early stopping, data balancing, and learning rate scheduling. The model can be tested using the predict_model.py file, which calculates various metrics. The utils folder contains modules for preprocessing, plotting heatmaps, and implementing early stopping. Overall, the repository provides a streamlined pipeline for deep learning analysis on single-visit data.


Repository Structure

└── /
    └── Single-visit/
        └── deep learning model/
            ├── fast_pipe.ipynb
            ├── models/
            ├── pipeline.ipynb
            ├── predict_model.py
            ├── requirements.txt
            └── utils/

Modules

Root
File Summary
fast_pipe.ipynb The code in the fast_pipe.ipynb file is a streamlined version of a deep learning model pipeline. It imports necessary libraries and modules, including pandas, numpy, torch, and sklearn. It also includes functions for preprocessing and plotting. The code does not run evaluation on each epoch, making it faster than the main pipeline. The code also includes a function to test the model using the predict_model.py file.
pipeline.ipynb The code in the'pipeline.ipynb' notebook imports various libraries and modules necessary for data preprocessing, model building, and evaluation. It includes functions for importing and preparing data, defining machine learning models, creating data loaders, calculating metrics, visualizing results, and testing the trained model. Additional utilities such as early stopping, data balancing techniques, and learning rate scheduling are also utilized.
predict_model.py The code above defines a function called test_model that evaluates the performance of a deep learning model on a test dataset. The function loads a trained model and test data, creates a data loader for the test data, and makes predictions on the test set. It then calculates various metrics including accuracy, precision, recall, and balanced accuracy.The function returns these metrics along with the target variable used for evaluation.
requirements.txt The code above represents a directory tree structure containing a deep learning model. The "requirements.txt" file inside the "deep learning model" directory specifies the versions of various Python libraries necessary to run the model. These libraries include imbalanced_learn, imblearn, matplotlib, numpy, pandas, pytorch_warmup, scikit_learn, seaborn, torch, and tqdm.
high_complexity_model.py The code above defines a deep learning model called Net, which is a feedforward neural network. It consists of multiple fully connected layers with batch normalization and dropout layers in between. The model takes an input of specified size and passes it through the layers using the ReLU activation function. The final output is obtained by applying the sigmoid activation function to the last layer. The purpose of this model is to prevent underfitting and improve model performance.
medium_complexity_model.py The code represents a deep learning model called "Medium Complexity Model" implemented using PyTorch. The model consists of multiple fully connected (linear) layers with batch normalization and dropout layers for regularization. The model performs forward propagation using the ReLU activation function for the hidden layers and sigmoid activation for binary classification. The purpose of the model is to make predictions based on input data.
simple_model.py The code defines a simple feedforward neural network model, called Net, which is used to address overfitting issues. The model takes an input of size'input_size' and consists of two fully connected layers with 64 and 1 neurons respectively. It also includes a dropout layer and batch normalization. The forward function applies the necessary operations to the input and returns the output predictions.
EarlyStopping.py The code implements an "EarlyStopping" class that provides functionality for early stopping during model training. It tracks the validation loss and checks if it improves over time. If the validation loss does not improve for a specified number of consecutive iterations, it stops the training early. The class also saves the model with the lowest validation loss during training. The class is initialized with parameters such as patience (number of consecutive iterations without improvement), verbose (whether to print messages), delta (minimum improvement required), and model_path (where to save the model).
heatmap_plots.py The code provides two functions for plotting metrics of a deep learning model. The'plot_heat_map' function takes a dataframe of results and plots heatmaps of specified scores (e.g., Balanced Accuracy, Precision, Recall) for each target. Users can choose to plot each score type separately or all in one graph.The'plot_metrics' function takes a dictionary of metrics (e.g., accuracy, loss, balanced accuracy) and a list of plots to generate. It plots the specified metrics over epochs, comparing the training and validation data. The available plots include accuracy, loss, balanced accuracy, precision, and recall.Both functions use the matplotlib and seaborn libraries for plotting the graphs.
Preprocessing_utils.py The code defines the output_selection_prepro function, which preprocesses data by imputing missing values and transforming the target variable. The function takes a dataframe df and a target variable target as inputs. It first checks if the preprocessed data file already exists, and if so, loads the data from the file. It then checks for missing values and if none are found, proceeds with defining numerical and categorical columns, dropping the target variable, and returning the preprocessed dataframe, target variable, and column lists. If the file does not exist or has missing values, the function runs the imputation process. It defines the target variable and lists of categorical and numerical columns, drops rows with missing values in the target column, and performs imputation on the remaining data using the IterativeImputer and SimpleImputer from scikit-learn. It transforms the target variable based on predefined thresholds, drops the target columns from the dataframe, saves the imputed data to a CSV file, and returns the preprocessed dataframe, transformed target variable, and updated column lists.

Getting Started

Dependencies

Please ensure you have the following dependencies installed on your system:

- ℹ️ Python 3.11.4

- ℹ️ Anaconda(Optional)

- ℹ️ ...

Installation

  1. Clone the repository:
git clone ../
  1. Change to the project directory:
cd 
  1. Install the dependencies:
pip install -r requirements.txt
  1. Run in a jupyter environment or convert to py and run it

Return


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages