Skip to content

Instantly share code, notes, and snippets.

View zaburo-ch's full-sized avatar
💭
😇

Kaizaburo Kido zaburo-ch

💭
😇
View GitHub Profile
@zaburo-ch
zaburo-ch / save_arrayボツ案.py
Created September 26, 2018 05:32
save_arrayボツ案
def save_array(X, filepath):
X = np.asarray(X)
shape_str = str(X.shape)
pd.Series(X.reshape(-1)).to_hdf(filepath, complevel=9, complib='blosc', key=shape_str)
def load_array(filepath):
with pd.io.pytables.HDFStore(filepath, mode='r') as store:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from joblib import Parallel, delayed
from sklearn import model_selection
import lightgbm as lgb
import base
@zaburo-ch
zaburo-ch / base.py
Created August 21, 2018 11:10
Utility module
import tables as tb
import numpy as np
import pandas as pd
import os
import json
import datetime
import pickle
import inspect
import requests
# A list of lists of ordered column groups.
groups_40 = [['f190486d6', '58e2e02e6', 'eeb9cd3aa'...], ...]
total = pd.concat([train, test], sort=False)
X = (total[sum(groups_40, [])].values.copy().reshape(-1, len(groups_40), 40) * 100).astype(np.int64)
next_values = [{} for j in range(40 - 1)]
for i in range(X.shape[0]):
for j in range(40 - 1):
if (X[i, :, j + 1:] != 0).sum() == 0:
@zaburo-ch
zaburo-ch / overflow_detection.cpp
Last active June 6, 2018 10:08
[WIP] C++ int64_t overflow detection
class SafeInt64{
private:
bool overflow = false;
int64_t value = 0;
int64_t safe_add(int64_t b){
int64_t a = value;
int clz_a = __builtin_clzll(a > 0 ? a : -a);
int clz_b = __builtin_clzll(b > 0 ? b : -b);
#!/usr/bin/env python
import argparse
import os
import subprocess
import sys
parser = argparse.ArgumentParser(description='This sctipt quickly run a c++ program.')
parser.add_argument('file_path', help='path to c++ program')
# parser.add_argument('-i', metavar='input_file',
# default=None, help='path to standard input file')
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
int n;
cin >> n;
@zaburo-ch
zaburo-ch / dirty_approach.py
Created November 16, 2017 14:14
kaggle web-traffic-time-series-forecasting の solution
import numpy as np
np.random.seed(1024)
import pandas as pd
import chainer
from chainer import serializers
from chainer.optimizers import Adam
import chainer.functions as F
import chainer.links as L
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
using P = pair<int, int>;
using ll = long long;
struct MazeConstruct {
vector<string> construct(int k) {
if(k+1 <= 50) return vector<string>(1, string(k+1, '.'));
if(k <= 100-2) return vector<string>(50, string(k+1-49, '.'));
#include <bits/stdc++.h>
using namespace std;
struct edge{int pu, pv, move;};
struct MovingTokens {
int move(int n, int m, vector<int> moves) {
vector<edge> rev_edges[50][50];
for(int j=0;j<m;j++){
for(int pu=0;pu<n;pu++){