Public
Edited
Dec 22, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chartData.get("united_coverage", 0)
Insert cell
Insert cell
coverage_score = _.round(
chartDataMeasurements.get("Average Headline Bias", 0),
3
)
Insert cell
topic_bias = {
let coverage_score = _.round(
chartDataMeasurements.get("Average Headline Bias", 0),
3
);
let coverage = "Low Subjectivity";
if (coverage_score > 0.6) {
coverage = "High Subjectivity";
} else if (tcoverage_score > 0.2) {
coverage = "Medium Subjectivity";
} else {
coverage = "Low Subjectivity";
}
return coverage;
}
Insert cell
Insert cell
Insert cell
top_15_topics = dt
.groupby("topic_name")
.rollup({ attention_sum: (d) => op.sum(d.attention_score) })
.orderby(aq.desc("attention_sum"))
.slice(0, 15)
.select("topic_name")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
top_10_topic_source_bias_attention = aq
.from(
dt
.objects()
.filter((o) => top_10_topics.array("topic_name").includes(o.topic_name))
)
.groupby("topic_name", "source_bias", "source_bias_readable")
.params({ division_factor: division_factor })
.rollup({
attention_sum: (d, $) => op.sum(d.attention_score) / $.division_factor
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
skewed_topics_with_attention_source.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
source_divergence.view()
Insert cell
mean_divergence = source_divergence
.rollup({ mean: (d) => op.mean(d.divergence) })
.values("mean")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function getHeadlinesForSource(data, source, count = 1, with_dates = false) {
let filteredData = data
.orderby("rank", aq.desc("scraped_at_date"))
.filter(
aq.escape((o) => o.source === source && o.topic_prob > topic_threshold)
);
if (filteredData.size == 0) {
return [];
}
if (count === 1) {
return filteredData.slice(0, 1).objects()[0].headline_with_source;
}
if (with_dates) {
return filteredData
.derive({
headline_with_date: (o) => "(" + o.scraped_at_date + ") " + o.headline
})
.array("headline_with_date")
.slice(0, count);
}
return filteredData
.array("headline_with_source")
.slice(0, count)
.map((o) => get_headline_link(o, true));
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function getMaxDate(dates) {
let maxDate = dates[0];
for (let i = 1; i < dates.length; i++) {
if (dates[i] > maxDate) {
maxDate = dates[i];
}
}
return maxDate;
}
Insert cell
function formatDate(dateString) {
const date = new Date(dateString);
const options = { year: "numeric", month: "short", day: "numeric" };
return date.toLocaleDateString("en-US", options);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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