-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
44 lines (36 loc) · 1.42 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from flask import Flask, render_template_string
from data_preprocessing import preprocess_data
from model_pipeline import train_and_evaluate, prepare_data, plot_correlation_matrix
#from ClusteringNLP import execute_all_nlp_and_clustering_functions
import pandas as pd
app = Flask(__name__)
# HTML template as a Python string
HTML_TEMPLATE = """
<!DOCTYPE html>
<html>
<head>
<title>Model Evaluation Results</title>
</head>
<body>
<h1>Data Head</h1>
<pre>{{ data_head }}</pre>
<h1>Model Evaluation Results</h1>
<pre>{{ model_results }}</pre>
</body>
</html>
"""
@app.route('/')
def show_results():
# Path to your dataset
df_path = 'D:\\Northeastern\\Semester 2\\Python\\Optical Diseases\\full_df.csv'
df_cleaned = preprocess_data(df_path)
# Mock-up for displaying purposes - adjust as necessary
X = df_cleaned[['Patient Age', 'Patient Sex', 'D', 'H']] # Example feature selection
y = df_cleaned['MONR'] # Example target variable
model_results = train_and_evaluate(X, y)
print("Model Results from train_and_evaluate:", model_results) # Debug print
#operations_summary = execute_all_nlp_and_clustering_functions(df_cleaned)
#summary_str = "\n".join(f"{key}: {value}" for key, value in operations_summary.items())
return render_template_string(HTML_TEMPLATE, data_head=df_cleaned.head().to_string(), model_results=model_results)
if __name__ == '__main__':
app.run(debug=True)