This file contains hidden or 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
""" | |
Original Author Ernesto P. Adorio, Ph.D | |
Original Source: http://my-other-life-as-programmer.blogspot.com/2012/02/python-finding-nearest-matching-color.html | |
Modifed By: JDiscar | |
This class maps an RGB value to the nearest color name it can find. Code is modified to include | |
ImageMagick names and WebColor names. | |
1. Modify the minimization criterion to use least sum of squares of the differences. | |
2. Provide error checking for input R, G, B values to be within the interval [0, 255]. |
This file contains hidden or 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
import numpy as np | |
# import utils | |
from scipy.special import gammaln, psi | |
# from formatted_logger import formatted_logger | |
eps = 1e-20 | |
# log = formatted_logger('RTM', 'info') | |
class rtm: | |
""" implementation of relational topic model by Chang and Blei (2009) |
This file contains hidden or 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
#! encoding=UTF-8 | |
""" | |
kernel canonical correlation analysis | |
""" | |
import numpy as np | |
from scipy.linalg import svd | |
from sklearn.metrics.pairwise import pairwise_kernels, euclidean_distances | |
class KCCA(object): |
This file contains hidden or 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
#! encoding=UTF-8 | |
""" | |
zikan: a class of measuring elasped time | |
""" | |
from datetime import datetime, timedelta | |
class Zikan(object): | |
""" | |
Zikan class |
This file contains hidden or 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
import re | |
r = re.compile("RT @([0-9a-zA-Z_]{1,15}):(?!.*RT @[0-9a-zA-Z_]{1,15})\s?(.*?)$") | |
text = "RT @aaa: あああ RT @bbb: いいい" | |
s = r.search(text) | |
s.group(0) # マッチした全体(RT @bbb: いいい) | |
s.group(1) # 発信者screen_name(bbb) | |
s.group(2) # 発信情報(いいい) |
This file contains hidden or 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 os | |
import cv2 | |
folderName = '' | |
outputFolder = '' | |
for files in os.listdir(folderName): |
This file contains hidden or 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 os | |
import cv2 | |
row = 1882 #縦 | |
col = 1913 #横 | |
point = [(195, 133), (2073, 133), (3948, 133), | |
(200, 2035), (2072, 2035), (3938, 2035)] # |
This file contains hidden or 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
import numpy as np | |
from scipy.optimize import fmin_bfgs | |
def rosen(x): | |
return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:1])**2.0) | |
def rosen_der(x): | |
xm = x[1:-1] | |
xm_m1 = x[:-2] | |
xm_p1 = x[2:] |