html`<div style="font-family: Arial, sans-serif; padding: 20px;">
<h2 style="text-align: center;"> SpamDetect: Visual Analytics on Email Text Patterns</h2>
<div style="margin: 20px auto; text-align: center;">
${viewof classFilter}
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 30px;">
<!-- Chart 1 -->
<div>
<h4>1️⃣ Word Frequency</h4>
${Plot.plot({
marks: [
Plot.barY(
wordAvgData.flatMap(d => [
{ word: d.word, class: "Spam", freq: d.spam },
{ word: d.word, class: "Not Spam", freq: d.not_spam }
]),
{
x: "word",
y: "freq",
fill: "class",
tip: true
}
)
],
color: {
domain: ["Spam", "Not Spam"],
range: ["#e63946", "#2a9d8f"],
legend: true
},
x: { label: "Word" },
y: { label: "Avg Frequency" },
width: 500,
height: 300
})}
</div>
<!-- Chart 2 -->
<div>
<h4>2️⃣ Capital Run Length Scatter</h4>
${Plot.plot({
marks: [
Plot.dot(filteredData, {
x: "capital_run_length_average",
y: "capital_run_length_longest",
fill: d => d.class === 1 ? "#e63946" : "#2a9d8f",
tip: true
})
],
x: { label: "Avg Capital Run" },
y: { label: "Longest Capital Run" },
width: 500,
height: 300
})}
</div>
</div>
<div style="margin-top: 40px;">
<h4>3️⃣ Special Character Usage (! and $)</h4>
${Plot.plot({
marks: [
Plot.boxY(filteredData, {
x: d => d.class === 1 ? "Spam" : "Not Spam",
y: "char_freq_%21",
fill: "orange",
tip: true
}),
Plot.boxY(filteredData, {
x: d => d.class === 1 ? "Spam" : "Not Spam",
y: "char_freq_%24",
fill: "blue",
tip: true
})
],
y: { label: "Frequency" },
width: 1040,
height: 300
})}
</div>
</div>`