Skip to content

Instantly share code, notes, and snippets.

View p-m-m-c's full-sized avatar

Paul p-m-m-c

  • Utrecht, Netherlands
View GitHub Profile
name: template-env
channels:
- conda-forge
- defaults
dependencies:
- bzip2=1.0.6=1
- ca-certificates=2018.10.15=ha4d7672_0
- certifi=2018.10.15=py36_1000
- jupyterlab=0.35.4=py36_0
- jupyterlab_server=0.2.0=py_0
@p-m-m-c
p-m-m-c / .bash_profile
Last active March 11, 2019 14:29
Bash config
# Name, domain and location are different colors
export PS1="\n\[\033[1;32m\]\u\[\033[1;30m\]@\[\033[34m\]\h \[\033[1;30m\]: \[\033[1;33m\]\w\[\e[0;31m\]\$(parse_git_branch)\n \[\033[m\]$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
# Define aliases for frequent commands
alias ls='ls -GFh'
alias ..='cd ..'
alias ....='cd ../..'
alias lal='ls -al'
@p-m-m-c
p-m-m-c / .vimrc
Last active January 21, 2019 19:47
Vim config
syntax on
set tabstop=4
set shiftwidth=4
set autoindent
set expandtab
set smarttab
@p-m-m-c
p-m-m-c / plt_multiple_plots.py
Created September 15, 2017 15:26
Code for drawing multiple plots on automatically scaled figure
# Code for plotting multiple plots
n_subplots = 8
assert n_subplots%2 == 0, 'Use even number of subplots'
fig, axarr = plt.subplots(n_subplots//2,2)
fig.set_figwidth(15)
fig.set_figheight(4*axarr.shape[0])
for numb, ax in enumerate(axarr.ravel()):
X = np.arange(10)
@p-m-m-c
p-m-m-c / draw_heatmap_from_df.py
Created September 15, 2017 14:26
Heatmap plot for df
# INPUT: pandas DataFrame
# Compute the correlation matrix
corr = df.corr()
# Generate a mask for the upper triangle
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
# Set up the matplotlib figure
@p-m-m-c
p-m-m-c / extract_results_gridsearch.py
Last active November 13, 2018 19:28
Extracting scores from gridsearch object
def extract_results_GS(grid_scores):
"""
After applying gridsearch to a dataset, for all different combinations of parameters, an array of scores is
given in the grid_scores object of the estimator. The length of this array is equal to the number of fits of
the model. E.g. a model that is fit on three different train/test combinations, as happens in cross-validation. From that, the
mean validation score and standard deviation of the scores can be obtained. This function converts a
GridSearchCV.grid_scores_ object to a pandas DataFrame object. The frame is unsorted, because the best parameter
setting can be verified in the GridSearchCV.best_estimator_ and best_score_ properties.
"""