Skip to content

Instantly share code, notes, and snippets.

View fufufukakaka's full-sized avatar
:shipit:

Yusuke Fukasawa fufufukakaka

:shipit:
View GitHub Profile
@altescy
altescy / progress.py
Last active May 29, 2023 04:00
Show iteration progress with estimated running time.
from __future__ import annotations
import functools
import os
import re
import sys
import time
from collections.abc import Sized
from typing import Any, Callable, ClassVar, Generic, Iterable, Iterator, TextIO, TypeVar, cast
@t8da
t8da / count_encoder.py
Last active September 6, 2018 07:21
Count Encoder
import pandas as pd
import numpy as np
from itertools import combinations
import multiprocessing as mp
from sklearn.base import BaseEstimator, TransformerMixin
def _hashed_rows(x):
y = np.zeros(x.shape[0])
v = x.values # to avoid __getattr__
for i in range(x.shape[0]):
@jeremyjordan
jeremyjordan / sgdr.py
Last active December 4, 2023 13:41
Keras Callback for implementing Stochastic Gradient Descent with Restarts
from keras.callbacks import Callback
import keras.backend as K
import numpy as np
class SGDRScheduler(Callback):
'''Cosine annealing learning rate scheduler with periodic restarts.
# Usage
```python
schedule = SGDRScheduler(min_lr=1e-5,
@9bic
9bic / cloud-config.yaml
Created January 6, 2018 17:22
gcloud and gsutil for Google Container Optimized OS
#cloud-config
users:
- name: cloudservice
groups: docker
uid: 2000
write_files:
- path: /home/cloudservice/currentdir/gcloud-sdk-setup
permissions: '0644'
from gensim.models import KeyedVectors
# Load gensim word2vec
w2v_path = '<Gensim File Path>'
w2v = KeyedVectors.load_word2vec_format(w2v_path)
import io
# Vector file, `\t` seperated the vectors and `\n` seperate the words
"""