Skip to content

Instantly share code, notes, and snippets.

View orico's full-sized avatar

Ori Cohen orico

View GitHub Profile
@ogrisel
ogrisel / learning_curves.png
Created December 30, 2011 16:04
Learning Curves for under/overfitting evaluation
learning_curves.png
@mblondel
mblondel / letor_metrics.py
Last active April 24, 2024 19:43
Learning to rank metrics.
# (C) Mathieu Blondel, November 2013
# License: BSD 3 clause
import numpy as np
def ranking_precision_score(y_true, y_score, k=10):
"""Precision at rank k
Parameters
@skylander86
skylander86 / fleiss kappa.py
Created April 7, 2016 02:08
Compute Fleiss' kappa using numpy.
def fleiss_kappa(M):
"""
See `Fleiss' Kappa <https://en.wikipedia.org/wiki/Fleiss%27_kappa>`_.
:param M: a matrix of shape (:attr:`N`, :attr:`k`) where `N` is the number of subjects and `k` is the number of categories into which assignments are made. `M[i, j]` represent the number of raters who assigned the `i`th subject to the `j`th category.
:type M: numpy matrix
"""
N, k = M.shape # N is # of items, k is # of categories
n_annotators = float(np.sum(M[0, :])) # # of annotators
@udibr
udibr / gruln.py
Last active November 7, 2020 02:34
Keras GRU with Layer Normalization
import numpy as np
from keras.layers import GRU, initializations, K
from collections import OrderedDict
class GRULN(GRU):
'''Gated Recurrent Unit with Layer Normalization
Current impelemtation only works with consume_less = 'gpu' which is already
set.
# Arguments
@chelsea1992
chelsea1992 / gist:6c725a24d358763097bebe8223c2014a
Created April 15, 2017 07:11
Community Detection, Girvan-Newman algorithm
import networkx as nx
import sys
from collections import deque
import community as cm
from collections import defaultdict
import matplotlib.pyplot as plt
# calculate the betweeness
def cal_betweeness(graph):