Skip to content

Instantly share code, notes, and snippets.

"""Kernel K-means"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
from sklearn.base import BaseEstimator, ClusterMixin
from sklearn.metrics.pairwise import pairwise_kernels
from sklearn.utils import check_random_state
###########################################################################
###########################################################################
## @purpose: Simulate return data with dense shocks and show that the
## LASSO doesn't add any forecasting power.
## ------------------------------------------------------------------------
## @author: Alex Chinco
## @date: 04-DEC-2015
###########################################################################
###########################################################################
@vishalbelsare
vishalbelsare / ranking.py
Created September 8, 2017 15:43 — forked from agramfort/ranking.py
Pairwise ranking using scikit-learn LinearSVC
"""
Implementation of pairwise ranking using scikit-learn LinearSVC
Reference: "Large Margin Rank Boundaries for Ordinal Regression", R. Herbrich,
T. Graepel, K. Obermayer.
Authors: Fabian Pedregosa <fabian@fseoane.net>
Alexandre Gramfort <alexandre.gramfort@inria.fr>
"""
@vishalbelsare
vishalbelsare / TimeSeries-Decomposition.ipynb
Created December 5, 2017 21:41 — forked from balzer82/TimeSeries-Decomposition.ipynb
TimeSeries Decomposition in Python with statsmodels and Pandas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vishalbelsare
vishalbelsare / jupyter.service
Created December 15, 2017 21:02 — forked from whophil/jupyter.service
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
@vishalbelsare
vishalbelsare / tracker-query-dbus.el
Last active December 24, 2017 14:30
tracker-query-dbus
(dbus-introspect :session "org.freedesktop.Tracker1"
"/org/freedesktop/Tracker1")
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"
\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">
<!-- GDBus 2.54.0 -->
<node>
<node name=\"Backup\"/>
<node name=\"Steroids\"/>
<node name=\"Statistics\"/>
<node name=\"Status\"/>
@vishalbelsare
vishalbelsare / gist:1af34abf905f3a4b30c3a325a48ba22a
Created February 20, 2018 15:34
journalctl - libinput, xwayland, gnome shell
Feb 20 16:28:28 einstein org.gnome.Shell.desktop[19485]: gnome-shell: ../libinput-1.10.0/src/evdev-mt-touchpad-tap.c:1073: tp_tap_handlle_state: Assertion `tp->tap.nfingers_down <= tp->nfingers_down' failed.
Feb 20 16:28:28 einstein org.gnome.Shell.desktop[19485]: == Stack trace for context 0x5638f1dec000 ==
Feb 20 16:28:29 einstein gnome-terminal-[19854]: Error reading events from display: Broken pipe
Feb 20 16:28:29 einstein evolution-alarm[19716]: Error reading events from display: Broken pipe
Feb 20 16:28:29 einstein org.gnome.Shell.desktop[19485]: (EE)
Feb 20 16:28:29 einstein org.gnome.Shell.desktop[19485]: Fatal server error:
Feb 20 16:28:29 einstein org.gnome.Shell.desktop[19485]: (EE) failed to read Wayland events: Broken pipe
Feb 20 16:28:29 einstein org.gnome.Shell.desktop[19485]: (EE)
Feb 20 16:28:29 einstein systemd[19409]: gnome-terminal-server.service: Main process exited, code=exited, status=1/FAILURE
Feb 20 16:28:29 einstein systemd[19409]: gnome-terminal-server.service: Failed with result 'e
import pandas as pd
import pandas_datareader.data as web
import numpy as np
import datetime
from scipy.optimize import minimize
TOLERANCE = 1e-10
def _allocation_risk(weights, covariances):
@vishalbelsare
vishalbelsare / asset-pricing-time-scales.R
Created March 27, 2018 18:01 — forked from alexchinco/asset-pricing-time-scales.R
Code to create figures for my post "Identifying Relevant Asset Pricing Time Scales". url: http://www.alexchinco.com/identifying-relevant-asset-pricing-time-scales/
################################################################################
################################################################################
## Prep workspace
################################################################################
################################################################################
options(width=200, digits=6, digits.secs=6)
rm(list=ls())
library(foreign)
@vishalbelsare
vishalbelsare / code.R
Created March 27, 2018 18:30 — forked from alexchinco/code.R
Illustrative Example: Why Bayesian Variable Selection Doesn't Scale
## ##########################################################################################################################
## ##########################################################################################################################
## @section: Prep workspace
## ##########################################################################################################################
## ##########################################################################################################################
options(width=200, digits=6, digits.secs=6)
rm(list=ls())