Public
Edited
Dec 6, 2023
Insert cell
Insert cell
toto = d3.json(urlPredicat).then(
res => {
const values = res['coicop'][`\'${product_debounce}\'`] ;
return values
}
)
Insert cell
Inputs.table(toto)
Insert cell
product_debounce = debounce(viewof product, 2000)
Insert cell
viewof product = Inputs.text(
{label: '', value: 'Nutella', width: 800}
)
Insert cell
urlPredicat = `https://api.lab.sspcloud.fr/predicat/label?k=2&q=%27${product_debounce}%27&v=1`
Insert cell
activite_debounce = debounce(viewof activite, 2000)
Insert cell
viewof activite = Inputs.text(
{label: '', value: 'Crêperie', width: 800}
)
Insert cell
urlApe = `https://codification-ape-test.lab.sspcloud.fr/predict?nb_echos_max=3&prob_min=0&text_feature=${activite_debounce}`
Insert cell
d3.json(urlApe).then(res => {
var IC, results;

({ IC, ...results } = res);

IC = parseFloat(IC);

const rows = Object.values(results).map(obj => {
return `
<tr>
<td>${obj.code} | ${obj.libelle}</td>
<td>${obj.probabilite.toFixed(3)}</td>
</tr>
`;
}).join('');

const confidenceRow = `<tr>
<td colspan="2" style="text-align:left; "><em>Indice de confiance : ${IC.toFixed(3)}</em></td>
</tr>`;

const tableHTML = html`
<table>
<caption>
Prédiction de l'activité
</caption>
<tr>
<th style="text-align:center;">Libellé (NA2008)</th>
<th>Probabilité</th>
</tr>
${rows}
${confidenceRow}
</table>`;

// Now you can use the tableHTML as needed, for example, inserting it into the DOM.
// For example, assuming you have a container with the id "tableContainer":
return tableHTML;
});

Insert cell
import {debounce} from "@mbostock/debouncing-input"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more