Spaces:
Runtime error
Runtime error
Commit
·
ec5e9ed
1
Parent(s):
a7ff4ae
Update app.py
Browse files
app.py
CHANGED
@@ -119,7 +119,7 @@ def tweets_localidad(buscar_localidad):
|
|
119 |
try:
|
120 |
geolocator = Nominatim(user_agent="nombre_del_usuario")
|
121 |
location = geolocator.geocode(buscar_localidad)
|
122 |
-
radius = "
|
123 |
tweets = api.search_tweets(q="",lang="es",geocode=f"{location.latitude},{location.longitude},{radius}", count = 500, tweet_mode="extended")
|
124 |
result = []
|
125 |
for tweet in tweets:
|
@@ -134,14 +134,14 @@ def tweets_localidad(buscar_localidad):
|
|
134 |
etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
135 |
result.append(etiqueta)
|
136 |
df = pd.DataFrame(result)
|
|
|
|
|
|
|
|
|
|
|
137 |
if df.empty:
|
138 |
st.text("No se encontraron tweets sexistas dentro de la localidad")
|
139 |
else:
|
140 |
-
df['Prediccion'] = np.where(df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
141 |
-
df = df[df["Prediccion"] == 'Sexista']
|
142 |
-
df = df[df["Probabilidad"] > 0.5]
|
143 |
-
df = df.sort_values(by='Probabilidad', ascending=False)
|
144 |
-
muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
|
145 |
tabla.append(muestra)
|
146 |
resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
147 |
colores=["#aae977","#EE3555"]
|
|
|
119 |
try:
|
120 |
geolocator = Nominatim(user_agent="nombre_del_usuario")
|
121 |
location = geolocator.geocode(buscar_localidad)
|
122 |
+
radius = "15km"
|
123 |
tweets = api.search_tweets(q="",lang="es",geocode=f"{location.latitude},{location.longitude},{radius}", count = 500, tweet_mode="extended")
|
124 |
result = []
|
125 |
for tweet in tweets:
|
|
|
134 |
etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
135 |
result.append(etiqueta)
|
136 |
df = pd.DataFrame(result)
|
137 |
+
df['Prediccion'] = np.where(df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
138 |
+
df = df[df["Prediccion"] == 'Sexista']
|
139 |
+
df = df[df["Probabilidad"] > 0.5]
|
140 |
+
df = df.sort_values(by='Probabilidad', ascending=False)
|
141 |
+
muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
|
142 |
if df.empty:
|
143 |
st.text("No se encontraron tweets sexistas dentro de la localidad")
|
144 |
else:
|
|
|
|
|
|
|
|
|
|
|
145 |
tabla.append(muestra)
|
146 |
resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
147 |
colores=["#aae977","#EE3555"]
|