Spaces:
Sleeping
Sleeping
initial commit
Browse files
app.py
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# coding: utf-8
|
3 |
-
|
4 |
-
# In[4]:
|
5 |
-
|
6 |
-
|
7 |
-
import pickle
|
8 |
-
import pandas as pd
|
9 |
-
import gradio as gr
|
10 |
-
import warnings
|
11 |
-
warnings.filterwarnings('ignore')
|
12 |
-
|
13 |
-
# Load the trained model
|
14 |
-
model = pickle.load(open('GradientBoosting.pkl', 'rb'))
|
15 |
-
|
16 |
-
def word_happiness(Standard_Error, Economy_GDP_per_Capita, Family, Freedom, Trust_Government_Corruption, Generosity, Dystopia_Residual):
|
17 |
-
# Prepare the input data as a DataFrame
|
18 |
-
data = pd.DataFrame({
|
19 |
-
'Standard_Error': [Standard_Error],
|
20 |
-
'Economy_GDP_per_Capita': [Economy_GDP_per_Capita],
|
21 |
-
'Family': [Family],
|
22 |
-
'Freedom': [Freedom],
|
23 |
-
'Trust_Government_Corruption': [Trust_Government_Corruption],
|
24 |
-
'Generosity': [Generosity],
|
25 |
-
'Dystopia_Residual': [Dystopia_Residual]
|
26 |
-
})
|
27 |
-
|
28 |
-
# Perform the prediction
|
29 |
-
prediction = model.predict(data)
|
30 |
-
return prediction[0]
|
31 |
-
|
32 |
-
# Create the input components
|
33 |
-
input_components = [
|
34 |
-
gr.inputs.Number(label="Standard Error"),
|
35 |
-
gr.inputs.Number(label="Economy GDP per Capita"),
|
36 |
-
gr.inputs.Number(label="Family"),
|
37 |
-
gr.inputs.Number(label="Freedom"),
|
38 |
-
gr.inputs.Number(label="Trust Government Corruption"),
|
39 |
-
gr.inputs.Number(label="Generosity"),
|
40 |
-
gr.inputs.Number(label="Dystopia Residual")
|
41 |
-
]
|
42 |
-
|
43 |
-
# Create the interface
|
44 |
-
interface = gr.Interface(
|
45 |
-
fn=word_happiness,
|
46 |
-
inputs=input_components,
|
47 |
-
outputs="number",
|
48 |
-
title="Word Happiness Report Project",
|
49 |
-
description="Word Happiness Report Project."
|
50 |
-
)
|
51 |
-
|
52 |
-
# Launch the interface
|
53 |
-
interface.launch()
|
54 |
-
|
55 |
-
|
56 |
-
# In[ ]:
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|