Skip to content

Instantly share code, notes, and snippets.

@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@whophil
whophil / jupyter.service
Last active October 30, 2023 16:33 — forked from doowon/jupyter_systemd
A systemd script for running a Jupyter notebook server.
# 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
@Nikolay-Lysenko
Nikolay-Lysenko / xgb_quantile_loss.py
Last active October 25, 2023 13:26
Customized loss function for quantile regression with XGBoost
import numpy as np
def xgb_quantile_eval(preds, dmatrix, quantile=0.2):
"""
Customized evaluational metric that equals
to quantile regression loss (also known as
pinball loss).
Quantile regression is regression that
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MMesch
MMesch / robust_fourier_sklearn.py
Created May 22, 2017 16:27
Robust Fourier Transform and Custom Features with Scikit Learn
#!/usr/bin/env python
"""
Robust non-linear feature estimation with scikit-learn applied to
the Fourier Transform.
"""
from matplotlib import pyplot as plt
import numpy as np
from sklearn.base import TransformerMixin
from sklearn.pipeline import make_pipeline
@MMesch
MMesch / robust_splines_sklearn.py
Last active July 6, 2023 23:04
Robust Spline Regression with Scikit-Learn
#!/usr/bin/env python
"""
Robust B-Spline regression with scikit-learn
"""
import matplotlib.pyplot as plt
import numpy as np
import scipy.interpolate as si
from sklearn.base import TransformerMixin
from sklearn.pipeline import make_pipeline
@MMesch
MMesch / bspline_basis_scipy.py
Created July 21, 2017 12:51
simple script that extracts an ND Bspline basis from scipy (plots in 1D and 2D)
#!/usr/bin/env python
"""
ND Bspline basis class for Python
"""
import numpy as np
import scipy.interpolate as si
import matplotlib.pyplot as plt
import itertools
@kevinzakka
kevinzakka / data_loader.py
Last active April 19, 2024 23:42
Train, Validation and Test Split for torchvision Datasets
"""
Create train, valid, test iterators for CIFAR-10 [1].
Easily extended to MNIST, CIFAR-100 and Imagenet.
[1]: https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4
"""
import torch
import numpy as np
from urllib.parse import urlparse
import lightgbm as lgb
import threading
def _parse_machines(workers, listen_port):
"""From dask worker info to LightGBM mlist"""
# TODO: Assert that we're using TCP?
mlist = ['127.0.0.1:{}'.format(listen_port)] + [urlparse(worker).netloc
for worker in workers]
@MMesch
MMesch / minimal_cwt.py
Last active September 11, 2018 13:26
Minimal Continuous Wavelet Transform
#!/usr/bin/env python
"""Mini implementation of continuous wavelet transform (Morlet wavelet)."""
import numpy as np
import matplotlib.pyplot as plt
def continuous_wavelet_transform(signal, frequencies, time_step=1.0,
wavelet_width=5):