Published
Edited
Jan 30, 2020
Insert cell
md`# Probe Similarity single probe histograms`
Insert cell
// probesFiltered = Object.assign({ prb_ids: psMeta2.filter(prbFilterFn).map(p => p.id) });
Insert cell
probesDownLoad = fetch(`https://8100.ripe.net/aggregated-recursive/19432?mode=similar&band=0.0,1.0&limit=10`, {
method: 'GET',
headers: {'Content-Type': 'application/json'
},
mode: 'cors',
// body: JSON.stringify(probesFiltered)
})
.then(res => res.json()).then(r => r.result);
Insert cell
probesFiltered = ({prb_ids: probesDownLoad.map(p => p.prb_id)});
Insert cell
sims = fetch(`https://8100.ripe.net/probes?limit=0`, {
method: 'POST',
headers: {'Content-Type': 'application/json'
},
mode: 'cors',
body: JSON.stringify(probesFiltered)
})
.then(res => res.json());
Insert cell
psMeta2 = await FileAttachment("active_probes_per_city_jan_2020.json").json();
Insert cell
ss = sims.flatMap(r => {
let prJoin = psMeta2.find(m => m.id === r.id)
let facet = prJoin && prJoin[facetParm]
return r.result.map(res => {
return (
{ ...res, src_prb_id: r.id, facet: facet, src_prb: prJoin })
})
});
Insert cell
bb = vl.markCircle() //({interpolate: 'step-before', opacity: 1.0, strokeWidth: 0.8, size: 20})
.encode(
vl.x().fieldN("prb_id").bin({maxbins:1000}),
vl.y().fieldQ("similarity").title('Similarity (jaccard index)').bin({maxbins:35}),
vl.color().fieldQ("similarity").scale({type: 'linear', range: ["#A5FFFF","teal","purple"]}),
// vl.y().fieldQ("prb_id").title('probe id'),
// vl.color().fieldN('facet').title(null),
// vl.color().fieldN('src_prb_id').title('source probe'),
vl.size().count().scale({type:'log',range: [22,120]})
)
.width(240)
.height(240)
.facet({column: vl.field("src_prb.id")})
.data(ss)
.title('probe similarities')
.transform(
// vl.groupby(["similarity", "src_prb_id", "facet"]).aggregate(vl.count().as('prb_count')),
// vl.window(vl.sum('Count').as('Cumulative_Sum')).groupby(['src_prb_id']).sort(vl.field("similarity")),
vl.groupby("facet")
)
Insert cell
Insert cell
prbFilterFn = p => true
Insert cell
facetParm = 'id'
Insert cell
probesFiltered.prb_ids.length
Insert cell
import {vl} from '@vega/vega-lite-api'
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