Skip to content

Instantly share code, notes, and snippets.

@goraj
goraj / fold_lgbm.py
Created February 2, 2018 16:14
Custom fold indices using lightgdm
import numpy as np
from sklearn.datasets import load_digits
from sklearn.metrics import roc_auc_score
import lightgbm as lgbm
if __name__ == '__main__':
np.random.seed(4242)
d = load_digits()
@goraj
goraj / video_recorder_setup_videoio.cpp
Created February 24, 2018 13:44
video_recorder_setup_videoio.cpp
bool video_recorder::setup_videoio(cv::Mat & mat, double fps) {
std::string cmdline = ffmpeg_path_.string() +
" -framerate " + std::to_string(static_cast<int>(fps)) +
" -f image2pipe -vcodec png -i - -c:v libx264 -pix_fmt yuv444p" +
" -preset faster " +
//" -preset ultrafast " +
" -crf 14" +
//" -qp 0 " +
" -vf drawtext=\"fontcolor = white:fontfile = " +
def offset_version_detection(quality_string = ''):
"""Tries to detect phred score offset automatically.
Args:
quality_string used to estimate format version and offset
Returns:
Phred offset
Raises:
ValueError: Cannot evaluate empty quality string
ValueError: Cannot evaluate phred offset
"""
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 21 08:36:44 2018
@author: user
"""
import cv2
import numpy as np
@goraj
goraj / incremental_lightgbm.py
Last active October 1, 2021 03:25
incremental learning lightgbm
# -*- coding: utf-8 -*-
"""
@author: goraj
"""
import lightgbm as lgbm
from sklearn.datasets import load_digits
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score
def ic50_in_nM_to_pic50(nM):
try:
return 9.0 - math.log10(float(nM))
except Exception as e:
return 0.0
def ic50_in_uM_to_pic50(uM):
nM = uM * 1000
return ic50_in_nM_to_pic50(nM)
@goraj
goraj / make_window_borderless.py
Created June 11, 2018 21:10
Borderless opencv window
def make_window_borderless(self):
"""
Requires: pywin32
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32
import win32gui as wg
import win32api as wa
import win32con as wc
Based on: https://github.com/howardjohn/pyty/blob/master/src/window_api.py
"""
@goraj
goraj / oob_patch.py
Created August 12, 2018 02:02
custom oob score function sklearn
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 21:41:24 2018
@author: goraj
"""
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from warnings import warn
@goraj
goraj / reproduce.py
Created December 3, 2018 20:35
reproduce.py
'''
>>> dask.__version__
'1.0.0'
>>> umap.__version__
'0.3.7'
'''
from dask.distributed import Client
def do_run(arg1, arg2):
@goraj
goraj / reproduce_segfault.log
Created December 5, 2018 22:11
reproduce_segfault.log
-bash-4.2$ ./Miniconda3-latest-Linux-x86_64.sh -b -p ~/m3_centos7
PREFIX=/home/username/m3_centos7
installing: python-3.7.0-hc3d631a_0 ...
Python 3.7.0 (default, Jun 28 2018, 13:15:42)
[GCC 7.2.0]
installing: ca-certificates-2018.03.07-0 ...
installing: conda-env-2.6.0-1 ...
installing: libgcc-ng-8.2.0-hdf63c60_1 ...