Skip to content

Instantly share code, notes, and snippets.

View syou6162's full-sized avatar

Yasuhisa Yoshida syou6162

View GitHub Profile
@nkt1546789
nkt1546789 / puclassifier.py
Last active May 12, 2022 15:13
Learning Classifiers from positive and unlabeled data by sample weighting proposed by Elkan and Noto 2008.
import numpy as np
from sklearn.linear_model import SGDClassifier
from sklearn.cross_validation import StratifiedKFold
from sklearn.grid_search import GridSearchCV
class PUClassifier(object):
def __init__(self, trad_clf=None, n_folds=2):
self.trad_clf = trad_clf
self.n_folds = n_folds
@odashi
odashi / chainer_encoder_decoder.py
Last active January 22, 2021 14:03
Training and generation processes for neural encoder-decoder machine translation.
#!/usr/bin/python3
import datetime
import sys
import math
import numpy as np
from argparse import ArgumentParser
from collections import defaultdict
from chainer import FunctionSet, Variable, functions, optimizers
@odashi
odashi / chainer_rnnlm.py
Created August 24, 2015 18:03
ChainerによるRNN言語モデルの学習器
#!/usr/bin/python3
# RNNLM trainer
# date: 2015-8-25
# author: @odashi_t
import datetime
import sys
import math
import numpy as np
@sinhrks
sinhrks / dtw.R
Created November 14, 2014 13:36
Dynamic Time Warping
library(dplyr)
library(tidyr)
library(ggplot2)
library(gridExtra)
library(animation)
plot_dtw_matrix <- function(ts_a, ts_b, i, j, cost, dist) {
.plot_matrix <- function(m, title, low, high) {
d <- dplyr::tbl_df(data.frame(m))
@JonyEpsilon
JonyEpsilon / parser.clj
Last active November 13, 2015 02:58
Using the Stanford NLP LexicalizedParser in clojure
;; gorilla-repl.fileformat = 1
;; **
;;; # Loading a lexparser
;; **
;; @@
(ns fuscia-sunset
(:import (edu.stanford.nlp.parser.lexparser LexicalizedParser Options)))
;; @@
@yoheia
yoheia / perl_oneliner_example
Last active January 24, 2020 18:12
Perlワンライナー&マルチライナー集
Perl ワンライナーサンプル集
■概要
障害解析のためのログの調査、非互換対応でのソースコードの調査といった
テキスト処理で使った Perl ワンライナーのサンプル集です。
Perl ワンライナーは以下の点が良いと思います。
・Perl は Oracle Database (10g以降) に同梱されている。
 従って、Windows プラットフォームでも使える。
@neubig
neubig / crf.py
Created November 7, 2013 10:59
This is a script to train conditional random fields. It is written to minimize the number of lines of code, with no regard for efficiency.
#!/usr/bin/python
# crf.py (by Graham Neubig)
# This script trains conditional random fields (CRFs)
# stdin: A corpus of WORD_POS WORD_POS WORD_POS sentences
# stdout: Feature vectors for emission and transition properties
from collections import defaultdict
from math import log, exp
import sys
@syou6162
syou6162 / README.md
Last active October 19, 2017 01:58
Clojure performance tips

メモリ

個人的にはコレクションと配列との使用メモリ量比較が参考になりました.1M 個の long を格納するとして,vector だと 30MB, vector-of だと 9MB, 配列だと 8MB というのは覚えておいて損は無さそうです.案外 vector はメモリを食いません.

メモリ消費量を測定する用のマクロ

(defn current-total-memory-usage []
@acardona
acardona / parse-bibtex-with-monads.clj
Created September 8, 2012 09:13
A parser for a subset of BibTeX files, written with clojure monads
; Albert Cardona, 2012-09-08
; http://albert.rierol.net/clojure-monads.html
(ns my.parse.bib5
(:use [clojure.algo.monads :only [domonad with-monad state-t maybe-m fetch-state set-state m-seq m-plus m-result]])
(:use [clojure.string :only [lower-case]])
(:use [clojure.pprint :only [pprint]]))
(set! *warn-on-reflection* true)
@syou6162
syou6162 / clj-seq-utils.md
Created September 6, 2012 00:24
Clojureのsequence関係のユーティリティ関数のまとめ

sequence関係のユーティリティ関数で自分がよく知らないものをまとめておく。

map-indexed

昔はindexedっていうそのまんまな関数があったけど、1.3くらいからなくなっていた。今はmap-indexedっていう関数を使う。よく使うのはこんな感じの使い方。

(map-indexed #(vector %1 %2) ["a" "b" "c" "d" "e"])
; ([0 "a"] [1 "b"] [2 "c"] [3 "d"] [4 "e"])

reductions