Spaces:
Sleeping
Sleeping
initial commit
Browse files- GradientBoosting.pkl +3 -0
- app.ipynb +119 -0
- requirements.txt +1 -0
GradientBoosting.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:034fc8eb71aec73ccdc3aef0ddd2632a38565fa7d42d014bc9605e41b22a6a81
|
3 |
+
size 117183
|
app.ipynb
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 4,
|
6 |
+
"id": "6e9a9546",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [
|
9 |
+
{
|
10 |
+
"name": "stdout",
|
11 |
+
"output_type": "stream",
|
12 |
+
"text": [
|
13 |
+
"Running on local URL: http://127.0.0.1:7863\n",
|
14 |
+
"\n",
|
15 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
16 |
+
]
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"data": {
|
20 |
+
"text/html": [
|
21 |
+
"<div><iframe src=\"http://127.0.0.1:7863/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
22 |
+
],
|
23 |
+
"text/plain": [
|
24 |
+
"<IPython.core.display.HTML object>"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
"metadata": {},
|
28 |
+
"output_type": "display_data"
|
29 |
+
},
|
30 |
+
{
|
31 |
+
"data": {
|
32 |
+
"text/plain": []
|
33 |
+
},
|
34 |
+
"execution_count": 4,
|
35 |
+
"metadata": {},
|
36 |
+
"output_type": "execute_result"
|
37 |
+
}
|
38 |
+
],
|
39 |
+
"source": [
|
40 |
+
"import pickle\n",
|
41 |
+
"import pandas as pd\n",
|
42 |
+
"import gradio as gr\n",
|
43 |
+
"import warnings\n",
|
44 |
+
"warnings.filterwarnings('ignore')\n",
|
45 |
+
"\n",
|
46 |
+
"# Load the trained model\n",
|
47 |
+
"model = pickle.load(open('GradientBoosting.pkl', 'rb'))\n",
|
48 |
+
"\n",
|
49 |
+
"def word_happiness(Standard_Error, Economy_GDP_per_Capita, Family, Freedom, Trust_Government_Corruption, Generosity, Dystopia_Residual):\n",
|
50 |
+
" # Prepare the input data as a DataFrame\n",
|
51 |
+
" data = pd.DataFrame({\n",
|
52 |
+
" 'Standard_Error': [Standard_Error],\n",
|
53 |
+
" 'Economy_GDP_per_Capita': [Economy_GDP_per_Capita],\n",
|
54 |
+
" 'Family': [Family],\n",
|
55 |
+
" 'Freedom': [Freedom],\n",
|
56 |
+
" 'Trust_Government_Corruption': [Trust_Government_Corruption],\n",
|
57 |
+
" 'Generosity': [Generosity],\n",
|
58 |
+
" 'Dystopia_Residual': [Dystopia_Residual]\n",
|
59 |
+
" })\n",
|
60 |
+
"\n",
|
61 |
+
" # Perform the prediction\n",
|
62 |
+
" prediction = model.predict(data)\n",
|
63 |
+
" return prediction[0]\n",
|
64 |
+
"\n",
|
65 |
+
"# Create the input components\n",
|
66 |
+
"input_components = [\n",
|
67 |
+
" gr.inputs.Number(label=\"Standard Error\"),\n",
|
68 |
+
" gr.inputs.Number(label=\"Economy GDP per Capita\"),\n",
|
69 |
+
" gr.inputs.Number(label=\"Family\"),\n",
|
70 |
+
" gr.inputs.Number(label=\"Freedom\"),\n",
|
71 |
+
" gr.inputs.Number(label=\"Trust Government Corruption\"),\n",
|
72 |
+
" gr.inputs.Number(label=\"Generosity\"),\n",
|
73 |
+
" gr.inputs.Number(label=\"Dystopia Residual\")\n",
|
74 |
+
"]\n",
|
75 |
+
"\n",
|
76 |
+
"# Create the interface\n",
|
77 |
+
"interface = gr.Interface(\n",
|
78 |
+
" fn=word_happiness,\n",
|
79 |
+
" inputs=input_components,\n",
|
80 |
+
" outputs=\"number\",\n",
|
81 |
+
" title=\"Word Happiness Report Project\",\n",
|
82 |
+
" description=\"Word Happiness Report Project.\"\n",
|
83 |
+
")\n",
|
84 |
+
"\n",
|
85 |
+
"# Launch the interface\n",
|
86 |
+
"interface.launch()\n"
|
87 |
+
]
|
88 |
+
},
|
89 |
+
{
|
90 |
+
"cell_type": "code",
|
91 |
+
"execution_count": null,
|
92 |
+
"id": "46b8306d",
|
93 |
+
"metadata": {},
|
94 |
+
"outputs": [],
|
95 |
+
"source": []
|
96 |
+
}
|
97 |
+
],
|
98 |
+
"metadata": {
|
99 |
+
"kernelspec": {
|
100 |
+
"display_name": "Python 3 (ipykernel)",
|
101 |
+
"language": "python",
|
102 |
+
"name": "python3"
|
103 |
+
},
|
104 |
+
"language_info": {
|
105 |
+
"codemirror_mode": {
|
106 |
+
"name": "ipython",
|
107 |
+
"version": 3
|
108 |
+
},
|
109 |
+
"file_extension": ".py",
|
110 |
+
"mimetype": "text/x-python",
|
111 |
+
"name": "python",
|
112 |
+
"nbconvert_exporter": "python",
|
113 |
+
"pygments_lexer": "ipython3",
|
114 |
+
"version": "3.9.12"
|
115 |
+
}
|
116 |
+
},
|
117 |
+
"nbformat": 4,
|
118 |
+
"nbformat_minor": 5
|
119 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
scikit-learn == 1.0.2
|