Skip to content

Instantly share code, notes, and snippets.

View WMJi's full-sized avatar

WMJ improved WMJi

  • independent
  • Dalian, China
View GitHub Profile
@WMJi
WMJi / PSI.R
Created December 6, 2017 10:02 — forked from agabrielsen/PSI.R
Population Distribution Index (PSI) Studies on the Validation of Internal Rating Systems
PSI = function(X,Y,saveplot,showplot,ratings,psinames) {
# ---------------------------------------------------------------
# PURPOSE:
# Population Distribution Index (PSI)
# Basel Committee on Banking Supervision
# Working Paper No. 14
# Studies on the Validation of Internal Rating Systems
# ---------------------------------------------------------------
# INPUTS:
# X Array of (%) of Frequency
@WMJi
WMJi / GBT_CaliforniaHousing.py
Created November 6, 2017 08:58 — forked from tonicebrian/GBT_CaliforniaHousing.py
Gradient Boosting Trees using Python
# =============
# Introduction
# =============
# I've been doing some data mining lately and specially looking into `Gradient
# Boosting Trees <http://en.wikipedia.org/wiki/Gradient_boosting>`_ since it is
# claimed that this is one of the techniques with best performance out of the
# box. In order to have a better understanding of the technique I've reproduced
# the example of section *10.14.1 California Housing* in the book `The Elements of Statistical Learning <http://www-stat.stanford.edu/~tibs/ElemStatLearn/>`_.
# Each point of this dataset represents the house value of a property with some
# attributes of that house. You can get the data and the description of those
@WMJi
WMJi / hist.py
Created July 24, 2017 14:16 — forked from bistaumanga/hist.py
Histogram Equalization in python
import numpy as np
def imhist(im):
# calculates normalized histogram of an image
m, n = im.shape
h = [0.0] * 256
for i in range(m):
for j in range(n):
h[im[i, j]]+=1
return np.array(h)/(m*n)
@WMJi
WMJi / mnist.py
Created July 23, 2017 16:35 — forked from akesling/mnist.py
import os
import struct
import numpy as np
"""
Loosely inspired by http://abel.ee.ucla.edu/cvxopt/_downloads/mnist.py
which is GPL licensed.
"""
def read(dataset = "training", path = "."):
@WMJi
WMJi / partial_corr.py
Created April 1, 2017 21:36 — forked from wizzeh/partial_corr.py
Partial Correlation in Python
"""
Partial Correlation in Python
Based on Fabian Pedregosa-Izquierdo's implementation at:
https://gist.github.com/fabianp/9396204419c7b638d38f
This version of the algorithm calculates the partial correlation coefficient controlling for Z.
I use row vectors here, for whatever reason.
"""
@WMJi
WMJi / clojure-match.clj
Created June 14, 2016 13:19 — forked from ckirkendall/clojure-match.clj
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})

Here's the canonical TOML example from the TOML README, and a YAML version of the same. Which looks nicer?

title = "TOML Example"

[owner] name = "Tom Preston-Werner"

@WMJi
WMJi / gist:1f4f384d9327f779b06bcbee046860ac
Created May 2, 2016 03:39 — forked from cataska/gist:2717986
Why is Lisp so great? or Why so many parenthesis?
;; Why is Lisp so great? or Why so many parenthesis?
;; The funny thing about Lisp is that everybody asks why it has so may parenthesis. Quite a few friends of mine who have studied Lisp in college don’t like it that much. I couldn’t really understand why, until I realized they usually take a class that uses the book Concepts of Programming Languages by Robert W. Sebesta as a textbook. I’m in no position to review this book because I haven’t read it. But from what I’ve skimmed, Lisp is not very well represented in this book, to put it very nicely. He describes Lisp only as a functional programming language, tells a little bit about cons cells, and that’s pretty much it! No object orientation in lisp, no syntactic abstraction, no meta-programming, and so on. My feeling is that if I didn’t know Lisp and read this book I wouldn’t be very impressed by Lisp.
;; So why is Lisp so great and why so many parenthesis? These two different questions have the same answer; because Lisp have syntactic abstraction trough t
@WMJi
WMJi / Plot_Examples.md
Created February 11, 2016 07:52 — forked from gizmaa/Plot_Examples.md
Various Julia plotting examples using PyPlot
@WMJi
WMJi / tmux.conf
Created February 9, 2016 22:16 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000