# Verify conda is installed, check version number
conda info
# Update conda to the current version
conda update conda
# conda install PACKAGENAME
Install a package included in Anaconda
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
// ==UserScript== | |
// @name Overleaf Editor Custom VIM Keybindings | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @match https://www.overleaf.com/project/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; |
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
""" | |
@Created Date: Friday February 4th 2022 | |
@Author: Alafate Abulimiti | |
@Company: INRIA | |
@Lab: CoML/Articulab | |
@School: PSL/ENS | |
@Description: Save the frequent useful functions | |
-------------- | |
@HISTORY: | |
Date By Comments |
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 os | |
libs = { | |
"pillow", | |
"sklearn", | |
"numpy", | |
"pandas", | |
"jupyterlab", | |
"scikit-learn", | |
"torch torchvision", |
使用 Python 内置的 defaultdict
,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)
就是这样!
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
# add row | |
scores = list() | |
for row in df.itemrows(): | |
df.loc[len(df)] = scores | |
def get_data(data, features): | |
""" | |
Data is an array each row being a tuple with possibily several features. | |
Keep only those features whose indices appear in the 'features' vector | |
""" |
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
# 合并两个dict 同keys, values 相加 | |
def get(compe_list, text_list): | |
span_score = calcul_span_score.calcul_span_score(text_list, compe_list) | |
fre_score = calcul_fre_score.calcul_fre_score(text_list, compe_list) | |
span_score_counter = Counter(span_score) | |
fre_score_counter = Counter(fre_score) | |
scores_dict = dict(span_score_counter + fre_score_counter) | |
return scores_dict |
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
# docs is 2 dims | |
vocabs = set(itertools.chain.from_iterable(docs)) | |
return vocabs |
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
# 这是装饰器函数,参数 func 是被装饰的函数 | |
def logger(func): | |
def wrapper(*args, **kw): | |
print('主人,我准备开始执行:{} 函数了:'.format(func.__name__)) | |
# 真正执行的是这行。 | |
func(*args, **kw) | |
print('主人,我执行完啦。') | |
return wrapper |
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
# 列表对象(list)是一个查询效率高于更新操作的数据结构,比如删除一个元素和插入一个元素时执行效率就非常低,因为还要对剩下的元素进行移动 | |
names = ['raymond', 'rachel', 'matthew', 'roger', | |
'betty', 'melissa', 'judith', 'charlie'] | |
names.pop(0) | |
names.insert(0, 'mark') | |
## pythonic | |
from collections import deque | |
names = deque(['raymond', 'rachel', 'matthew', 'roger', | |
'betty', 'melissa', 'judith', 'charlie']) |
NewerOlder