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
# https://stackoverflow.com/a/45438143/955952 | |
def random_choice_noreplace(m, n, axis=-1): | |
# m, n are the number of rows, cols of output | |
return np.random.rand(m, n).argsort(axis=axis) |
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
conda config --append channels bioconda | |
conda install perl perl-db-file perl-xml-parser perl-libwww-perl # This will install tons of packages | |
sed -i '1 s/perl.*/env perl/' ~/.files2rouge/ROUGE-1.5.5.pl |
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
arr = np.array(np.meshgrid(arr0, arr1)).T.reshape(-1, 2) |
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
sort -u -k 1,2 run.monobert.dev.small.tsv | trec_eval -m recip_rank_cut.10 qrels.dev.small.tsv - | |
sort -u -k 1,2 run.duobert.dev.small.tsv | trec_eval -m recip_rank_cut.10 qrels.dev.small.tsv - |
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
perf record -F 99 -g -a <command> | |
perf script | ~/src/FlameGraph/stackcollapse-perf.pl | ~/src/FlameGraph/flamegraph.pl > perf.svg | |
google-chrome perf.svg |
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
# https://stackoverflow.com/a/10154763/955952 | |
fig.savefig('samplefigure', bbox_extra_artists=(lgd,text), bbox_inches='tight') |
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
% https://tex.stackexchange.com/q/32886/124998 | |
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{myfig} |
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
from more_itertools import always_iterable | |
from typing import Callable, Union | |
import multiprocessing | |
import pandas as pd | |
def groupby_mp(groupby_df: pd.core.groupby.DataFrameGroupBy, | |
func: Callable[[pd.DataFrame], Union[pd.DataFrame, pd.Series]], | |
num_cpus: int = multiprocessing.cpu_count() // 2, | |
chunksize: int = 1) -> pd.DataFrame: |
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
"""Information Retrieval metrics | |
Useful Resources: | |
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt | |
http://www.nii.ac.jp/TechReports/05-014E.pdf | |
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf | |
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf | |
Learning to Rank for Information Retrieval (Tie-Yan Liu) | |
""" | |
import numpy as np |
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 tqdmf(path, *args, **kwargs): | |
with tqdm( | |
total=os.stat(path).st_size, | |
unit='B', | |
unit_scale=True, | |
unit_divisor=1024, | |
*args, | |
**kwargs) as bar: | |
with open(path, 'r') as f: | |
for line in f: |