Skip to content

Instantly share code, notes, and snippets.

@ybenjo
ybenjo / README.md
Last active December 13, 2023 08:04 — forked from yagays/agqr.rb
save AGQR radio programs.

agqr.rb

これは何

AGQR の放送を保存するスクリプト.

fork 元との違いは

yagays / agqr.rb には

  • 31日まである月に翌日の指定が失敗する

というバグが存在する.

@ybenjo
ybenjo / biterm_topic_model.rb
Last active June 3, 2023 03:16
biterm topic model(www2013)
# Xiaohui Yan, A biterm topic model for short texts(WWW 2013)
require 'set'
class Biterm
def initialize(alpha, beta, k)
@alpha = alpha
@beta = beta
@k = k
@doc_w = { }
@ybenjo
ybenjo / test.py
Created May 4, 2020 05:36
scipy.sparse.csgraph.maximum_bipartite_matching is broken when get complete bipartite graph
from scipy.sparse import lil_matrix, csr_matrix
from scipy.sparse.csgraph import maximum_bipartite_matching
import random
N = 10
M = 10
random.seed(0)
for x in range(5):
mat = lil_matrix((N, M))
@ybenjo
ybenjo / convert_checkins_json_to_ics.rb
Last active June 8, 2019 07:36
converts foursquare's (dumped) check-ins data to ics file.
# coding: utf-8
require 'json'
require 'time'
require 'digest/md5'
srand(0)
data = JSON.load(open("#{__dir__}/checkins.json").read)
output_file = "#{__dir__}/checkins.ics"
@ybenjo
ybenjo / nfm.py
Last active March 19, 2018 23:52
neural factorization machines (SIGIR 2017) unofficial code by Chainer
import numpy as np
import chainer
from chainer import functions as F
from chainer import links as L
class NFMClassifier(chainer.Chain):
def __init__(self, n_feature, n_dim_emb, n_dim_1, n_dim_2):
np.random.seed(6162)
self.n_feature = n_feature
@ybenjo
ybenjo / bug.py
Last active July 27, 2017 23:44
xgboost bug (Classifier can't handle nested array)
from xgboost import XGBClassifier
model = XGBClassifier(seed = 1)
# XOR Pattern
train_data = [
[1, 0],
[0, 1],
[1, 1],
[0, 0],
@ybenjo
ybenjo / bug.py
Last active July 27, 2017 23:41
xgboost bug (handling nested array)
# Version: 0.6a2
from xgboost import XGBRegressor
model = XGBRegressor(seed = 1)
# XOR pattern + [0, 0, 0]
train_data = [
[1, 0] + [0] * 3,
[0, 1] + [0] * 3,
[1, 1] + [0] * 3,
@ybenjo
ybenjo / ccut
Last active April 27, 2016 08:39
cut with column names
#!/usr/bin/env ruby
# cat data.tsv | ccut -d delim -c name,name,name...
require 'trollop'
opts = Trollop::options do
opt :delim, 'delimitor', default: "\t"
opt :column, 'column name(s)', type: String
end
delim = opts[:delim]
@ybenjo
ybenjo / ecoweb.py
Created December 30, 2015 08:52
The Web as a Jungle: Non-Linear Dynamical Systems for Co-evolving Online Activities (WWW 2015)
import numpy as np
import sys
from collections import defaultdict
from lmfit import minimize, Parameters
from sklearn.decomposition import FastICA
import math
# This script is (incomplete and buggy) implementation of
# The Web as a Jungle: Non-Linear Dynamical Systems for Co-evolving Online Activities, (WWW 2015).
# http://www.cs.kumamoto-u.ac.jp/~yasuko/PUBLICATIONS/www15-ecoweb.pdf
@ybenjo
ybenjo / sample2.ret
Created September 29, 2013 11:40
sample
0 a 0.545564
0 b 0.235328
0 c 0.0589112
0 d 0.160196
1 a 0.282141
1 b 0.400634
1 c 0.227655
1 d 0.0895693
2 a 0.0782046
2 b 0.155836