<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Jaccard Similarity on Chang Luo</title>
		<link>https://www.luochang.ink/tags/jaccard-similarity/</link>
		<description>Recent content in Jaccard Similarity on Chang Luo</description>
		<generator>Hugo</generator>
		<language>zh-CN</language>
		
		
		
		
			<lastBuildDate>Sat, 27 Jul 2024 00:00:00 +0000</lastBuildDate>
		
			<atom:link href="https://www.luochang.ink/tags/jaccard-similarity/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>SynchroTrap 算法实现</title>
				<link>https://www.luochang.ink/posts/synchrotrap/</link>
				<pubDate>Sat, 27 Jul 2024 00:00:00 +0000</pubDate>
				<guid>https://www.luochang.ink/posts/synchrotrap/</guid>
				<description>&lt;blockquote&gt;&#xA;&lt;p&gt;SynchroTrap 是基于 Jaccard 相似度和最大连通子图的异常检测算法，出自 Facebook 的论文 &lt;a href=&#34;https://users.cs.duke.edu/~xwy/publications/SynchroTrap-ccs14.pdf&#34; target=&#34;_blank&#34;&gt;Uncovering Large Groups of Active Malicious Accounts in Online Social Networks&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;GitHub 项目地址：&lt;a href=&#34;https://github.com/luochang212/SynchroTrap&#34; target=&#34;_blank&#34;&gt;SynchroTrap&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;本文做了什么：&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;用 &lt;code&gt;mimesis&lt;/code&gt; 生成源数据，并基于源数据构造正态分布的样本&lt;/li&gt;&#xA;&lt;li&gt;通过构造一个 \( \lambda \) 可调的泊松过程，生成用户到访时间戳&lt;/li&gt;&#xA;&lt;li&gt;提供一个由 7 个变量控制的异常数据生成函数，见 &lt;a href=&#34;https://github.com/luochang212/SynchroTrap/blob/main/utils.py#L236&#34; target=&#34;_blank&#34;&gt;gen_attack_df&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;用 Jaccard 相似度构图，再用 &lt;code&gt;NetworkX&lt;/code&gt; 对图做可视化&lt;/li&gt;&#xA;&lt;li&gt;用 Spark 的 &lt;code&gt;graphframes&lt;/code&gt; 计算最大连通子图&lt;/li&gt;&#xA;&lt;li&gt;复现了论文 2.2 节的可视化效果，见 &lt;a href=&#34;https://www.luochang.ink/posts/synchrotrap/#%E4%B8%89%E8%AF%84%E4%BC%B0%E4%B8%8E%E5%8F%AF%E8%A7%86%E5%8C%96&#34;&gt;评估与可视化&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;介绍如何使用 &lt;code&gt;Docker&lt;/code&gt; 构建 Spark 开发环境&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;✨ 注意：运行以下代码依赖 &lt;a href=&#34;https://github.com/luochang212/SynchroTrap/blob/main/utils.py&#34; target=&#34;_blank&#34;&gt;utils.py&lt;/a&gt; 文件和 &lt;a href=&#34;https://github.com/luochang212/SynchroTrap/tree/main/gen_data&#34; target=&#34;_blank&#34;&gt;gen_data&lt;/a&gt; 库。&lt;/p&gt;&#xA;&lt;h3 id=&#34;一样本生成&#34;&gt;一、样本生成&lt;/h3&gt;&#xA;&lt;p&gt;脱离互联网企业，我们很难拿到可供挖掘的异常数据样本。一种方法是自己生成。自己生成样本的好处是能拿到真正的 ground truth，而且可以精细地控制异常的规模和程度。&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;生成源数据&lt;/li&gt;&#xA;&lt;li&gt;生成大盘数据&#xA;&lt;ul&gt;&#xA;&lt;li&gt;生成正态样本分布&lt;/li&gt;&#xA;&lt;li&gt;生成 uid 并计算访问次数&lt;/li&gt;&#xA;&lt;li&gt;时间与时间戳&lt;/li&gt;&#xA;&lt;li&gt;用户日志表&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;生成异常数据&#xA;&lt;ul&gt;&#xA;&lt;li&gt;选择攻击开始时间&lt;/li&gt;&#xA;&lt;li&gt;获取 ip 池&lt;/li&gt;&#xA;&lt;li&gt;发起攻击&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;整合两份数据&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; 与异常捕获的难度有关的变量：&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
