ShadowTEM commited on
Commit
5d6a0a9
Β·
verified Β·
1 Parent(s): 1c27aad

Upload 6 files

Browse files
Files changed (6) hide show
  1. .gitattributes +35 -35
  2. Dockerfile +10 -10
  3. LICENSE +21 -0
  4. README.md +107 -11
  5. app.py +22 -0
  6. requirements.txt +10 -0
.gitattributes CHANGED
@@ -1,35 +1,35 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -1,11 +1,11 @@
1
- FROM python:3.10.12
2
-
3
- WORKDIR /src
4
-
5
- COPY requirements.txt .
6
-
7
- RUN pip install --no-cache-dir -r requirements.txt
8
-
9
- COPY . .
10
-
11
  CMD ["gunicorn", "--workers", "1", "--bind", "0.0.0.0:8080", "app:app"]
 
1
+ FROM python:3.10.12
2
+
3
+ WORKDIR /src
4
+
5
+ COPY requirements.txt .
6
+
7
+ RUN pip install --no-cache-dir -r requirements.txt
8
+
9
+ COPY . .
10
+
11
  CMD ["gunicorn", "--workers", "1", "--bind", "0.0.0.0:8080", "app:app"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ahmed Saqr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,11 +1,107 @@
1
- ---
2
- title: Heart Attack
3
- emoji: ⚑
4
- colorFrom: yellow
5
- colorTo: blue
6
- sdk: docker
7
- pinned: false
8
- license: apache-2.0
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Heart Attack EDA and Detection
2
+
3
+ This project provides a machine learning solution for heart attack detection using Flask and Docker. The system performs exploratory data analysis (EDA) and implements a prediction model for heart attack risk assessment.
4
+
5
+ ## Prerequisites
6
+
7
+ ### Installing Anaconda/Miniconda
8
+
9
+ 1. Download Anaconda or Miniconda:
10
+ - [Anaconda](https://www.anaconda.com/products/distribution)
11
+ - [Miniconda](https://docs.conda.io/en/latest/miniconda.html)
12
+
13
+ 2. Follow the installation instructions for your operating system:
14
+ - Windows: Run the installer executable
15
+ - Linux: `bash Anaconda-latest-Linux-x86_64.sh`
16
+ - macOS: `bash Anaconda-latest-MacOSX-x86_64.sh`
17
+
18
+ 3. Verify installation:
19
+ ```bash
20
+ conda --version
21
+ ```
22
+
23
+ ### Installing Docker
24
+
25
+ 1. Download Docker Desktop:
26
+ - [Docker Desktop](https://www.docker.com/products/docker-desktop)
27
+
28
+ 2. Installation by OS:
29
+ - Windows: Run the Docker Desktop Installer
30
+ - macOS: Drag Docker to Applications folder
31
+ - Linux: Follow the [official guide](https://docs.docker.com/engine/install/)
32
+
33
+ 3. Verify installation:
34
+ ```bash
35
+ docker --version
36
+ ```
37
+
38
+ ## Project Setup
39
+
40
+ 1. Clone the repository:
41
+ ```bash
42
+ git clone https://github.com/ahmedhassan456/heart_attack_EDA_and_detection.git
43
+ cd heart_attack_EDA_and_detection
44
+ ```
45
+
46
+ 2. Create and activate Conda environment:
47
+ ```bash
48
+ conda create -n heart_attack_env python=3.10.12
49
+ conda activate heart_attack_env
50
+ ```
51
+
52
+ 3. Install required packages:
53
+ ```bash
54
+ pip install -r requirements.txt
55
+ ```
56
+
57
+ ## Local Development
58
+
59
+ 1. Activate the Conda environment:
60
+ ```bash
61
+ conda activate heart_attack_env
62
+ ```
63
+
64
+ 2. Run the Flask application:
65
+ ```bash
66
+ python deployment/app.py
67
+ ```
68
+
69
+ 3. Access the application at `http://localhost:8000`
70
+
71
+ ## Docker Deployment
72
+
73
+ 1. Build the Docker image:
74
+ ```bash
75
+ docker build -t heart-attack-detection .
76
+ ```
77
+
78
+ 2. Run the Docker container:
79
+ ```bash
80
+ docker run -it -p 8000:8000 heart-attack-detection
81
+ ```
82
+
83
+ 3. Access the application at `http://127.0.0.1:8000`
84
+
85
+ ## Project Structure
86
+
87
+ ```
88
+ Heart Attack EDA and Detection/
89
+ β”œβ”€β”€ deployment # Folder contain the deployment files using Flask
90
+ β”œβ”€β”€ controller # Floder contain files to load and predict the model
91
+ β”œβ”€β”€ models/ # Trained model files
92
+ β”œβ”€β”€ templates/ # HTML templates
93
+ β”œβ”€β”€ app.py # Flask application
94
+ β”œβ”€β”€ test_model # Folder contain the notebook and the data
95
+ β”œβ”€β”€ Dockerfile # Docker configuration
96
+ β”œβ”€β”€ requirements.txt # Python dependencies
97
+ └── README.md # Project documentation
98
+ ```
99
+
100
+ ## API Endpoints
101
+
102
+ - `/`: Home page
103
+ - `/predict`: Endpoint for heart attack prediction
104
+
105
+ ## License
106
+
107
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request
2
+ from controller.GetPredictions import GetPredictions
3
+ from controller.LoadModel import LoadModel
4
+
5
+ app = Flask(__name__)
6
+
7
+ model = LoadModel('deployment/models/heart_attack_detection_model_99.3%.pkl')
8
+
9
+ @app.route('/')
10
+ def home():
11
+ return render_template('home.html')
12
+
13
+ @app.route('/predict', methods=['POST'])
14
+ def predict():
15
+ if request.method == 'POST':
16
+ inputs = request.form.to_dict()
17
+ prediction = GetPredictions(model, inputs)
18
+
19
+ return render_template('result.html', prediction=prediction)
20
+
21
+ if __name__ == '__main__':
22
+ app.run(debug=True, host="0.0.0.0", port=8000)
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ numpy==1.26.4
2
+ pandas==2.2.2
3
+ matplotlib==3.7.5
4
+ seaborn==0.12.2
5
+ scikit-learn==1.2.2
6
+ imbalanced-learn==0.12.4
7
+ optuna==4.1.0
8
+ xgboost==2.0.3
9
+ flask==3.1.0
10
+ gunicorn==23.0.0