Skip to content

Instantly share code, notes, and snippets.

import numpy as np
def plot_confusion_matrix(cm,
target_names,
title='Confusion matrix',
cmap=None,
normalize=True):
"""
given a sklearn confusion matrix (cm), make a nice plot
@FangliangBai
FangliangBai / Porting Virtualenv
Last active July 22, 2019 13:18
Transfer the venv from one computer to another one.
1. Two computers install `Python` and `virtualenv` of same version.
2. On source computer:
pip freeze > requirements.txt
pip download -d your_offline_packages_folder_dir -r requirements.txt
3. On target computer:
pip install --no-index --find-links=your_offline_packages_folder_dir -r requirements.txt
@FangliangBai
FangliangBai / Excellent Softwares
Last active July 19, 2019 14:56
List of Excellent Softwares -- keep updating
uTools Win Extension of Everything
mackup Lnx Keep your application settings in sync
Blender Lnx 三维动画制作
@FangliangBai
FangliangBai / Ubuntu 16.04 use PulseAudio Volume Control
Created July 19, 2019 08:53
Ubuntu 16.04 use PulseAudio Volume Control
% Description:
% Allow user to output audio from HDMI or other audio devices.
% Reference:
% https://www.linuxidc.com/Linux/2019-02/156865.htm
$ sudo apt install pulseaudio
% Reboot
$ sudo apt install pavucontrol
@FangliangBai
FangliangBai / Ubuntu 16.04 recover files which were deleted by rm command
Created July 18, 2019 10:05
Ubuntu 16.04 recover files which were deleted by rm command
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% - This snip is for ext4 partition.
% - Do this operation immediately after you deleting the files.
% - There is a possibility that some files are not recoverable.
% - Reference:
% https://blog.csdn.net/q1302182594/article/details/47315177
% https://blog.csdn.net/fjb2080/article/details/5604103
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Install extundelete.
filename = os.path.join(data_dir, trainfilename)
row_img = []
with open(filename) as fid:
content = fid.read()
content = content.split('\n')
content = content[:-1]
for i in content:
img = skimage.io.imread(fname, as_grey=False, plugin=None, flatten=None, **plugin_args)
row_img.append(img)