1 Star 0 Fork 1

duanyao/Bio_CN_Parser

forked from laozibabac/Bio_CN_Parser 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
brain_util.py 980 Bytes
一键复制 编辑 原始数据 按行查看 历史
laozibabac 提交于 2023-11-22 18:01 . initial commit
import brain
import numpy as np
import random
import copy
import pickle
from collections import OrderedDict
# Save obj (could be Brain object, list of saved winners, etc) as file_name
def sim_save(file_name, obj):
with open(file_name,'wb') as f:
pickle.dump(obj, f)
def sim_load(file_name):
with open(file_name,'rb') as f:
return pickle.load(f)
# Compute item overlap between two lists viewed as sets.
def overlap(a,b,percentage=False):
o = len(set(a) & set(b))
if percentage:
return (float(o)/float(len(b)))
else:
return o
# Compute overlap of each list of winners in winners_list
# with respect to a specific winners set, namely winners_list[base]
def get_overlaps(winners_list,base,percentage=False):
overlaps = []
base_winners = winners_list[base]
k = len(base_winners)
for i in xrange(len(winners_list)):
o = overlap(winners_list[i],base_winners)
if percentage:
overlaps.append(float(o)/float(k))
else:
overlaps.append(o)
return overlaps
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/duan-yao/bioparser.git
[email protected]:duan-yao/bioparser.git
duan-yao
bioparser
Bio_CN_Parser
master

搜索帮助