{"id":2806,"date":"2026-11-14T12:00:00","date_gmt":"2026-11-14T12:00:00","guid":{"rendered":"https:\/\/sites.wp.odu.edu\/locky\/?p=2806"},"modified":"2026-10-26T20:49:50","modified_gmt":"2026-10-26T20:49:50","slug":"unsupervised-malware-detection-when-anomalies-arent-rare","status":"publish","type":"post","link":"https:\/\/sites.wp.odu.edu\/locky\/2026\/11\/14\/unsupervised-malware-detection-when-anomalies-arent-rare\/","title":{"rendered":"Unsupervised Malware Detection: When Anomalies Aren&#8217;t Rare"},"content":{"rendered":"\n<p>One of my models scored 0.350 ROC-AUC. That\u2019s worse than random guessing, and I left it in the report.<\/p>\n\n\n\n<p>This assignment used K-Means and DBSCAN to detect malware without labels. The models never saw which files were malicious. Labels came in only afterward, to grade the results.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The assumption that broke<\/h3>\n\n\n\n<p>Clustering-based anomaly detection assumes anomalies are rare. They should sit apart from the dense crowd of normal data.<\/p>\n\n\n\n<p>The instructions treated malware as the anomaly. But in this dataset, 70 percent of the files were malware. The \u201canomaly\u201d was the crowd.<\/p>\n\n\n\n<p>So K-Means did what it was built to do. It flagged the files farthest from the center of the data. Those turned out to be mostly benign, and the malware was scored as normal.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why I didn\u2019t flip it<\/h3>\n\n\n\n<p>Reversing the score would have produced 0.650. But I would only know to flip it by looking at the labels. That sneaks label knowledge into a method that\u2019s supposed to work without it.<\/p>\n\n\n\n<p>Instead, I ran a second set with malware cut to 5 percent. The pipeline and parameter rules stayed the same. K-Means rose to 0.794, and DBSCAN reached 0.910.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What else showed up<\/h3>\n\n\n\n<p>Both algorithms independently found the same 290-file cluster, and every file in it was benign. Small clusters aren\u2019t automatically suspicious.<\/p>\n\n\n\n<p>DBSCAN also found a 100-file cluster that was entirely malware. To a density method, a tight group looks normal. Malware arriving in volume can hide in plain sight.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The takeaway<\/h3>\n\n\n\n<p>The makeup of the data mattered more than the algorithm. Before choosing an unsupervised method, I now check whether its core assumption holds.<\/p>\n\n\n\n<p>The full report is on my <a href=\"https:\/\/sites.wp.odu.edu\/locky\/coursework\/cybersecurity-applications\/cyse-420-applied-ml-in-cybersecurity\/\">CYSE 420 course page<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-layout-1 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\"><a href=\"https:\/\/sites.wp.odu.edu\/locky\/wp-content\/uploads\/sites\/38189\/2026\/10\/CYSE420_Assignment05_Report_fd-1.pdf\" class=\"pdfemb-viewer\" style=\"\" data-width=\"max\" data-height=\"max\"  data-toolbar=\"both\" data-toolbar-fixed=\"on\">CYSE420_Assignment05_Report_fd-1<br\/><\/a>\n<p class=\"wp-block-pdfemb-pdf-embedder-viewer\"><\/p>\n<\/div><\/div>\n<\/div><\/div>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<ul class=\"wp-block-social-links has-normal-icon-size has-visible-labels has-icon-color has-icon-background-color is-style-default is-horizontal is-content-justification-center is-layout-flex wp-container-core-social-links-layout-1 wp-block-social-links-is-layout-flex\"><li style=\"color: #ffffff; background-color: #cf2e2e; \" class=\"wp-social-link wp-social-link-chain has-white-color wp-block-social-link\"><a rel=\"https:\/\/www.credly.com\/users\/carl-lochstampfor-jr noopener nofollow\" target=\"_blank\" href=\"http:\/\/sites.wp.odu.edu\/locky\/wp-content\/uploads\/sites\/38189\/2026\/10\/CYSE420_Assignment05_Report_fd-1.pdf\" class=\"wp-block-social-link-anchor\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" version=\"1.1\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M15.6,7.2H14v1.5h1.6c2,0,3.7,1.7,3.7,3.7s-1.7,3.7-3.7,3.7H14v1.5h1.6c2.8,0,5.2-2.3,5.2-5.2,0-2.9-2.3-5.2-5.2-5.2zM4.7,12.4c0-2,1.7-3.7,3.7-3.7H10V7.2H8.4c-2.9,0-5.2,2.3-5.2,5.2,0,2.9,2.3,5.2,5.2,5.2H10v-1.5H8.4c-2,0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z\"><\/path><\/svg><span class=\"wp-block-social-link-label\">Full Screen or Download<\/span><\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>K-Means scored 0.350 ROC-AUC on malware data, worse than random. Why clustering fails when the anomaly is the majority, and what changed at 5 percent.<\/p>\n","protected":false},"author":30379,"featured_media":2807,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"image","meta":{"footnotes":"","wds_primary_category":165},"categories":[165,60],"tags":[287,267,289,285,274,290,286,288],"_links":{"self":[{"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/posts\/2806"}],"collection":[{"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/users\/30379"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/comments?post=2806"}],"version-history":[{"count":3,"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/posts\/2806\/revisions"}],"predecessor-version":[{"id":2819,"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/posts\/2806\/revisions\/2819"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/media\/2807"}],"wp:attachment":[{"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/media?parent=2806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/categories?post=2806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/locky\/wp-json\/wp\/v2\/tags?post=2806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}