Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files
coolest_styles.css
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
body {
|
3 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
4 |
+
background-color: #282a36;
|
5 |
+
color: #f8f8f2;
|
6 |
+
}
|
7 |
+
|
8 |
+
.container {
|
9 |
+
max-width: 800px;
|
10 |
+
margin: auto;
|
11 |
+
text-align: center;
|
12 |
+
padding: 40px;
|
13 |
+
border: 3px solid #6272a4;
|
14 |
+
border-radius: 15px;
|
15 |
+
background-color: #44475a;
|
16 |
+
box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
|
17 |
+
}
|
18 |
+
|
19 |
+
.input-group,
|
20 |
+
.output-group {
|
21 |
+
margin-bottom: 30px;
|
22 |
+
}
|
23 |
+
|
24 |
+
label {
|
25 |
+
display: inline-block;
|
26 |
+
width: 300px;
|
27 |
+
text-align: right;
|
28 |
+
margin-right: 20px;
|
29 |
+
font-size: 18px;
|
30 |
+
font-weight: bold;
|
31 |
+
}
|
32 |
+
|
33 |
+
input,
|
34 |
+
select {
|
35 |
+
width: 300px;
|
36 |
+
padding: 10px;
|
37 |
+
border-radius: 8px;
|
38 |
+
border: 2px solid #6272a4;
|
39 |
+
background-color: #f8f8f2;
|
40 |
+
color: #282a36;
|
41 |
+
font-size: 18px;
|
42 |
+
}
|
43 |
+
|
44 |
+
.predict-button {
|
45 |
+
padding: 15px 30px;
|
46 |
+
background-color: #50fa7b;
|
47 |
+
color: #282a36;
|
48 |
+
border: none;
|
49 |
+
border-radius: 8px;
|
50 |
+
cursor: pointer;
|
51 |
+
font-size: 20px;
|
52 |
+
font-weight: bold;
|
53 |
+
transition: background-color 0.3s ease;
|
54 |
+
}
|
55 |
+
|
56 |
+
.predict-button:hover {
|
57 |
+
background-color: #5af78e;
|
58 |
+
}
|
59 |
+
|
60 |
+
/* Range slider styles */
|
61 |
+
input[type=range] {
|
62 |
+
width: 100%;
|
63 |
+
height: 25px;
|
64 |
+
background: #44475a;
|
65 |
+
outline: none;
|
66 |
+
opacity: 0.7;
|
67 |
+
border-radius: 20px;
|
68 |
+
box-shadow: 0 0 5px #6272a4;
|
69 |
+
-webkit-appearance: none;
|
70 |
+
}
|
71 |
+
|
72 |
+
input[type=range]::-webkit-slider-thumb {
|
73 |
+
width: 25px;
|
74 |
+
height: 25px;
|
75 |
+
background: #50fa7b;
|
76 |
+
cursor: pointer;
|
77 |
+
border-radius: 50%;
|
78 |
+
box-shadow: 0 0 5px #6272a4;
|
79 |
+
-webkit-appearance: none;
|
80 |
+
}
|
81 |
+
|
82 |
+
input[type=range]:focus {
|
83 |
+
opacity: 1;
|
84 |
+
}
|
fastapi_app_updated.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from fastapi import FastAPI, HTTPException
|
3 |
+
from fastapi.responses import FileResponse
|
4 |
+
from fastapi.staticfiles import StaticFiles
|
5 |
+
import pickle
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
# Serve static files like CSS
|
10 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
11 |
+
|
12 |
+
# Load the model
|
13 |
+
with open('logistic_model_reduced.pkl', 'rb') as file:
|
14 |
+
model = pickle.load('/Users/matheusrech/Documents/logistic_model_reduced_files/logistic_model_reduced.pkl')
|
15 |
+
|
16 |
+
@app.get("/")
|
17 |
+
def read_root():
|
18 |
+
return FileResponse("/Users/matheusrech/Documents/logistic_model_reduced_files/final_interactive_prototype_with_updated_title.html")
|
19 |
+
|
20 |
+
@app.post("/predict")
|
21 |
+
async def predict(features: list):
|
22 |
+
try:
|
23 |
+
prediction = model.predict([features])[0]
|
24 |
+
return {"prediction": int(prediction)}
|
25 |
+
except Exception as e:
|
26 |
+
raise HTTPException(status_code=500, detail=str(e))
|
final_interactive_prototype_with_updated_title.html
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<!DOCTYPE html>
|
3 |
+
|
4 |
+
<html>
|
5 |
+
<head>
|
6 |
+
<title>Medical Prediction Tool</title>
|
7 |
+
<link href="styles.css" rel="stylesheet" type="text/css"/>
|
8 |
+
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
9 |
+
<script>
|
10 |
+
function updateOutput(sliderID, outputID) {
|
11 |
+
var slider = document.getElementById(sliderID);
|
12 |
+
var output = document.getElementById(outputID);
|
13 |
+
output.innerHTML = slider.value;
|
14 |
+
}
|
15 |
+
</script></head>
|
16 |
+
<body>
|
17 |
+
<div class="container">
|
18 |
+
<h1>Major Acute Cardiovascular Events after Liver Transplantation Prediction Tool</h1>
|
19 |
+
<div class="output-group">
|
20 |
+
<h2>Prediction: <span id="prediction"></span></h2>
|
21 |
+
<h2>Probability: <span id="probability"></span></h2>
|
22 |
+
</div>
|
23 |
+
<div class="input-group"><label for="Weight">Patient Weight (kg):</label><input id="Weight" max="200" min="40" oninput="updateOutput('Weight', 'Weight_output')" step="1" type="range" value="120"/><output id="Weight_output">120</output></div><div class="input-group"><label for="Height">Patient Height (cm):</label><input id="Height" max="210" min="140" oninput="updateOutput('Height', 'Height_output')" step="1" type="range" value="175"/><output id="Height_output">175</output></div><div class="input-group"><label for="BodyMassIndex">Body Mass Index (BMI):</label><input id="BodyMassIndex" max="40" min="15" oninput="updateOutput('BodyMassIndex', 'BodyMassIndex_output')" step="1" type="range" value="27"/><output id="BodyMassIndex_output">27</output></div><div class="input-group"><label for="Hematocrit">Hematocrit:</label><input id="Hematocrit" max="60" min="20" oninput="updateOutput('Hematocrit', 'Hematocrit_output')" step="1" type="range" value="40"/><output id="Hematocrit_output">40</output></div><div class="input-group"><label for="Leukocytes">Leukocyte Count:</label><input id="Leukocytes" max="30" min="1" oninput="updateOutput('Leukocytes', 'Leukocytes_output')" step="1" type="range" value="15"/><output id="Leukocytes_output">15</output></div><div class="input-group"><label for="Platelets">Platelets:</label><input id="Platelets" max="600" min="50" oninput="updateOutput('Platelets', 'Platelets_output')" step="1" type="range" value="325"/><output id="Platelets_output">325</output></div><div class="input-group"><label for="TotalBilirubin">TotalBilirubin:</label><input id="TotalBilirubin" max="50" min="0" oninput="updateOutput('TotalBilirubin', 'TotalBilirubin_output')" step="1" type="range" value="25"/><output id="TotalBilirubin_output">25</output></div><div class="input-group"><label for="DirectBilirubin">Direct Bilirubin Level:</label><input id="DirectBilirubin" max="40" min="0" oninput="updateOutput('DirectBilirubin', 'DirectBilirubin_output')" step="1" type="range" value="20"/><output id="DirectBilirubin_output">20</output></div><div class="input-group"><label for="Creatinine">Creatinine Level:</label><input id="Creatinine" max="5" min="0.2" oninput="updateOutput('Creatinine', 'Creatinine_output')" step="1" type="range" value="2.0"/><output id="Creatinine_output">2.0</output></div><div class="input-group"><label for="Urea">Urea Level:</label><input id="Urea" max="150" min="5" oninput="updateOutput('Urea', 'Urea_output')" step="1" type="range" value="77"/><output id="Urea_output">77</output></div><div class="input-group"><label for="ProthrombinTimeActivity">ProthrombinTimeActivity:</label><input id="ProthrombinTimeActivity" max="150" min="50" oninput="updateOutput('ProthrombinTimeActivity', 'ProthrombinTimeActivity_output')" step="1" type="range" value="100"/><output id="ProthrombinTimeActivity_output">100</output></div><div class="input-group"><label for="InternationalNormalizedRatio">InternationalNormalizedRatio:</label><input id="InternationalNormalizedRatio" max="5" min="0.8" oninput="updateOutput('InternationalNormalizedRatio', 'InternationalNormalizedRatio_output')" step="1" type="range" value="2.0"/><output id="InternationalNormalizedRatio_output">2.0</output></div><div class="input-group"><label for="Sodium">Sodium:</label><input id="Sodium" max="160" min="120" oninput="updateOutput('Sodium', 'Sodium_output')" step="1" type="range" value="140"/><output id="Sodium_output">140</output></div><div class="input-group"><label for="Potassium">Potassium:</label><input id="Potassium" max="7" min="2" oninput="updateOutput('Potassium', 'Potassium_output')" step="1" type="range" value="4"/><output id="Potassium_output">4</output></div><div class="input-group"><label for="Albumin">Albumin:</label><input id="Albumin" max="5" min="1" oninput="updateOutput('Albumin', 'Albumin_output')" step="1" type="range" value="3"/><output id="Albumin_output">3</output></div><div class="input-group"><label for="AST">Aspartate Aminotransferase (AST):</label><input id="AST" max="300" min="5" oninput="updateOutput('AST', 'AST_output')" step="1" type="range" value="152"/><output id="AST_output">152</output></div><div class="input-group"><label for="ALT">Alanine Aminotransferase (ALT):</label><input id="ALT" max="300" min="5" oninput="updateOutput('ALT', 'ALT_output')" step="1" type="range" value="152"/><output id="ALT_output">152</output></div><div class="input-group"><label for="GGT">Gamma-Glutamyl Transferase (GGT):</label><input id="GGT" max="300" min="5" oninput="updateOutput('GGT', 'GGT_output')" step="1" type="range" value="152"/><output id="GGT_output">152</output></div><div class="input-group"><label for="AlkalinePhosphatase">AlkalinePhosphatase:</label><input id="AlkalinePhosphatase" max="400" min="20" oninput="updateOutput('AlkalinePhosphatase', 'AlkalinePhosphatase_output')" step="1" type="range" value="210"/><output id="AlkalinePhosphatase_output">210</output></div><div class="input-group"><label for="BloodGroup">BloodGroup:</label><select id="BloodGroup"><option value="1">A</option><option value="2">B</option><option value="3">C</option><option value="4">D</option></select></div><div class="input-group"><label for="CongestiveHeartFailure">CongestiveHeartFailure:</label><select id="CongestiveHeartFailure"><option value="0">No</option><option value="1">Yes</option></select></div><div class="input-group"><label for="Angioplasty">Angioplasty:</label><select id="Angioplasty"><option value="0">No</option><option value="1">Yes</option></select></div><div class="input-group"><label for="Dyslipidemia">Dyslipidemia:</label><select id="Dyslipidemia"><option value="0">No</option><option value="1">Yes</option></select></div><div class="input-group"><label for="ValveReplacement">Valve Replacement Type:</label><select id="ValveReplacement"><option value="0">No</option><option value="1">Metallic</option><option value="2">Biological</option></select></div><div class="input-group"><label for="NonInvasiveMethod">Non-Invasive Method Used:</label><select id="NonInvasiveMethod"><option value="0">No</option><option value="1">Yes</option></select></div><div class="input-group"><label for="Stroke">Type of Stroke:</label><select id="Stroke"><option value="0">No</option><option value="1">Ischemic</option><option value="2">Hemorrhagic</option></select></div><div class="input-group"><label for="DiabetesMellitus">DiabetesMellitus:</label><select id="DiabetesMellitus"><option value="0">No</option><option value="1">Yes</option></select></div><button class="predict-button" onclick="this.innerHTML = 'Predicting...'; this.style.backgroundColor = '#ff5555';">Predict</button></div>
|
24 |
+
<script>
|
25 |
+
function getPrediction() {
|
26 |
+
const Weight = $('#Weight').val();
|
27 |
+
const SpontaneousBacterialPeritonitis = $('#SpontaneousBacterialPeritonitis').val();
|
28 |
+
$.post('http://localhost:5000/predict', {
|
29 |
+
Weight,
|
30 |
+
SpontaneousBacterialPeritonitis,
|
31 |
+
})
|
32 |
+
.done(function(data) {
|
33 |
+
$('#prediction').text(data.prediction);
|
34 |
+
$('#probability').text(data.probability);
|
35 |
+
})
|
36 |
+
.fail(function(xhr, status, error) {
|
37 |
+
alert('Prediction failed: ' + error);
|
38 |
+
});
|
39 |
+
}
|
40 |
+
</script>
|
41 |
+
</body>
|
42 |
+
</html>
|
logistic_model_reduced.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8bbcfd84702cf4fd66dcdf1156c7f48ab41c56fb00933ecd0659a3ba732e326f
|
3 |
+
size 1120
|
logistic_model_reduced_params.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"C": 0.5, "class_weight": "balanced", "dual": false, "fit_intercept": true, "intercept_scaling": 1, "l1_ratio": null, "max_iter": 100, "multi_class": "auto", "n_jobs": null, "penalty": "l2", "random_state": 42, "solver": "lbfgs", "tol": 0.0001, "verbose": 0, "warm_start": false}
|