Public
Edited
Feb 28
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
format_count = d3.format(".0%")
Insert cell
color = d3.scaleOrdinal(results.map(d => d.label), d3.schemeCategory10)
Insert cell
results = predictions[0].results.length <= 0 ? [] : predictions.map(d => ({label: d.label, probability: d.results[0].probabilities[1]}))
Insert cell
predictions
Insert cell
/*html`<div class="predictions">
${comments.map((c, i) => {
return `<div class="prediction"><p>${c}</p><div class="labels">${parse_predictions(i)}</div></div>`
})}
</div>`*/
Insert cell
function parse_predictions(i){
return predictions.map(l => `<span class="${l.label}">${l.label}=${l.results[i].match} (${l.results[i].probabilities[1].toFixed(2)})</span>`).join(" ")
}
Insert cell
// Finding the answers
predictions = model.classify(comments);
Insert cell
model.tokenizer
Insert cell
comments = text_input.replace(/\.\s+([A-Z])/g, ".\n$1").split("\n").filter(x => x.length > 0)
Insert cell
text_input
Insert cell
Insert cell
// Load the model.
model = toxicity.load();
Insert cell
toxicity = require('@tensorflow-models/toxicity');
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