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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more