Public
Edited
Apr 8
Insert cell
Insert cell
Insert cell
import {vl} from "@vega/vega-lite-api-v5"
Insert cell
import {printTable} from "@uwdata/data-utilities"
Insert cell
cnn1 = FileAttachment("Aggregated_Results_CNN_v1.csv").csv()
Insert cell
cnn2 = FileAttachment("Aggregated_Results_CNN_v2.csv").csv()
Insert cell
vit1 = FileAttachment("Aggregated_Results_transformer_v1.csv").csv()
Insert cell
vit2 = FileAttachment("Aggregated_Results_transformer_v2.csv").csv()
Insert cell
best = FileAttachment("Best_revised.csv").csv()
Insert cell
printTable(best.slice(0,5))
Insert cell
Insert cell
vl.markBar()
.data(best)
.encode(
vl.x().fieldN('Model').title('Model').axis({ labelAngle: -30 }),
vl.y().fieldQ('Accuracy').title('Accuracy Score'),
vl.color().fieldN('Preprocessing').title('Preprocessing')
.legend({ orient: 'right', titleFontSize: 12 }), // preprocessing color coding
vl.column().fieldN('Balanced').title('')
.header({
labelExpr: "datum.value == 'Yes' ? 'Balanced data' : 'Unbalanced data'" // Relabel values for subplots
}),
vl.tooltip().fieldN('Model_type')
)
.width(200) // sub-chart width
.height(400)
.title({
text: 'Accuracy of Best Performing Models',
anchor: 'middle', // Center title
fontSize: 14,
offset: 20 // vertical spacing
})

.render()
Insert cell
vl.markBar()
.data(best)
.encode(
vl.x().fieldN('Model').title('Model').axis({ labelAngle: -30 }),
vl.y().fieldQ('AUC').title('AUC Score'),
vl.color().fieldN('Preprocessing').title('Preprocessing')
.legend({ orient: 'right', titleFontSize: 12 }),
vl.column().fieldN('Balanced').title('')
.header({
labelExpr: "datum.value == 'Yes' ? 'Balanced data' : 'Unbalanced data'" // Relabel values for subplots
}),
vl.tooltip().fieldN('Model_type')
)
.width(200) // sub-chart width
.height(400)
.title({
text: 'AUC of Best Performing Models',
anchor: 'middle', // Center title
fontSize: 14,
offset: 20 // vertical spacing
})

.render()
Insert cell
(best.map(d => d.Balanced));
Insert cell
vl.markPoint({ size: 100 })
.data(best)
.encode(
vl.x().fieldQ('Accuracy').title('Accuracy').scale({ domain: [0.4, 1] }), // set bounds
vl.y().fieldQ('AUC').title('AUC').scale({ domain: [0.7, 1] }),
vl.color().fieldN('Model').title('Model').scale({ scheme: "category10" }),
vl.shape().fieldN('Balanced'),
vl.tooltip([vl.tooltip().fieldN('Model_type'), vl.tooltip().fieldQ('F1-Score')])
)
.width(450)
.height(300)
.title('Accuracy vs. AUC of Best Performing Models')

.render()
Insert cell
// testing styles
vl.markBar()
.data(best)
.encode(
vl.y().fieldQ('Accuracy').title('Accuracy Score'),
vl.x().fieldN('Model').title('Model').axis({ labelAngle: -10 }),
vl.color().fieldN('Model_type'), // Color by Model_type
vl.xOffset().fieldN('Model_type'),
vl.tooltip().fieldN('Model_type')
)
.width(800)
.height(300)
.title('Accuracy of Best Performing Models')
.render()
Insert cell
Insert cell
traintestsplit = [
{ "category": "Train Images", "value": 5120 },
{ "category": "Test Images", "value": 1280 }
] // noted from Huggingface dataset
Insert cell
vl.markArc({ innerRadius: 0, outerRadius: 130 })
.data(traintestsplit)
.transform(
vl.joinaggregate([{ op: 'sum', field: 'value', as: 'TotalCount' }]),
vl.calculate('datum.value / datum.TotalCount').as('Percentage') // find percentage of total
)
.encode(
vl.theta().fieldQ('value').title('count'), // set number of rows as value
vl.color().fieldN('category').title('') // assign to data split
.scale({scheme: "paired" }),
vl.tooltip([ // display percentages upon hover
vl.tooltip().fieldQ('value').title('Count'),
vl.tooltip().fieldQ('Percentage').title('Percentage').format('.1%')
])
)
// plot settings
.width(300)
.height(300)
.title('Train Test Data Split')

.render()
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