function histograms({
feature,
title,
yScaleType = 'linear',
xDomain = undefined
}) {
return Plot.plot((() => {
const cols = 5;
const folds = d3.range(1, 11);
const fx = (fold) => (fold - 1) % cols;
const fy = (fold) => Math.floor((fold - 1) / cols);
return {
title,
width,
height: 500,
fx: {
axis: false
},
fy: {
axis: false
},
y: {
type: yScaleType
},
color: {
scheme: 'plasma',
reverse: true,
legend: true,
label: 'Fold RMSE'
},
marks: [
Plot.rectY(data, Plot.binX(
{y: "count"},
{
x: {
value: feature,
domain: xDomain
},
fx: d => fx(d.fold),
fy: d => fy(d.fold),
fill: "rmse"
}
)),
Plot.text(folds, {text: d => `Fold ${d}`, fx, fy, frameAnchor: "top", dx: 0, dy: 0}),
Plot.ruleY([0])
]
};
})());
}