Skip to content

Instantly share code, notes, and snippets.

Avatar

Masayuki Isobe chiral

  • Adfive, Inc.
  • Taito-ku, Tokyo, Japan.
View GitHub Profile
@chiral
chiral / adult.R
Created Jun 5, 2017
comparison between LogisticRegression and RandomForest with "Census Income" dataset. please refer to http://archive.ics.uci.edu/ml/datasets/Adult
View adult.R
library(randomForest)
library(ROCR)
init <- function() {
df1 <- read.csv("adult.data",header=F)
df2 <- read.csv("adult.test",header=F)
df2$V15 <- gsub("\\.$","",df2$V15)
df <- rbind(df1,df2)
@chiral
chiral / mycmp.py
Last active Jan 30, 2017
custom comparison function generator for sorted in Python
View mycmp.py
import numpy as np
from random import random
def cmp0(d):
def cmp(a,b):
return int(a[d]-b[d])
return cmp
def cmp1(dd):
def cmp(a,b):
@chiral
chiral / show_jsons.py
Last active Jul 23, 2016
json viewer which can show unicode and top level array
View show_jsons.py
# redirect to stdin to use
# % python show_jsons.py < hoge.json
import sys
import json
import pprint
lines = sys.stdin.readlines()
data = json.loads(''.join(lines),'utf8')
p = sys.stdout.write
@chiral
chiral / jupyter_client_sample.py
Created Apr 11, 2016
sample code for jupyter_client
View jupyter_client_sample.py
from subprocess import PIPE
from jupyter_client import KernelManager
import time
try:
from queue import Empty # Py 3
except ImportError:
from Queue import Empty # Py 2
km = KernelManager(kernel_name='ir')
km.start_kernel()
@chiral
chiral / common.h
Created Apr 10, 2016
code example of AIBOX DroneBrain
View common.h
#ifndef SLAM_COMMON_H
#define SLAM_COMMON_H
#include <opencv2/opencv.hpp>
#include <vector>
using namespace cv;
#define FOCAL_LENGTH 374.6706070969281
@chiral
chiral / decompose_fmatrix.cpp
Last active Feb 1, 2016
convert from fundamental matrix to camera pose (R1, R2, T) in OpenCV2 (similar to decomposeEssentialMat() in OpenCV 3)
View decompose_fmatrix.cpp
/*
you can use the result matrix (rot1,rot2,tvec) as:
candidate1: rot1, tvec
candidate2: rot1, -tvec
candidate3: rot2, tvec
candidate4: rot2, -tvec
*/
bool convertF2RT(Mat &F,Mat &K,Mat &rot1,Mat &rot2,Mat &tvec) {
if (F.empty() || K.empty()) return false;
@chiral
chiral / xgbdump_formatter.py
Created Dec 18, 2015
pretty print for xgboost gbtree booster dump
View xgbdump_formatter.py
import sys
import re
import unicodedata
depth={}
yn={}
f1=None
f=open(sys.argv[1])
@chiral
chiral / trivial_opt_ceres.cpp
Created Dec 2, 2015
example of trivial optimization problem on 2-d circle for the purpose of comparison between ceres-solver and TensorFlow
View trivial_opt_ceres.cpp
#include "ceres/ceres.h"
#include "glog/logging.h"
using ceres::CostFunction;
using ceres::AutoDiffCostFunction;
using ceres::Problem;
using ceres::Solver;
using ceres::Solve;
struct CostFunctor {
@chiral
chiral / example.py
Last active May 4, 2016
RDF generation helper built on rdflib
View example.py
from rdfhelper import *
AD5 = 'http://adfive.net/o/v1#'
def make_recipe1():
g = GraphEx(AD5)
b = g.BNodeEx()
b.load_csv.a(g.LoadCSV).source(
b.in_file.a(g.DataSource)
).destination(
@chiral
chiral / iris.lua
Created Oct 1, 2015
3 layer perceptron for iris data by torch7. iris.csv can be obtained from https://gist.github.com/chiral/5b3609e884e3af8b412a
View iris.lua
-- loarocks install csv
csv = require "csv"
nn = require "nn"
-- prepare data set
dataset={}
size=0
ans={setosa=1,versicolor=2,virginica=3}
You can’t perform that action at this time.