virtualenv --no-site-packages --distribute -p `which python3` <env_name>
or simply
pyvenv <env_name>
Download/Copy all related *.zip files in one directory. | |
Open terminal and change to that directory which has all zip files. | |
Enter command zip -s- FILE_NAME.zip -O COMBINED_FILE.zip | |
Enter unzip COMBINED_FILE.zip |
def print_stats(y_true, y_pred): | |
print(f'Total accuracy: {accuracy_score(y_true, y_pred)}') | |
print() | |
cm = pd.DataFrame(confusion_matrix(y_true, y_pred), | |
columns=pd.MultiIndex.from_arrays([['not_fit', 'fit']], names=['My fit']), | |
index=['not_fit', 'fit'], | |
) | |
cm.index.name = 'Toloka fit' | |
print('Confusion matrix') | |
print(cm) |
# register file moved without svn mv | |
set -eu | |
shopt -s expand_aliases | |
. ~/.bash_aliases | |
old=$1 | |
new=$2 | |
tmp=$(mktemp svnmove.XXXXXX) | |
svn rm --keep-local "$new" | |
mv "$new" "$tmp" | |
svn revert "$old" |
# After Ubuntu 16.04, Systemd becomes the default. | |
# It is simpler than https://gist.github.com/Doowon/38910829898a6624ce4ed554f082c4dd | |
[Unit] | |
Description=Jupyter Notebook | |
[Service] | |
Type=simple | |
PIDFile=/run/jupyter.pid | |
ExecStart=/home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config=/home/phil/.jupyter/jupyter_notebook_config.py |
from sqlalchemy.dialects import postgresql | |
def bulk_upsert(session: Session, | |
items: Sequence[Mapping[str, Any]]): | |
session.execute( | |
postgresql.insert(MyModel.__table__) | |
.values(items) | |
.on_conflict_do_update( | |
index_elements=[MyModel.id], | |
set_={MyModel.my_field.name: 'new_value'}, |
from scipy.sparse import csr_matrix | |
import numpy as np | |
def make_sparse(clf): | |
""" | |
Make sklearn.svm.SVC trained on dense data work on sparse features without fitting if again. | |
""" | |
clf._sparse = True | |
clf.support_vectors_ = csr_matrix(clf.support_vectors_) |
import numpy as np | |
import scipy as sp | |
import scipy.sparse | |
import tempfile | |
def hstack(parts): | |
with tempfile.TemporaryFile() as data_file, tempfile.TemporaryFile() as indices_file: | |
data = np.memmap(data_file, | |
dtype=parts[0].dtype, |
import tkinter | |
import time | |
master = tkinter.Tk() | |
canvas = tkinter.Canvas(master, width=1000, height=1000) | |
canvas.pack() | |
def animation(): | |
def draw_point(x, y, c='black'): |
sudo kill -9 $(ps aux | grep <name> | awk '{print $2}') |
virtualenv --no-site-packages --distribute -p `which python3` <env_name>
or simply
pyvenv <env_name>