This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
PDFをマージして見開きにする | |
''' | |
import subprocess | |
import tempfile | |
from pathlib import Path | |
def main(args): | |
with tempfile.TemporaryDirectory() as tmpdir: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ]; then | |
# echo "Usage: [Q=QueueName] [P=NProcs] [T=NThreads] [C=NCpus] [G=NGpus] [M=Memory (GB)] [W=WallTime (hour)] [J=JobName] [O=LogDir] bash $0 [-I|command]" | |
echo "Usage: [Q=QueueName] [ [P=NProcs] [C=NCpus] [M=Memory (GB)] | [G=NGpus] ] [W=WallTime (hour)] [J=JobName] [O=LogDir] bash $0 [-I|command]" | |
exit 1 | |
fi | |
# Set default values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Implement DBSCAN clustering algorithm''' | |
import numpy as np | |
from scipy.spatial import distance | |
from scipy.sparse.csgraph import connected_components | |
def dbscan(X, eps=0.5, minPts=2): | |
X = np.array(X) | |
if X.ndim != 2: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from collections import namedtuple | |
def typednamedtuple(typename, field_names, field_types): | |
'''Typed namedtuple | |
An implementation of typed namedtuple. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
edgelistとlabellistを0始まりのIDに変換する | |
''' | |
import os | |
import sys | |
#from snlocest.largedict import LargeDict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* | |
* 三目並べを作る | |
* */ | |
#define WIDTH 3 | |
#define HEIGHT 3 | |
#define BLANK 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
''' | |
はねろコイキングのとっくんのCPテーブルをダウンロード | |
''' | |
import os | |
import urllib.request | |
import bs4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import random | |
def markov(n, p): | |
state = True | |
for i in range(n): | |
x = random.random() | |
if p > x: | |
state = not state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
Label Propagationを実装した | |
''' | |
import numpy as np | |
import scipy as sp | |
import sklearn.datasets | |
import sklearn.metrics as metrics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
def print_mat(mat): | |
for row in mat: | |
for c in row: | |
print(c, end=", ") | |
print() | |
def gauss_jordan(mat): | |
n = len(mat) |
NewerOlder