Spaces:
Sleeping
Sleeping
fschwartzer
commited on
Commit
·
74f3104
1
Parent(s):
74f85af
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
|
|
|
|
4 |
from sklearn.neighbors import KNeighborsRegressor
|
5 |
from geopy.distance import geodesic
|
6 |
import googlemaps
|
@@ -9,6 +11,14 @@ from streamlit_folium import st_folium
|
|
9 |
from streamlit_folium import folium_static
|
10 |
import folium
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Function to calculate distance in meters between two coordinates
|
14 |
def calculate_distance(lat1, lon1, lat2, lon2):
|
@@ -276,4 +286,14 @@ if 'Predicted_target' in filtered_data.columns and not np.all(predicted_target =
|
|
276 |
st.write(f"Valor médio (Reais/m²) para as características selecionadas: ${mean_value:.2f}$ Reais")
|
277 |
st.write(f"Os valores podem variar entre ${lower_bound:.2f}$ e ${higher_bound:.2f}$ Reais, dependendo das características dos imóveis.")
|
278 |
else:
|
279 |
-
st.warning(f"**Dados insuficientes para inferência do valor. Mínimo necessário:** {k_threshold}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
4 |
+
import seaborn as sns
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
from sklearn.neighbors import KNeighborsRegressor
|
7 |
from geopy.distance import geodesic
|
8 |
import googlemaps
|
|
|
11 |
from streamlit_folium import folium_static
|
12 |
import folium
|
13 |
|
14 |
+
# Function to plot heatmap
|
15 |
+
def plot_heatmap(data, title):
|
16 |
+
plt.figure(figsize=(8, 6))
|
17 |
+
sns.heatmap(data, annot=True, cmap="YlGnBu", fmt=".2f", linewidths=.5)
|
18 |
+
plt.title(title)
|
19 |
+
plt.xlabel("Longitude")
|
20 |
+
plt.ylabel("Latitude")
|
21 |
+
st.pyplot()
|
22 |
|
23 |
# Function to calculate distance in meters between two coordinates
|
24 |
def calculate_distance(lat1, lon1, lat2, lon2):
|
|
|
286 |
st.write(f"Valor médio (Reais/m²) para as características selecionadas: ${mean_value:.2f}$ Reais")
|
287 |
st.write(f"Os valores podem variar entre ${lower_bound:.2f}$ e ${higher_bound:.2f}$ Reais, dependendo das características dos imóveis.")
|
288 |
else:
|
289 |
+
st.warning(f"**Dados insuficientes para inferência do valor. Mínimo necessário:** {k_threshold}")
|
290 |
+
|
291 |
+
# Plot heatmaps for 'Valor_Urb', 'Valor_Eqp', and 'RENDA'
|
292 |
+
st.subheader("Mapa de Calor para 'Valor_Urb'")
|
293 |
+
plot_heatmap(filtered_data.pivot_table(index='latitude', columns='longitude', values='Valor_Urb', aggfunc='mean'), 'Valor_Urb')
|
294 |
+
|
295 |
+
st.subheader("Mapa de Calor para 'Valor_Eqp'")
|
296 |
+
plot_heatmap(filtered_data.pivot_table(index='latitude', columns='longitude', values='Valor_Eqp', aggfunc='mean'), 'Valor_Eqp')
|
297 |
+
|
298 |
+
st.subheader("Mapa de Calor para 'RENDA'")
|
299 |
+
plot_heatmap(filtered_data.pivot_table(index='latitude', columns='longitude', values='RENDA', aggfunc='mean'), 'RENDA')
|