This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| # activation function | |
| sigmoid = lambda x: 1/(1+np.exp(-x)) | |
| # set input, output and hyperparameter | |
| X = np.array([ | |
| [1,0,1] | |
| ]) | |
| y = np.array([ | |
| [1] | |
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 定義計算方法 | |
| log2 = lambda x: np.log2(x,where=x!=0) | |
| I = lambda *args: sum([-arg/sum(args)*log2(arg/sum(args)) for arg in args]) | |
| G = lambda *args: sum([1-(arg/sum(args))**2 for arg in args]) | |
| Cum = lambda F, P, y: P.mean() * F(*[ (P&(y==v)).sum() for v in y.unique() ]) | |
| CumSum = lambda F, S, y: sum([ Cum(F, S==v, y) for v in S.unique() ]) | |
| E = lambda S, y: CumSum(I, S, y) | |
| Gain = lambda S, y: I(*y.value_counts()) - E(S, y) | |
| SplitGain = lambda S: I(*S.value_counts()) | |
| GainRatio = lambda S, y: Gain(S,y) / SplitGain(S) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| A = np.array([['男', '市場部', '24000', '無'], | |
| ['女', '研發部', '45000', '有'], | |
| ['男', '會計部', '45000', '無'], | |
| ['男', '研發部', '40000', '無'], | |
| ['女', '市場部', '24000', '有'], | |
| ['女', '研發部', '40000', '無'], | |
| ['男', '市場部', '24000', '有']]) | |
| def Hamming_distance(A): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from selenium import webdriver | |
| driver = webdriver.Chrome('C:/Users/使用者名稱/Downloads/chromedriver.exe') | |
| driver.get('https://shopee.tw/') #會彈出新的頁面 | |
| cookies = driver.get_cookies() #格式為list包dict | |
| csrftoken = [item['value'] for item in cookies if item['name'] == 'csrftoken'][0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Super Easy Diy Drumpad Example | |
| GIT: https://gist.github.com/billju/ce1337ea3c1dbb4341ce22dca1b55442 | |
| 2017 by Billju | |
| Inspired by Evan Kale | |
| */ | |
| #include <Keyboard.h> | |
| #include "MIDIUSB.h" |
NewerOlder