Roberta2024 commited on
Commit
26b9374
·
verified ·
1 Parent(s): 513edc2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import gradio as gr
2
  import pandas as pd
3
- import numpy as np
4
  import joblib, os
5
 
6
  script_dir = os.path.dirname(os.path.abspath(__file__))
@@ -11,13 +10,14 @@ model_path = os.path.join(script_dir, 'toolkit', 'Random Forest Classifier.jobli
11
  pipeline = joblib.load(pipeline_path)
12
  model = joblib.load(model_path)
13
 
14
- # Update predict function to handle new parameters
 
 
 
 
15
  def predict(age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak, slope, ca, thal):
16
  # Create a dataframe with the input data
17
-
18
- input_df = pd.read_csv("heart.csv")
19
- '''
20
- input_df = pd.DataFrame({
21
  'age': [age],
22
  'sex': [sex],
23
  'cp': [cp],
@@ -32,7 +32,7 @@ def predict(age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak,
32
  'ca': [ca],
33
  'thal': [thal]
34
  })
35
- '''
36
  # Process input data using the pipeline
37
  X_processed = pipeline.transform(input_df)
38
 
 
1
  import gradio as gr
2
  import pandas as pd
 
3
  import joblib, os
4
 
5
  script_dir = os.path.dirname(os.path.abspath(__file__))
 
10
  pipeline = joblib.load(pipeline_path)
11
  model = joblib.load(model_path)
12
 
13
+ # Load the heart.csv data
14
+ heart_data_path = os.path.join(script_dir, 'heart.csv')
15
+ heart_df = pd.read_csv(heart_data_path)
16
+
17
+ # Define the predict function
18
  def predict(age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak, slope, ca, thal):
19
  # Create a dataframe with the input data
20
+ input_df = pd.DataFrame({
 
 
 
21
  'age': [age],
22
  'sex': [sex],
23
  'cp': [cp],
 
32
  'ca': [ca],
33
  'thal': [thal]
34
  })
35
+
36
  # Process input data using the pipeline
37
  X_processed = pipeline.transform(input_df)
38