Template Classification
Template Classification
Template Classification
DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N"
crossorigin="anonymous">
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
.styled-table {
border-collapse: collapse;
margin: 25px 0;
font-size: 0.9em;
font-family: sans-serif;
min-width: 400px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}
.styled-table thead tr {
background-color: #33b2ff;
color: #ffffff;
text-align: left;
}
.styled-table th,
.styled-table td {
padding: 12px 15px;
}
.styled-table tbody tr {
border-bottom: 1px solid #dddddd;
}
.node text {
font: 12px sans-serif;
}
.link {
fill: none;
stroke: #ccc;
stroke-width: 2px;
}
#treeDiv {
width: 100%;
height: 600px;
margin: 0 auto;
}
</style>
<script src="https://d3js.org/d3.v6.min.js"></script>
</head>
<body>
<td>
{{ row.index }}
</td>
<td>
{{ row.Precision }}
</td>
<td>
{{ row.Recall }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="col-6" style="border:1px solid black;height: 100%;overflow-y:
auto;">
<table class="styled-table">
<thead>
<tr style="position: sticky;top: 0;">
<th> # </th>
{% for row in df_conf_matrix_index %}
<th> {{row}} </th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for item in df_conf_matrix %}
<tr>
</tbody>
</table>
</div>
</div>
<script>
// Initialize DataTable
$('#example').DataTable({
data: dataset,
columns: columns,
order: [[0, 'desc']],
scrollY: '300px',
scrollX: true,
scrollCollapse: true,
createdRow: function(row, data, dataIndex) {
debugger;
// Highlight rows from dataset1
var isInDataset1 = dataset1.some(function(item) {
// Check if all key-value pairs in the row match an item in
dataset1
return Object.keys(item).every(function(key) {
return item[key] === data[key];
});
});
if (isInDataset1) {
$('td:eq(1)', row).addClass('highlight');
}
}
});
let i = 0; // Initialize i
const duration = 750; // Initialize duration
function update(source) {
const treeData = tree(rootData);
nodeEnter.append('circle')
.attr('class', 'node')
.attr('r', 1e-6)
.style("fill", d => d.children ? "lightsteelblue" :
"green") // Default to lightsteelblue
.style("stroke", "#333")
.style("stroke-width", 2);
nodeEnter.append('text')
.attr("dy", ".35em")
.attr("x", d => d.children ? -13 : 13)
.attr("text-anchor", d => d.children ? "end" : "start")
.text(d => d.data.name);
nodeUpdate.transition()
.duration(duration)
.attr("transform", d => "translate(" + d.y + "," + d.x +
")");
nodeUpdate.select('circle.node')
.attr('r', 10)
.style("fill", d => {
if (d.children) {
return "lightsteelblue"; // Parent nodes
} else {
return "green"; // Leaf nodes
}
})
.attr('cursor', 'pointer');
nodeExit.select('circle')
.attr('r', 1e-6);
nodeExit.select('text')
.style('fill-opacity', 1e-6);
nodes.forEach(d => {
d.x0 = d.x;
d.y0 = d.y;
});
function diagonal(s, d) {
return `M ${s.y} ${s.x}
C ${(s.y + d.y) / 2} ${s.x},
${(s.y + d.y) / 2} ${d.x},
${d.y} ${d.x}`;
}
function click(event, d) {
if (d.children) {
d._children = d.children;
d.children = null;
} else {
d.children = d._children;
d._children = null;
}
update(d);
}
}
function collapse(d) {
if (d.children) {
d._children = d.children;
d._children.forEach(collapse);
d.children = null;
}
}
</script>
</body>
</html>