Spaces:
Sleeping
Sleeping
Update prediction.py
Browse files- prediction.py +5 -6
prediction.py
CHANGED
@@ -1,16 +1,15 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import joblib
|
4 |
-
|
5 |
-
from sklearn.pipeline import Pipeline
|
6 |
-
from xgboost import XGBClassifier
|
7 |
|
8 |
def app():
|
9 |
st.title("Transaction Data Input")
|
10 |
st.write("Choose to upload a CSV file or manually input transaction data.")
|
11 |
|
12 |
# Load pre-trained model
|
13 |
-
|
|
|
14 |
|
15 |
# Option to choose upload or manual input
|
16 |
option = st.radio("Select input method:", ("Upload CSV", "Manual Input"))
|
@@ -31,7 +30,7 @@ def app():
|
|
31 |
data['prediction'] = data['prediction'].map({1: 'Fraud Transactions', 0: 'Not Fraud Transactions'})
|
32 |
|
33 |
st.write("Predictions:")
|
34 |
-
st.write(data[['nameOrig', 'nameDest', 'prediction']])
|
35 |
|
36 |
elif option == "Manual Input":
|
37 |
st.write("Manually input data:")
|
@@ -71,7 +70,7 @@ def app():
|
|
71 |
manual_data['prediction'] = manual_data['prediction'].map({1: 'Fraud Transactions', 0: 'Not Fraud Transactions'})
|
72 |
|
73 |
st.write("Predictions:")
|
74 |
-
st.write(manual_data[['nameOrig', 'nameDest', 'prediction']])
|
75 |
|
76 |
if __name__ == "__main__":
|
77 |
app()
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import joblib
|
4 |
+
|
|
|
|
|
5 |
|
6 |
def app():
|
7 |
st.title("Transaction Data Input")
|
8 |
st.write("Choose to upload a CSV file or manually input transaction data.")
|
9 |
|
10 |
# Load pre-trained model
|
11 |
+
with open('model.pkl', 'rb') as file_1:
|
12 |
+
model = joblib.load(file_1)
|
13 |
|
14 |
# Option to choose upload or manual input
|
15 |
option = st.radio("Select input method:", ("Upload CSV", "Manual Input"))
|
|
|
30 |
data['prediction'] = data['prediction'].map({1: 'Fraud Transactions', 0: 'Not Fraud Transactions'})
|
31 |
|
32 |
st.write("Predictions:")
|
33 |
+
st.write(data[['type','nameOrig', 'nameDest', 'prediction']])
|
34 |
|
35 |
elif option == "Manual Input":
|
36 |
st.write("Manually input data:")
|
|
|
70 |
manual_data['prediction'] = manual_data['prediction'].map({1: 'Fraud Transactions', 0: 'Not Fraud Transactions'})
|
71 |
|
72 |
st.write("Predictions:")
|
73 |
+
st.write(manual_data[['type','nameOrig', 'nameDest', 'prediction']])
|
74 |
|
75 |
if __name__ == "__main__":
|
76 |
app()
|