This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a very simple Python 2.7 implementation of the Information Set Monte Carlo Tree Search algorithm. | |
# The function ISMCTS(rootstate, itermax, verbose = False) is towards the bottom of the code. | |
# It aims to have the clearest and simplest possible code, and for the sake of clarity, the code | |
# is orders of magnitude less efficient than it could be made, particularly by using a | |
# state.GetRandomMove() or state.DoRandomRollout() function. | |
# | |
# An example GameState classes for Knockout Whist is included to give some idea of how you | |
# can write your own GameState to use ISMCTS in your hidden information game. | |
# | |
# Written by Peter Cowling, Edward Powley, Daniel Whitehouse (University of York, UK) September 2012 - August 2013. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
NMF by coordinate descent, designed for sparse data (without missing values) | |
""" | |
# Author: Mathieu Blondel <mathieu@mblondel.org> | |
# License: BSD 3 clause | |
import numpy as np | |
import scipy.sparse as sp | |
import numba |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to create data for http://ukdataexplorer.com/census/ | |
# Author James Trimble, james.trimble at yahoo.co.uk | |
# | |
# This code is based on Alex Singleton's work: | |
# http://rpubs.com/alexsingleton/openatlas | |
# http://www.alex-singleton.com/2011-census-open-atlas-project/ | |
# | |
# The script takes around an hour to run. It could be made faster! | |
# The script requires a lookup table and shapefile from | |
# https://geoportal.statistics.gov.uk/geoportal/catalog/search/browse/browse.page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Corey Chivers, 2012 ## | |
sim_bayes<-function(p=0.5,N=100,y_lim=20,a_a=2,a_b=10,b_a=8,b_b=3) | |
{ | |
## Simulate outcomes in advance | |
outcomes<-sample(1:0,N,prob=c(p,1-p),replace=TRUE) | |
success<-cumsum(outcomes) | |
for(frame in 1:N) | |
{ | |
png(paste("plots/",1000+frame,".png",sep="")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fast non-maximum suppression in C, port from | |
* http://quantombone.blogspot.com/2011/08/blazing-fast-nmsm-from-exemplar-svm.html | |
* | |
* @blackball (bugway@gmail.com) | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <limits.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy as sp | |
from scipy import optimize as opt | |
def nnlr(X, y, C): | |
""" | |
Non-negative Logistic Regression with L2 regularizer | |
""" | |
def lr_cost(X, y, theta, C): | |
m = len(y) | |
return (1./m) * (sp.dot(-y, sp.log(sigmoid(sp.dot(X, theta)))) \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function top = nms(boxes, overlap) | |
% top = nms_fast(boxes, overlap) | |
% Non-maximum suppression. (FAST VERSION) | |
% Greedily select high-scoring detections and skip detections | |
% that are significantly covered by a previously selected | |
% detection. | |
% NOTE: This is adapted from Pedro Felzenszwalb's version (nms.m), | |
% but an inner loop has been eliminated to significantly speed it | |
% up in the case of a large number of boxes | |
% Tomasz Malisiewicz (tomasz@cmu.edu) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Scanner: match text to generate tokens. | |
Adam Blinkinsop <blinks@acm.org> | |
First, construct a scanner with the tokens you'd like to match described as | |
keyword arguments, using Python-syntax regular expressions. | |
WARNING: Group syntax in these expressions has an undefined effect. | |
>>> simple = Scan(ID=r'\w+') | |