rufimelo commited on
Commit
7214c18
·
1 Parent(s): 14698c0
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
app/app.py CHANGED
@@ -28,10 +28,6 @@ wine_list = wine_similarity_df['NAME'].unique()
28
 
29
 
30
 
31
-
32
-
33
-
34
-
35
  ## Layout ##
36
 
37
  dashboard_layout = html.Div([
@@ -40,7 +36,7 @@ dashboard_layout = html.Div([
40
  dcc.Graph(id='graph-content'),
41
 
42
 
43
-
44
 
45
  html.H1(children='Wine Recommender', style={'textAlign':'center'}),
46
  dcc.Dropdown(wine_list, wine_list[0], id='dropdown-selection'),
@@ -49,6 +45,9 @@ dashboard_layout = html.Div([
49
 
50
 
51
 
 
 
 
52
  wiki_layout = html.Div([
53
  dcc.Link('Dashboard', href='/'),
54
 
@@ -59,11 +58,9 @@ wiki_layout = html.Div([
59
 
60
  html.H3('What is this project about?'),
61
 
62
- html.P('something'),
63
-
64
- html.H3('How does it work?'),
65
 
66
- #Insert image of the system
67
 
68
  html.H3('\'Bout us'),
69
  html.Img(src='/assets/tourdevino_logo.webp', style={'width': '40%', 'height': 'auto', 'display': 'block', 'margin-left': 'auto', 'margin-right': 'auto'}),
@@ -73,11 +70,6 @@ wiki_layout = html.Div([
73
  html.H4('André Catarino'),
74
  html.H4('Dinis Costa'),
75
  html.H4('Paulo Fidalgo'),
76
-
77
-
78
-
79
- html.H3('References'),
80
- html.P('The boiler model was based on the following paper:'),
81
 
82
 
83
  ], className='six columns'),], className='row'),
@@ -101,15 +93,41 @@ def display_page(pathname):
101
  @app.callback(
102
  Output('graph-content', 'figure'),
103
  Output('wine-recommendation', 'children'),
 
104
  Input('dropdown-selection', 'value')
105
  )
106
  def update_graph(value):
 
107
  recommended_wines = None
108
  if value:
109
  recommended_wines = core.get_top_5_similar_wines(value, wine_similarity_df)[1:]
110
  recommended_wines = "; ".join(recommended_wines)
111
 
112
- return px.line(df, x='year', y='pop'), recommended_wines
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
 
115
  if __name__ == "__main__":
 
28
 
29
 
30
 
 
 
 
 
31
  ## Layout ##
32
 
33
  dashboard_layout = html.Div([
 
36
  dcc.Graph(id='graph-content'),
37
 
38
 
39
+ dcc.Graph(id='world-map-fig'),
40
 
41
  html.H1(children='Wine Recommender', style={'textAlign':'center'}),
42
  dcc.Dropdown(wine_list, wine_list[0], id='dropdown-selection'),
 
45
 
46
 
47
 
48
+
49
+
50
+
51
  wiki_layout = html.Div([
52
  dcc.Link('Dashboard', href='/'),
53
 
 
58
 
59
  html.H3('What is this project about?'),
60
 
61
+ html.P('We are a group of 4 Computer Science Engineering Students with a solid Artificial Intelligence background.'),
62
+ html.P('This project aims to showcase AI applications for improving Wine Tourism for SOGRAPE.'),
 
63
 
 
64
 
65
  html.H3('\'Bout us'),
66
  html.Img(src='/assets/tourdevino_logo.webp', style={'width': '40%', 'height': 'auto', 'display': 'block', 'margin-left': 'auto', 'margin-right': 'auto'}),
 
70
  html.H4('André Catarino'),
71
  html.H4('Dinis Costa'),
72
  html.H4('Paulo Fidalgo'),
 
 
 
 
 
73
 
74
 
75
  ], className='six columns'),], className='row'),
 
93
  @app.callback(
94
  Output('graph-content', 'figure'),
95
  Output('wine-recommendation', 'children'),
96
+ Output('world-map-fig', 'figure'),
97
  Input('dropdown-selection', 'value')
98
  )
99
  def update_graph(value):
100
+ ### Wine Recommendation ###
101
  recommended_wines = None
102
  if value:
103
  recommended_wines = core.get_top_5_similar_wines(value, wine_similarity_df)[1:]
104
  recommended_wines = "; ".join(recommended_wines)
105
 
106
+
107
+ ### World Map of wineyards ###
108
+
109
+ geo_df = pd.read_csv('data/processed_wineyards.csv')
110
+
111
+
112
+ world_map_fig = px.scatter_map(geo_df,
113
+ lat=geo_df['coord_x'],
114
+ lon=geo_df['coord_y'],
115
+ hover_name=geo_df['name'],
116
+ zoom=4,
117
+ hover_data={
118
+ 'IsTouristic': True,
119
+ 'Wine Type': True,
120
+ 'Country': True,
121
+ 'Region': True,
122
+ 'Address': True,
123
+
124
+ },
125
+ title='Wineyards around the world',
126
+ )
127
+
128
+
129
+
130
+ return px.line(df, x='year', y='pop'), recommended_wines, world_map_fig
131
 
132
 
133
  if __name__ == "__main__":
app/dashboard.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 7,
6
  "metadata": {},
7
  "outputs": [
8
  {
@@ -20,11 +20,38 @@
20
  " "
21
  ],
22
  "text/plain": [
23
- "<IPython.lib.display.IFrame at 0x2b21db970>"
24
  ]
25
  },
26
  "metadata": {},
27
  "output_type": "display_data"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
  ],
30
  "source": [
@@ -58,10 +85,6 @@
58
  "\n",
59
  "\n",
60
  "\n",
61
- "\n",
62
- "\n",
63
- "\n",
64
- "\n",
65
  "## Layout ##\n",
66
  "\n",
67
  "dashboard_layout = html.Div([\n",
@@ -70,7 +93,7 @@
70
  " dcc.Graph(id='graph-content'),\n",
71
  "\n",
72
  "\n",
73
- "\n",
74
  "\n",
75
  " html.H1(children='Wine Recommender', style={'textAlign':'center'}),\n",
76
  " dcc.Dropdown(wine_list, wine_list[0], id='dropdown-selection'),\n",
@@ -79,6 +102,9 @@
79
  "\n",
80
  "\n",
81
  "\n",
 
 
 
82
  "wiki_layout = html.Div([\n",
83
  " dcc.Link('Dashboard', href='/'),\n",
84
  "\n",
@@ -89,11 +115,9 @@
89
  "\n",
90
  " html.H3('What is this project about?'),\n",
91
  "\n",
92
- " html.P('something'),\n",
93
- "\n",
94
- " html.H3('How does it work?'),\n",
95
  "\n",
96
- " #Insert image of the system\n",
97
  "\n",
98
  " html.H3('\\'Bout us'),\n",
99
  " html.Img(src='/assets/tourdevino_logo.webp', style={'width': '40%', 'height': 'auto', 'display': 'block', 'margin-left': 'auto', 'margin-right': 'auto'}),\n",
@@ -103,11 +127,6 @@
103
  " html.H4('André Catarino'),\n",
104
  " html.H4('Dinis Costa'),\n",
105
  " html.H4('Paulo Fidalgo'),\n",
106
- " \n",
107
- "\n",
108
- "\n",
109
- " html.H3('References'),\n",
110
- " html.P('The boiler model was based on the following paper:'),\n",
111
  "\n",
112
  "\n",
113
  " ], className='six columns'),], className='row'),\n",
@@ -131,15 +150,41 @@
131
  "@app.callback(\n",
132
  " Output('graph-content', 'figure'),\n",
133
  " Output('wine-recommendation', 'children'),\n",
 
134
  " Input('dropdown-selection', 'value')\n",
135
  ")\n",
136
  "def update_graph(value):\n",
 
137
  " recommended_wines = None\n",
138
  " if value:\n",
139
  " recommended_wines = core.get_top_5_similar_wines(value, wine_similarity_df)[1:]\n",
140
  " recommended_wines = \"; \".join(recommended_wines)\n",
141
  "\n",
142
- " return px.line(df, x='year', y='pop'), recommended_wines\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  "\n",
144
  "\n",
145
  "if __name__ == \"__main__\":\n",
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 6,
6
  "metadata": {},
7
  "outputs": [
8
  {
 
20
  " "
21
  ],
22
  "text/plain": [
23
+ "<IPython.lib.display.IFrame at 0x28f564370>"
24
  ]
25
  },
26
  "metadata": {},
27
  "output_type": "display_data"
28
+ },
29
+ {
30
+ "name": "stderr",
31
+ "output_type": "stream",
32
+ "text": [
33
+ "[2024-09-17 12:44:28,042] ERROR in app: Exception on /_dash-update-component [POST]\n",
34
+ "Traceback (most recent call last):\n",
35
+ " File \"/Users/ruimelo/anaconda3/envs/gan-nlp/lib/python3.10/site-packages/flask/app.py\", line 1473, in wsgi_app\n",
36
+ " response = self.full_dispatch_request()\n",
37
+ " File \"/Users/ruimelo/anaconda3/envs/gan-nlp/lib/python3.10/site-packages/flask/app.py\", line 882, in full_dispatch_request\n",
38
+ " rv = self.handle_user_exception(e)\n",
39
+ " File \"/Users/ruimelo/anaconda3/envs/gan-nlp/lib/python3.10/site-packages/flask/app.py\", line 880, in full_dispatch_request\n",
40
+ " rv = self.dispatch_request()\n",
41
+ " File \"/Users/ruimelo/anaconda3/envs/gan-nlp/lib/python3.10/site-packages/flask/app.py\", line 865, in dispatch_request\n",
42
+ " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]\n",
43
+ " File \"/Users/ruimelo/anaconda3/envs/gan-nlp/lib/python3.10/site-packages/dash/dash.py\", line 1376, in dispatch\n",
44
+ " ctx.run(\n",
45
+ " File \"/Users/ruimelo/anaconda3/envs/gan-nlp/lib/python3.10/site-packages/dash/_callback.py\", line 514, in add_context\n",
46
+ " raise err\n",
47
+ " File \"/Users/ruimelo/anaconda3/envs/gan-nlp/lib/python3.10/site-packages/dash/_callback.py\", line 503, in add_context\n",
48
+ " output_value = _invoke_callback(func, *func_args, **func_kwargs)\n",
49
+ " File \"/Users/ruimelo/anaconda3/envs/gan-nlp/lib/python3.10/site-packages/dash/_callback.py\", line 43, in _invoke_callback\n",
50
+ " return func(*args, **kwargs) # %% callback invoked %%\n",
51
+ " File \"/var/folders/b4/lwfgccm95kqd2skcwvrt2fr00000gn/T/ipykernel_62984/1808289814.py\", line 112, in update_graph\n",
52
+ " world_map_fig = px.scatter_map(geo_df,\n",
53
+ "TypeError: scatter_map() got an unexpected keyword argument 'projection_type'\n"
54
+ ]
55
  }
56
  ],
57
  "source": [
 
85
  "\n",
86
  "\n",
87
  "\n",
 
 
 
 
88
  "## Layout ##\n",
89
  "\n",
90
  "dashboard_layout = html.Div([\n",
 
93
  " dcc.Graph(id='graph-content'),\n",
94
  "\n",
95
  "\n",
96
+ " dcc.Graph(id='world-map-fig'),\n",
97
  "\n",
98
  " html.H1(children='Wine Recommender', style={'textAlign':'center'}),\n",
99
  " dcc.Dropdown(wine_list, wine_list[0], id='dropdown-selection'),\n",
 
102
  "\n",
103
  "\n",
104
  "\n",
105
+ "\n",
106
+ "\n",
107
+ "\n",
108
  "wiki_layout = html.Div([\n",
109
  " dcc.Link('Dashboard', href='/'),\n",
110
  "\n",
 
115
  "\n",
116
  " html.H3('What is this project about?'),\n",
117
  "\n",
118
+ " html.P('We are a group of 4 Computer Science Engineering Students with a solid Artificial Intelligence background.'),\n",
119
+ " html.P('This project aims to showcase AI applications for improving Wine Tourism for SOGRAPE.'),\n",
 
120
  "\n",
 
121
  "\n",
122
  " html.H3('\\'Bout us'),\n",
123
  " html.Img(src='/assets/tourdevino_logo.webp', style={'width': '40%', 'height': 'auto', 'display': 'block', 'margin-left': 'auto', 'margin-right': 'auto'}),\n",
 
127
  " html.H4('André Catarino'),\n",
128
  " html.H4('Dinis Costa'),\n",
129
  " html.H4('Paulo Fidalgo'),\n",
 
 
 
 
 
130
  "\n",
131
  "\n",
132
  " ], className='six columns'),], className='row'),\n",
 
150
  "@app.callback(\n",
151
  " Output('graph-content', 'figure'),\n",
152
  " Output('wine-recommendation', 'children'),\n",
153
+ " Output('world-map-fig', 'figure'),\n",
154
  " Input('dropdown-selection', 'value')\n",
155
  ")\n",
156
  "def update_graph(value):\n",
157
+ " ### Wine Recommendation ###\n",
158
  " recommended_wines = None\n",
159
  " if value:\n",
160
  " recommended_wines = core.get_top_5_similar_wines(value, wine_similarity_df)[1:]\n",
161
  " recommended_wines = \"; \".join(recommended_wines)\n",
162
  "\n",
163
+ "\n",
164
+ " ### World Map of wineyards ###\n",
165
+ "\n",
166
+ " geo_df = pd.read_csv('data/processed_wineyards.csv')\n",
167
+ "\n",
168
+ "\n",
169
+ " world_map_fig = px.scatter_map(geo_df,\n",
170
+ " lat=geo_df['coord_x'],\n",
171
+ " lon=geo_df['coord_y'],\n",
172
+ " hover_name=geo_df['name'],\n",
173
+ " zoom=4,\n",
174
+ " hover_data={\n",
175
+ " 'IsTouristic': True,\n",
176
+ " 'Wine Type': True,\n",
177
+ " 'Country': True,\n",
178
+ " 'Region': True,\n",
179
+ " 'Address': True,\n",
180
+ "\n",
181
+ " },\n",
182
+ " title='Wineyards around the world',\n",
183
+ " )\n",
184
+ " \n",
185
+ "\n",
186
+ "\n",
187
+ " return px.line(df, x='year', y='pop'), recommended_wines, world_map_fig\n",
188
  "\n",
189
  "\n",
190
  "if __name__ == \"__main__\":\n",
app/data/processed_wineyards.csv ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,name,IsTouristic,LOCAL TYPE,Wine Type,SIZE,Country,Region,Address,coord,coord_x,coord_y
2
+ 0,Quinta de Azevedo,No,Quinta,Verde,41.0,Portugal,Douro,"R. Conde de Azevedo 237, 4750-511 Roriz","41.57330853032964, -8.533706262471226",41.57330853032964,-8.533706262471226
3
+ 1,Quinta do Porto,No,Quinta,Douro,27.0,Portugal,Douro,"N226, 5100","41.1285485073888, -7.816127554438324",41.1285485073888,-7.816127554438324
4
+ 2,Quinta do Seixo,Quinta do Seixo,Quinta,,100.0,Portugal,Douro,"Largo de Eiras 37, 5150-084 Almendra","41.02111060351561, -7.011243914386894",41.02111060351561,-7.011243914386894
5
+ 3,Quinta do Caêdo,No,Quinta,,22.0,Portugal,Douro,5130-126 Ervedosa do Douro,"41.191193966639496, -7.464240963577649",41.191193966639496,-7.464240963577649
6
+ 4,Quinta do Vau,No,Quinta,,73.0,Portugal,Douro,"Quinta do Vau, 7750-301 Mértola","37.63310013834872, -7.664460830879209",37.63310013834872,-7.664460830879209
7
+ 5,Quinta do Sairrão,No,Quinta,,170.0,Portugal,Douro,"Quinta do Sairrão Valença do Douro, 5130-909 São João da Pesqueira","41.12585233297436, -7.4043047394921855",41.12585233297436,-7.4043047394921855
8
+ 6,Quinta da Leda,No,Quinta,,158.0,Portugal,Douro,"Largo de Eiras 37, 5150-084 Almendra","41.0211631569069, -7.011313646768633",41.0211631569069,-7.011313646768633
9
+ 7,Quinta dos Carvalhais,No,Quinta,,106.0,Portugal,Dão,6370-140 Fornos de Algodres,"40.68806430590881, -7.380353578401911",40.68806430590881,-7.380353578401911
10
+ 8,Quinta do Romeira,No,Quinta,,73.0,Portugal,Bucelas,"Quinta da Romeira de Cima, 2670-678 Bucelas","38.90339927862606, -9.08272372295126",38.90339927862606,-9.08272372295126
11
+ 9,Herdade do Peso,No,Quinta,,162.0,Portugal,Alentejo,"W8W4+9X, Fajarda","38.94607643846798, -8.692547592716494",38.94607643846798,-8.692547592716494
12
+ 10,Santiago Ruiz,No,Quinta,Branco,38.0,Espanha,Rías Baixas,"Rua do Vinicultor, Santiago Ruiz, s/n, 36760 San Miguel de Tabagón, Pontevedra, Espanha","41.941794564806685, -8.802269831979137",41.941794564806685,-8.802269831979137
13
+ 11,Viña Lanciano,LAN,Quinta,,72.0,Espanha,Rioja,"Paraje de Buicio s/n, 26360 Fuenmayor, Espanha","42.46620857388223, -2.6026644530093135",42.46620857388223,-2.6026644530093135
14
+ 12,Finca los Llanos,No,Quinta,,25.0,Espanha,Rueda,"Calle Sierra Nevada, 18413 Capileira, Granada, Espanha","36.97246300856455, -3.358175904877671",36.97246300856455,-3.358175904877671
app/data/wineyards.csv ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NAME,IsTouristic,LOCAL TYPE,WINE TYPE,SIZE,COUNTRY,REGION,ADDRESS,COORD
2
+ Quinta de Azevedo,No,Quinta,Verde,41,Portugal,Douro,"R. Conde de Azevedo 237, 4750-511 Roriz","41.57330853032964, -8.533706262471226"
3
+ Quinta do Porto,No,Quinta,Douro,27,Portugal,Douro,"N226, 5100","41.1285485073888, -7.816127554438324"
4
+ Quinta do Seixo,Quinta do Seixo,Quinta,,100,Portugal,Douro,"Largo de Eiras 37, 5150-084 Almendra","41.02111060351561, -7.011243914386894"
5
+ Quinta do Caêdo,No,Quinta,,22,Portugal,Douro,5130-126 Ervedosa do Douro,"41.191193966639496, -7.464240963577649"
6
+ Quinta do Vau,No,Quinta,,73,Portugal,Douro,"Quinta do Vau, 7750-301 Mértola","37.63310013834872, -7.664460830879209"
7
+ Quinta do Sairrão,No,Quinta,,170,Portugal,Douro,"Quinta do Sairrão Valença do Douro, 5130-909 São João da Pesqueira","41.12585233297436, -7.4043047394921855"
8
+ Quinta da Leda,No,Quinta,,158,Portugal,Douro,"Largo de Eiras 37, 5150-084 Almendra","41.0211631569069, -7.011313646768633"
9
+ Quinta dos Carvalhais,No,Quinta,,106,Portugal,Dão,6370-140 Fornos de Algodres,"40.68806430590881, -7.380353578401911"
10
+ Quinta do Romeira,No,Quinta,,73,Portugal,Bucelas,"Quinta da Romeira de Cima, 2670-678 Bucelas","38.90339927862606, -9.08272372295126"
11
+ Herdade do Peso,No,Quinta,,162,Portugal,Alentejo,"W8W4+9X, Fajarda","38.94607643846798, -8.692547592716494"
12
+ Santiago Ruiz,No,Quinta,Branco,38,Espanha,Rías Baixas,"Rua do Vinicultor, Santiago Ruiz, s/n, 36760 San Miguel de Tabagón, Pontevedra, Espanha","41.941794564806685, -8.802269831979137"
13
+ Viña Lanciano,LAN,Quinta,,72,Espanha,Rioja,"Paraje de Buicio s/n, 26360 Fuenmayor, Espanha","42.46620857388223, -2.6026644530093135"
14
+ Finca los Llanos,No,Quinta,,25,Espanha,Rueda,"Calle Sierra Nevada, 18413 Capileira, Granada, Espanha","36.97246300856455, -3.358175904877671"
15
+ Ribera del Duero,No,Region,Tinto,,Espanha,Ribera del Duero,,
16
+ Jerez de la Frontera,No,Region,,,Espanha,Jerez de la Frontera,Jerez de la Frontera,
17
+ Caves Ferreira,Caves Ferreira,Cave,Porto Wine,,Portugal,,,
18
+ Caves Sandeman,Caves Sandeman,Cave,,,Portugal,,,
19
+ Loja da Estação do Pinhão,Loja da Estação do Pinhão,Loja,,,Portugal,,,