Skip to content

Instantly share code, notes, and snippets.

@greeness
greeness / simhash links
Last active April 28, 2020 14:05
simhash
@greeness
greeness / gist:1498382
Created December 19, 2011 18:53
random projection lsh with random number from a pre-generated pool
import numpy
import math
# LSH signature generation using random projection
def get_signature(user_vector, rand_proj):
res = 0
for p in (rand_proj):
res = res << 1
val = numpy.dot(p, user_vector)
if val >= 0:
@greeness
greeness / gist:1887114
Created February 22, 2012 20:40
dou di zhu
斗地主人工智能 [2007-3-7]
http://www.ylog.net/blog_show.asp?log_id=2148
近一周在制作斗地主纸牌游戏的人工智能
算法主要是用宽度优先生成一棵搜索树
再根据玩牌的技巧进行剪枝与判权....
节点权值判断主要由有限状态机构成
@greeness
greeness / gist:3985998
Last active May 28, 2017 04:02
q-learning example
from random import random, choice, randint
"""
+++++++++++++++++++++
+ 10 + 1 + 1 + 1 +
+++++++++++++++++++++
+ 1 + 1 + 1 + 1 +
+++++++++++++++++++++
+ 1 + 1 + 1 + 1 +
+++++++++++++++++++++
+ 1 + 1 + 1 + 1 +
#The input data should be in CSV format.
# Each row is a campaign. The columns are (description and variable name):
# Campaign id (id)
# Conversion rate (cvr)
# Bid price (price)
# Max allocated campaign budget (max_allocation)
import csv
import sys
id cvr price max_allocation
1 0.005 4 100
2 0.001 0.75 100
3 0.0001 0.1 100
{
"metadata": {
"name": "2d Convolution"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{