Spaces:
Runtime error
Runtime error
LaurentTRIPIED
commited on
Commit
·
a72f593
1
Parent(s):
2d7498a
Pytorch V0.17
Browse files- RSECategorizer.py +0 -34
- app.py +3 -44
- localisation.py +28 -0
- organisations_engagees.py +17 -0
RSECategorizer.py
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
# RSECategorizer.py
|
2 |
-
|
3 |
-
from transformers import pipeline
|
4 |
-
import pandas as pd
|
5 |
-
|
6 |
-
# Charger le pipeline de classification avec un modèle léger
|
7 |
-
classifier = pipeline("zero-shot-classification", model="typeform/distilbert-base-uncased-mnli")
|
8 |
-
|
9 |
-
def classify_rse_actions(descriptions):
|
10 |
-
categories = [
|
11 |
-
"La gouvernance de la structure",
|
12 |
-
"Les droits humains",
|
13 |
-
"Les conditions et relations de travail",
|
14 |
-
"La responsabilité environnementale",
|
15 |
-
"La loyauté des pratiques",
|
16 |
-
"Les questions relatives au consommateur et à la protection du consommateur",
|
17 |
-
"Les communautés et le développement local"
|
18 |
-
]
|
19 |
-
|
20 |
-
classified_data = []
|
21 |
-
for description in descriptions:
|
22 |
-
# Classification de chaque description
|
23 |
-
result = classifier(description, categories)
|
24 |
-
# Récupération de la catégorie avec la probabilité la plus élevée
|
25 |
-
top_category = result['labels'][0]
|
26 |
-
classified_data.append(top_category)
|
27 |
-
|
28 |
-
return classified_data
|
29 |
-
|
30 |
-
# Exemple d'utilisation (à des fins de test, à commenter ou supprimer pour l'intégration finale)
|
31 |
-
# descriptions = ["Promotion de l'énergie renouvelable", "Amélioration des conditions de travail"]
|
32 |
-
# print(classify_rse_actions(descriptions))
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -1,52 +1,11 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
-
import
|
4 |
-
import folium
|
5 |
-
from streamlit_folium import folium_static
|
6 |
-
|
7 |
-
def get_data():
|
8 |
-
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
9 |
-
response = requests.get(url)
|
10 |
-
if response.status_code == 200:
|
11 |
-
data = response.json()
|
12 |
-
records = data.get("records", [])
|
13 |
-
return [record.get("fields") for record in records]
|
14 |
-
else:
|
15 |
-
return []
|
16 |
-
|
17 |
-
def display_organisations_engagees(data):
|
18 |
-
st.markdown("## OPEN DATA RSE")
|
19 |
-
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
|
20 |
-
num_etablissements = len(data)
|
21 |
-
st.markdown(f"Nombre d'établissements : {num_etablissements}")
|
22 |
-
if data:
|
23 |
-
df = pd.DataFrame(data)
|
24 |
-
st.dataframe(df[['nom_courant_denomination', 'commune', 'libelle_section_naf', 'tranche_effectif_entreprise', 'action_rse']].rename(columns={
|
25 |
-
'nom_courant_denomination': 'Nom',
|
26 |
-
'commune': 'Commune',
|
27 |
-
'libelle_section_naf': 'Section NAF',
|
28 |
-
'tranche_effectif_entreprise': 'Effectif',
|
29 |
-
'action_rse': 'Action RSE'
|
30 |
-
}))
|
31 |
-
|
32 |
-
def display_map(data):
|
33 |
-
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
34 |
-
for item in data:
|
35 |
-
point_geo = item.get('point_geo')
|
36 |
-
if isinstance(point_geo, dict):
|
37 |
-
lon = point_geo.get('lon')
|
38 |
-
lat = point_geo.get('lat')
|
39 |
-
if lon and lat:
|
40 |
-
folium.Marker(
|
41 |
-
[lat, lon],
|
42 |
-
icon=folium.Icon(color="green", icon="leaf"),
|
43 |
-
popup=item.get('nom_courant_denomination', 'Information non disponible'),
|
44 |
-
).add_to(m)
|
45 |
-
folium_static(m)
|
46 |
|
47 |
def main():
|
48 |
st.sidebar.title("Navigation")
|
49 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])
|
|
|
50 |
data = get_data()
|
51 |
if app_mode == "Organisations engagées":
|
52 |
display_organisations_engagees(data)
|
|
|
1 |
import streamlit as st
|
2 |
+
from organisations_engagees import display_organisations_engagees
|
3 |
+
from localisation import display_map, get_data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def main():
|
6 |
st.sidebar.title("Navigation")
|
7 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])
|
8 |
+
|
9 |
data = get_data()
|
10 |
if app_mode == "Organisations engagées":
|
11 |
display_organisations_engagees(data)
|
localisation.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import folium
|
3 |
+
from streamlit_folium import folium_static
|
4 |
+
|
5 |
+
def get_data():
|
6 |
+
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
7 |
+
response = requests.get(url)
|
8 |
+
if response.status_code == 200:
|
9 |
+
data = response.json()
|
10 |
+
records = data.get("records", [])
|
11 |
+
return [record.get("fields") for record in records]
|
12 |
+
else:
|
13 |
+
return []
|
14 |
+
|
15 |
+
def display_map(data):
|
16 |
+
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
17 |
+
for item in data:
|
18 |
+
point_geo = item.get('point_geo')
|
19 |
+
if isinstance(point_geo, dict):
|
20 |
+
lon = point_geo.get('lon')
|
21 |
+
lat = point_geo.get('lat')
|
22 |
+
if lon and lat:
|
23 |
+
folium.Marker(
|
24 |
+
[lat, lon],
|
25 |
+
icon=folium.Icon(color="green", icon="leaf"),
|
26 |
+
popup=item.get('nom_courant_denomination', 'Information non disponible'),
|
27 |
+
).add_to(m)
|
28 |
+
folium_static(m)
|
organisations_engagees.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
def display_organisations_engagees(data):
|
5 |
+
st.markdown("## OPEN DATA RSE")
|
6 |
+
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
|
7 |
+
num_etablissements = len(data)
|
8 |
+
st.markdown(f"Nombre d'établissements : {num_etablissements}")
|
9 |
+
if data:
|
10 |
+
df = pd.DataFrame(data)
|
11 |
+
st.dataframe(df[['nom_courant_denomination', 'commune', 'libelle_section_naf', 'tranche_effectif_entreprise', 'action_rse']].rename(columns={
|
12 |
+
'nom_courant_denomination': 'Nom',
|
13 |
+
'commune': 'Commune',
|
14 |
+
'libelle_section_naf': 'Section NAF',
|
15 |
+
'tranche_effectif_entreprise': 'Effectif',
|
16 |
+
'action_rse': 'Action RSE'
|
17 |
+
}))
|