Skip to content

Instantly share code, notes, and snippets.

X = \left[
\begin{array}{rrr}
x_{01} &...& x_{0k} & ... & x_{0K} \\
... \\
x_{t1} &...& x_{tk} & ... & x_{tK} \\
... \\
x_{T1} &...& x_{Tk} & ... & x_{TK}
\end{array}
\right]
@yatszhash
yatszhash / tips_to_save_memory_for_kernel_competitions.ipynb
Last active June 18, 2020 06:34
tips to manage or save the memory usage for kernel competitions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yatszhash
yatszhash / 2nd_omalley_model.png
Last active January 27, 2018 10:32
implementation for kaggle tensorflow speech recognition challenge, O'Malley's model
2nd_omalley_model.png
@yatszhash
yatszhash / LICENSE
Created January 27, 2018 09:16
LICENSE for my gists
MIT License
Copyright (c) 2018 yatszhash
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@yatszhash
yatszhash / reflection_samples.java
Created November 7, 2017 03:17
java reflection sample
public static void setPrivateField(Object targetObj, String fieldName, Object value)
throws NoSuchFieldException, IllegalAccessException
{
Class c = targetObj.getClass();
Field field = c.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(targetObj, value);
}
public static Object invokePrivateMethod(Object targetObj, String methodName,
@yatszhash
yatszhash / CheckValueTypeMatchers.py
Created October 18, 2017 02:42
check the type (i.e. Phone Number) of words in the list. Check the proportion is larger than given threshold.
import re
import numpy as np
class BaseMatcher(object):
def __init__(self, pattern, threshold):
self.pattern = pattern
self.compiled_pattern = re.compile(pattern=self.pattern)
self.threshold = threshold
def match(self, X):
@yatszhash
yatszhash / JpTopicModelVectorizer.py
Created October 18, 2017 02:16
japanese vectorizer on gensim's topic model for scikit-learn pipeline
from sklearn.base import BaseEstimator
import numpy as np
import gensim
from itertools import chain
import MeCab
class TopicModelVectorizer(BaseEstimator):
tagger = MeCab.Tagger("-Owakati")
def __init__(self, topic_type, dic_file_name=None, model_file_name=None):
self.topic_model = None
@yatszhash
yatszhash / JpTfidfVectorizer.py
Created October 18, 2017 02:13
Japanese TF-IDF vectorizer for scikit-learn pipline
# coding: utf-8
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
from sklearn.base import BaseEstimator
import MeCab
import numpy as np
from itertools import chain
class JpTfidfVectorizer(TfidfVectorizer):
tagger = MeCab.Tagger("-Owakati")