Skip to content

Instantly share code, notes, and snippets.

View stormxuwz's full-sized avatar
🤣
Sleepy?

Wenzhao Xu stormxuwz

🤣
Sleepy?
View GitHub Profile
@fabianp
fabianp / ranking.py
Last active February 1, 2024 10:02
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 1999
"Learning to rank from medical imaging data." Pedregosa, Fabian, et al.,
Machine Learning in Medical Imaging 2012.
@mason-stewart
mason-stewart / Default (OSX).sublime-keymap
Last active January 9, 2019 02:06
Better user key bindings for SublimeREPL.
[
// Remapping of *some* SublimeREPL shortcuts
{ "keys": ["ctrl+super+s"], "command": "repl_transfer_current", "args": {"scope": "selection"}},
{ "keys": ["ctrl+shift+,", "s"], "command": "repl_transfer_current", "args": {"scope": "selection", "action":"view_write"}},
{ "keys": ["ctrl+shift+super+f"], "command": "repl_transfer_current", "args": {"scope": "file"}},
{ "keys": ["shift+ctrl+,", "f"], "command": "repl_transfer_current", "args": {"scope": "file", "action":"view_write"}},
{ "keys": ["ctrl+super+l"], "command": "repl_transfer_current", "args": {"scope": "lines"}},
{ "keys": ["shift+ctrl+,", "l"], "command": "repl_transfer_current", "args": {"scope": "lines", "action":"view_write"}},
{ "keys": ["ctrl+super+b"], "command": "repl_transfer_current", "args": {"scope": "block"}},
{ "keys": ["shift+ctrl+,", "b"], "command": "repl_transfer_current", "args": {"scope": "block", "action":"view_write"}}
@iandanforth
iandanforth / kmeansExample.py
Last active October 5, 2023 12:35
A pure python implementation of K-Means clustering. Optional cluster visualization using plot.ly.
#############################################################################
# Full Imports
from __future__ import division
import math
import random
"""
This is a pure Python implementation of the K-means Clustering algorithmn. The
original can be found here:
@florianhartig
florianhartig / gaussianAutoregressiveExample.jags.
Last active November 9, 2021 11:07
A modification of code posted originally by Petr Keil http://www.petrkeil.com/?p=1910, to illustrate some comments I made in response to this blog post
library(mvtnorm) # to draw multivariate normal outcomes
library(R2jags) # JAGS-R interface
# function that makes distance matrix for a side*side 2D array
dist.matrix <- function(side)
{
row.coords <- rep(1:side, times=side)
col.coords <- rep(1:side, each=side)
row.col <- data.frame(row.coords, col.coords)
D <- dist(row.col, method="euclidean", diag=TRUE, upper=TRUE)
@stevepowell99
stevepowell99 / extractAnnotations.py
Last active December 20, 2021 21:03
Extracts annotations and highlighted passages in all .pdf files in a folder recursively and outputs them as text files with the same name and modification date
#!/usr/bin/env python
# see http://socialdatablog.com/extract-pdf-annotations.html
myxkfolder="/home/steve/xk/" #you need to set this to where you want your to-dos to appear
import poppler, os.path, os, time, datetime
for root, dirs, files in os.walk('./'):
for lpath in files:
"""Illustration for various types of namespace scopes in TensorFlow.
> python tf_scopes.py
foo_name_scoped :
v.name= v:0
v2.name= foo_name_scoped/v2:0
a.name= Variable:0
b.name= Variable_1:0
result_op.name= foo_name_scoped/Add:0
foo_op_scoped :