# 帳號分群 3/11 實驗結果 ## 實驗目標 - 將輸入資料分為純數字帳號、非純數字帳號,做不同的 hash function,確認能否優化Kmeans分群。 - Threshold 輸出時提供一個清單,列出各個hierarchical group的人數,並依照人數遞減排序,以便能快速鎖定人數多的group進行檢視。(例如:group #5=27人、group #2=4人、group #7=4人、group #3=2人、group #4=2人 ...,這樣的清單印出來後,就容易看出group #5很可能有問題) ## 分別處理純數字與非純數字帳號 - 新增 regular expression (以過濾出純數字帳號 ```python num_rule = re.compile(r'[0-9 _]*[0-9][0-9 _]*') ``` - 主程式一開始即詢問使用者是否只分析純數字帳號 - 根據輸入資料種類使用不同 hash function ```python * 純數字: Type 1: # 直接相加每個字的編碼 hash_value += ord(word) Type 2: # 直接以純數字的數值作為hash value hash_value = int(words) * 非純數字 # 數字的編碼設為1,非數字則直接相加 if word in '0123456789': hash_value += 1 else: hash_value += ord(word) ``` ## Threshold 輸出時提供一個清單 - 原始資料量為 100 筆 - 挑選Kmeans其中一群根據不同 threshold 分群後的結果,統計label,並按照成員數量排序群組 #### Threshold = 0 [Google sheet](https://docs.google.com/spreadsheets/d/1txulN0Ebj0sE-nlSbcU2q7xjzMQinVJRcCAE-sm02HI/edit?usp=sharing) - 成員資訊  - 群組人數  - 總覽  #### Threshold = 35 [Google sheet](https://docs.google.com/spreadsheets/d/1m8YawKafYU3pjbPq5xBhZuyat2NnRCeDVMgN5nhaMiU/edit?usp=sharing) - 成員資訊  - 群組人數  - 總覽  #### Threshold = 50 [Google sheet](https://docs.google.com/spreadsheets/d/1wKvwIG8jrl__O33UFO-6uaZNbNTOZHyWubLWmIRd7Ms/edit?usp=sharing) - 成員資訊  - 群組人數  - 總覽  ## 不同 hash function 之 Kmeans 分群結果 - 資料量為 100 筆 ### Type 1 (直接相加每個字的編碼) - 分五群 ``` * 數量 (Group 0): 30 (Group 1): 5 (Group 2): 18 (Group 3): 16 (Group 4): 31 ```  - 分兩群 ``` * 數量 (Group 0): 47 (Group 1): 53 ```  ### Type 2 (直接以純數字的數值作為hash value - 分五群 ``` * 數量 (Group 0): 85 (Group 1): 10 (Group 2): 1 (Group 3): 2 (Group 4): 2 ```  - 分兩群 ``` * 數量 (Group 0): 11 (Group 1): 89 ```  ## 總結 接著會繼續嘗試其他 hash function 確認效果,threshold 輸出清單也已確認排序部分能夠正常顯示。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up