penscola commited on
Commit
3493d9e
1 Parent(s): bb5357f

Upload 3 files

Browse files
Files changed (3) hide show
  1. Random-Forest-Regressor.pkl +3 -0
  2. app.py +69 -0
  3. requirements.txt +5 -0
Random-Forest-Regressor.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcf9fc0ead5c22e855b1bbd75856946d09fe8c1396116e803753b7246e2b25f0
3
+ size 16681902
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import pickle
4
+ import gradio as gr
5
+
6
+ from sklearn.model_selection import train_test_split
7
+ from sklearn.preprocessing import MinMaxScaler
8
+ from sklearn.model_selection import GridSearchCV
9
+ from sklearn.ensemble import RandomForestRegressor
10
+
11
+ # Load the saved full pipeline from the file
12
+ model_file = '/media/penscola/Penscola@Tech/Projects/Gold-Prediction/model/Random-Forest-Regressor.pkl'
13
+
14
+ with open(model_file, 'rb') as f_in:
15
+ scaler, model = pickle.load(f_in)
16
+
17
+ # Define the predict function
18
+ def predict(SPX, USO, SLV, EUR_USD):
19
+ # Create a DataFrame from the input data
20
+ input_data = pd.DataFrame({
21
+ 'SPX': [SPX] if SPX is not None else [0], # Replace None with default value
22
+ 'USO': [USO] if USO is not None else [0], # Replace None with default value
23
+ 'SLV': [SLV] if SLV is not None else [0], # Replace None with default value
24
+ 'EUR_USD': [EUR_USD] if EUR_USD is not None else [0], # Replace None with default value
25
+ })
26
+
27
+
28
+ # Make predictions using the loaded logistic regression model
29
+ #predict probabilities
30
+ predictions = model.predict(input_data)
31
+ #take the index of the maximum probability
32
+
33
+
34
+ #return predictions[0]
35
+ return(f'[Info] Predicted probabilities{predictions}')
36
+
37
+ # Setting Gradio App Interface
38
+ with gr.Blocks(css=".gradio-container {background-color:grey }",theme=gr.themes.Base(primary_hue='blue'),title='Uriel') as demo:
39
+ gr.Markdown("# Gold Price prediction #\n*This App allows the user to predict the price of Gold.*")
40
+
41
+ # Receiving ALL Input Data here
42
+ gr.Markdown("**Demographic Data**")
43
+ with gr.Row():
44
+ gender = gr.Number(label="Standard & Poor's Index")
45
+ SeniorCitizen = gr.Number(label="United State Oil Fund")
46
+ Partner = gr.Number(label="Silver Price")
47
+ Dependents = gr.Number(label="EURO_Dollar Exchange")
48
+
49
+
50
+ # Output Prediction
51
+ output = gr.Text(label="Outcome")
52
+ submit_button = gr.Button("Predict")
53
+
54
+ submit_button.click(fn= predict,
55
+ outputs= output,
56
+ inputs=[gender, SeniorCitizen, Partner, Dependents],
57
+
58
+ ),
59
+
60
+ # Add the reset and flag buttons
61
+ def clear():
62
+ output.value = ""
63
+ return 'Predicted values have been reset'
64
+
65
+ clear_btn = gr.Button("Reset", variant="primary")
66
+ clear_btn.click(fn=clear, inputs=None, outputs=output)
67
+
68
+
69
+ demo.launch(inbrowser = True)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ sklearn==0.0.post9
2
+ pandas==2.1.1
3
+ numpy==1.25.2
4
+ seaborn==0.12.2
5
+ matplotlib==3.8.0