Spaces:
Sleeping
Sleeping
dev test
Browse files
app.py
CHANGED
|
@@ -28,23 +28,25 @@ def predict_risk(file):
|
|
| 28 |
df = pd.read_excel(file.name)
|
| 29 |
else:
|
| 30 |
return pd.DataFrame({"Error": ["Unsupported file format. Please upload .csv or .xlsx"]})
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
# Step A: Extract the first column as Sample_IDs
|
| 33 |
-
# Handle both named and unnamed first columns
|
| 34 |
-
first_col_name = df.columns[0]
|
| 35 |
-
Sample_IDs = df.iloc[:, 0].values
|
| 36 |
|
| 37 |
-
# Step B: Extract all other columns as Model_Features (the floats)
|
| 38 |
-
Model_Features = df[hf_prediction_features].values
|
| 39 |
|
| 40 |
-
# Get predictions
|
| 41 |
-
prediction = predictor.predict(Model_Features)[0]
|
| 42 |
-
probabilities = predictor.predict_proba(Model_Features).iloc[0].to_dict()
|
| 43 |
|
| 44 |
-
return {
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
}
|
| 48 |
|
| 49 |
|
| 50 |
# # ---------------------------------------------------------
|
|
|
|
| 28 |
df = pd.read_excel(file.name)
|
| 29 |
else:
|
| 30 |
return pd.DataFrame({"Error": ["Unsupported file format. Please upload .csv or .xlsx"]})
|
| 31 |
+
|
| 32 |
+
print("data loaded")
|
| 33 |
|
| 34 |
+
# # Step A: Extract the first column as Sample_IDs
|
| 35 |
+
# # Handle both named and unnamed first columns
|
| 36 |
+
# first_col_name = df.columns[0]
|
| 37 |
+
# Sample_IDs = df.iloc[:, 0].values
|
| 38 |
|
| 39 |
+
# # Step B: Extract all other columns as Model_Features (the floats)
|
| 40 |
+
# Model_Features = df[hf_prediction_features].values
|
| 41 |
|
| 42 |
+
# # Get predictions
|
| 43 |
+
# prediction = predictor.predict(Model_Features)[0]
|
| 44 |
+
# probabilities = predictor.predict_proba(Model_Features).iloc[0].to_dict()
|
| 45 |
|
| 46 |
+
# return {
|
| 47 |
+
# "prediction": str(prediction),
|
| 48 |
+
# "probabilities": probabilities
|
| 49 |
+
# }
|
| 50 |
|
| 51 |
|
| 52 |
# # ---------------------------------------------------------
|