Skip to content

Instantly share code, notes, and snippets.

View yatakeke's full-sized avatar

Yatakeke a.k.a Agile Zamurai yatakeke

View GitHub Profile
a = np.zeros([2,2])
a[(0, 1),(0, 1)] = 1
print(a)
return
====>>>> array([1, 0],
[0, 1])
a = list(range(10))
print("before : ", a)
b = np.random.permutation(a)
print("after : ", b)
====>>>>
before : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
after : [9 7 4 0 8 3 2 6 5 1]
@yatakeke
yatakeke / step_function.py
Last active February 18, 2019 01:53
this is the code for step function in Python
def step_function(x):
return np.where(x >= 0, 1, 0)
### It is equivalent to below code to give 1-D array to np.where.
### variables = np.where(condition, val1, val2) <=> variables = val1 if x >= 0 else val2
def step_function(x:list):
return np.maximum(x, 0)
from glob import glob
from os import path
def listup_file_name(data_path, extension=None, abspath=True):
extension = '.' + extension if extension else ''
if abspath:
return glob(data_path + '*' + extension)
else:
return glob(path.relpath(data_path + '*' + extension))
@yatakeke
yatakeke / createAndBuildAppInHeroku.php
Last active February 18, 2019 01:56
methods to create and build app in heroku
<?php
public function createapp($email, $password){
$url = "https://api.heroku.com/apps";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, $email.":".$password);
$headers = ['Accept: application/vnd.heroku+json; version=3',"Content-Type: application/json"];
import MeCab
def tokenization(text, dic_path, lex = None):
# -Oyomi (ヨミ付与) -Ochasen (ChaSen互換) -Odump (全情報を出力)
unknown_option = "-U %M\\t未知語,*,*,*,*,*,*,*,*\\n"
mecab_options = " ".join(["-d", dic_path, unknown_option])
tagger = MeCab.Tagger(mecab_options)
parse = tagger.parse(text).replace('\t',',')