This file contains 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
def read_seq(inputfile): | |
"""reads and returns the imput sequence with special characters removed.""" | |
with open(inputfile, 'r') as f: | |
seq=f.read() | |
seq = seq.replace("\n","") | |
seq= seq.replace("\r","") | |
return seq |
This file contains 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 statsmodels.api as sm | |
mod=sm.OLS(y, x) #ordinary least sqares | |
est=mod.fit() | |
print (est.summary()) | |
#這裡得出來的斜率較大是因為沒有截距,從0開始畫 | |
#可以print 出詳細資訊 | |
X=sm.add_constant(x) | |
mod=sm.OLS(y, X) |
This file contains 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
#Basics of NetworkX | |
import networkx as nx | |
G=nx.Graph() | |
#增加節點 | |
G.add_node(1) | |
#一次增加多個節點 | |
G.add_nodes_from([2,3,'u','v']) |
This file contains 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
""" | |
np.isnan() | |
查看是否有nan | |
np.isnan(speed).any() | |
是true的話代表一定有nan值 | |
np.sum(np.isnan()) | |
看有幾個nan的值 |
This file contains 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
運用的觀念 | |
pearson correlation | |
spectral co-clustering | |
adjacency matrix | |
eigenvalues eigenvectors | |
bokeh用法 |
This file contains 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
numpy.power(兩點相減,相差的平方) | |
max(dictionary) = max(dictionary.keys()) | |
max(dictionary.values()) 是找值 | |
scipy.stats.mstats.mode | |
直接丟入list( or array),可以轉換成(最多出現的值,次數) | |
但是呈現規則為「次數皆相同者,只會秀出最小的值」,沒有考慮重複的問題 | |
np.argsort(np.array) #從給定的np.array中由小排到大的index位置 |