This repository provides a sophisticated implementation of diverse deep learning models and advanced optimization methodologies, aiming to enhance accuracy and reduce training time. The project examines innovative architectures and algorithms, facilitating cutting-edge experimentation and deployment across a wide array of applications.
- π₯ Allows users to input biometric data (pregnancy, glucose, blood pressure, etc.) to get a prediction on the likelihood of diabetes.
- π§ The deep learning model processes the data and returns a diagnosis along with medical recommendations.
- π Users can upload a CSV file with multiple patient records to obtain batch predictions.
- π The platform processes the data and generates a detailed report with key statistics, distributions, and correlations.
- π¬ An AI-based assistant answers diabetes-related questions, provides nutritional plans, medication recommendations, and emotional support.
- π Uses the
deepseek-r1:7bmodel to generate accurate and contextualized answers.
- πΌοΈ CNNs (Convolutional Neural Networks) β State-of-the-art image recognition models.
- β³ RNNs (Recurrent Neural Networks) β Designed for sequential data like text and time-series.
- π LSTMs (Long Short-Term Memory Networks) β Capture long-range dependencies in sequences.
- π Autoencoders β Used for dimensionality reduction and data reconstruction.
- π GANs (Generative Adversarial Networks) β Generate high-quality synthetic datasets.
- π Cutting-edge algorithms: Adam, Stochastic Gradient Descent (SGD), RMSProp.
- π‘οΈ Regularization techniques: Dropout, Batch Normalization, L2 Regularization.
- π¦ Efficient dataset loading (e.g., MNIST, CIFAR-10).
- π§ Comprehensive preprocessing: normalization, augmentation, batching.
- π Metrics: Accuracy, Precision, Recall, F1-score.
- π Training visualization: Loss, Accuracy, and Validation Performance.
This guide provides a comprehensive roadmap for implementing, executing, and testing a neural network optimization pipeline.
-
π₯ Data Acquisition and Loading
- Reads structured CSV files with feature vectors and corresponding labels.
-
π Data Preprocessing
- Splits data into training/testing subsets.
- Converts data into PyTorch-compatible tensors.
-
π Model Design
- Multi-layer neural network with two hidden layers for predictive analytics.
-
π― Model Training
- Uses optimization algorithms to refine parameters and minimize errors.
-
π Performance Evaluation
- Evaluates model generalization using unseen test data.
-
π Output Results
- Generates metrics like accuracy & confusion matrices.
- Saves trained model checkpoints and loss evolution visualizations.
git clone https://github.com/ReapeRAlan/deep-learning-optimization.git
cd deep-learning-optimizationOllama allows you to run language models locally. DiabeDoc Pro uses the deepseek-r1:7b model.
- Download Ollama from its official site.
- Install Ollama on your system.
- Download the
deepseek-r1:7bmodel:ollama pull deepseek-r1:7b
python -m venv DiabeApp
DiabeApp/scripts/activatepython3 -m venv DiabeApp
source DiabeApp/bin/activatedeactivatepip install -r requirements.txtRun the training script:
python mainALTERNATIVE.pyOnce the model is trained, run the API:
python DiabeDoc.pyLaunch the Streamlit application:
streamlit run DiabeApp.py- π Python Version:
3.8or higher
Prepare a CSV file sample_data.csv in ./data/datasets/ with the following structure:
feature1,feature2,feature3,feature4,label
5.1,3.5,1.4,0.2,0
4.9,3.0,1.4,0.2,0
7.0,3.2,4.7,1.4,1
6.4,3.2,4.5,1.5,1
6.3,3.3,6.0,2.5,2
5.8,2.7,5.1,1.9,2python main.py- Console Output:
Using device: cpu Epoch 1/50 - Loss: 1.2345 Epoch 2/50 - Loss: 0.9876 ... Test set accuracy: 0.85 Model saved at: ./models/saved_model.pth - Generated Files:
- π
results/loss_accuracy_plot.png: Loss trends - πΎ
models/saved_model.pth: Trained model checkpoint
- π
Create a script test_model.py to evaluate the trained model:
import torch
from models.nn_model import initialize_nn
from utils.config import CONFIG
# Load the saved model
model = initialize_nn(CONFIG["input_dim"], CONFIG["hidden_dim"], CONFIG["output_dim"])
model.load_state_dict(torch.load(CONFIG["save_model_path"]))
model.eval()
# Test on new data
new_data = torch.tensor([[5.9, 3.0, 5.1, 1.8]], dtype=torch.float32)
output = model(new_data)
_, predicted_class = torch.max(output, 1)
print(f"Prediction for input {new_data.numpy()}: Class {predicted_class.item()}")Run the script:
python test_model.pySample output:
Prediction for input [[5.9 3. 5.1 1.8]]: Class 2.
|-- data/
| |-- datasets/
| |-- sample_data.csv # Dataset file
|
|-- models/
| |-- nn_model.py # Neural network architecture
| |-- saved_model.pth # Trained model checkpoint
|
|-- results/
| |-- loss_accuracy_plot.png # Training progress visualization
|
|-- utils/
| |-- config.py # Global configuration file
| |-- metrics.py # Metric calculation utilities
| |-- plot_utils.py # Plotting utilities
|
|-- main.py # Main script
This project implements an advanced pipeline for training, evaluating, and saving neural network models for classification tasks.
Contributions are highly encouraged! Submit an issue or pull request.
This project is distributed under the Personal License. See LICENSE.md for details.