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
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())
@vishalbelsare
vishalbelsare / talk.md
Created April 26, 2018 11:40 — forked from phizaz/talk.md
BKKMLMEETUP: Q-Learning for Trading

Q-Learning for algorithm trading

Q-Learning background

by Konpat

Q-Learninng is a reinforcement learning algorithm, Q-Learning does not require the model and the full understanding of the nature of its environment, in which it will learn by trail and errors, after which it will be better over time. And thus proved to be asymtotically optimal.

  • you need first to understand the Markov Decision Process, which is a graph consisting of (states, actions, rewards) denoting {S}, {A}, {R}
  • State (S)
@vishalbelsare
vishalbelsare / README.md
Created September 10, 2018 21:44 — forked from lvm/README.md
[WIP] hackish emacs mode for FoxDot

Installation

  1. put foxdot-cli.py in the same directory as the FoxDot installaton (in case you're using virtualenv, otherwise comment from lines 5 to 7)
  2. copy foxdot-mode.el to ~/.emacs.d/lisp
  3. add (defvar foxdot-cli-path "/path/to/foxdot-cli/") in your ~/.emacs file
  4. in Emacs M-x load-library and complete with foxdot-mode
  5. Type C-c C-f or M-x foxdot-start to start
  6. Type C-c C-e or M-x foxdot-execute to evaluate a line or a block of code