Amit8281 commited on
Commit
d1ab01c
1 Parent(s): c25141f

initial commit

Browse files
Files changed (2) hide show
  1. app.py +68 -0
  2. scaler.pkl +3 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[1]:
5
+
6
+
7
+ import pickle
8
+ import pandas as pd
9
+ import gradio as gr
10
+ import warnings
11
+ from sklearn.preprocessing import StandardScaler
12
+
13
+ warnings.filterwarnings('ignore')
14
+
15
+ # Load the trained model
16
+ model = pickle.load(open('GradientBoosting.pkl', 'rb'))
17
+
18
+ # Load the scaler model
19
+ scaler = pickle.load(open('scaler.pkl', 'rb'))
20
+
21
+ def word_happiness(Standard_Error, Economy_GDP_per_Capita, Family, Freedom, Trust_Government_Corruption, Generosity, Dystopia_Residual):
22
+ # Prepare the input data as a DataFrame
23
+ data = pd.DataFrame({
24
+ 'Standard_Error': [Standard_Error],
25
+ 'Economy_GDP_per_Capita': [Economy_GDP_per_Capita],
26
+ 'Family': [Family],
27
+ 'Freedom': [Freedom],
28
+ 'Trust_Government_Corruption': [Trust_Government_Corruption],
29
+ 'Generosity': [Generosity],
30
+ 'Dystopia_Residual': [Dystopia_Residual]
31
+ })
32
+
33
+ # Scale the input data
34
+ scaled_data = scaler.transform(data)
35
+
36
+ # Perform the prediction
37
+ prediction = model.predict(scaled_data)
38
+ return prediction[0]
39
+
40
+ # Create the input components
41
+ input_components = [
42
+ gr.inputs.Number(label="Standard Error"),
43
+ gr.inputs.Number(label="Economy GDP per Capita"),
44
+ gr.inputs.Number(label="Family"),
45
+ gr.inputs.Number(label="Freedom"),
46
+ gr.inputs.Number(label="Trust Government Corruption"),
47
+ gr.inputs.Number(label="Generosity"),
48
+ gr.inputs.Number(label="Dystopia Residual")
49
+ ]
50
+
51
+ # Create the interface
52
+ interface = gr.Interface(
53
+ fn=word_happiness,
54
+ inputs=input_components,
55
+ outputs="number",
56
+ title="World Happiness Report Project",
57
+ description="World Happiness Report Project."
58
+ )
59
+
60
+ # Launch the interface
61
+ interface.launch()
62
+
63
+
64
+ # In[ ]:
65
+
66
+
67
+
68
+
scaler.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de6bffb5f3c78864468e0a5a732841c00df6553e02925f603532d63e0605d066
3
+ size 828