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
from __future__ import print_function | |
import random | |
from timeit import timeit | |
from functools import partial | |
import numpy as np | |
from sklearn.preprocessing import LabelEncoder | |
N_TRIALS = 3 | |
N_SAMPLES = 10000 | |
MULTILABEL = True |
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 fractions | |
import numpy as np | |
from sklearn.base import MetaEstimatorMixin, BaseEstimator | |
class DiscretelyWeightedTrainer(BaseEstimator, MetaEstimatorMixin): | |
"""Replicates samples according to `sample_weight` to fit an estimator |
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
from __future__ import print_function | |
import re | |
import sys | |
import six | |
dict_key_re = re.compile(r'''(?x) | |
( # preceding string of '.'-delimited identifiers | |
(?!\d)\w+ | |
(?:\.(?!\d)\w+)* |
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, timeit, sklearn.metrics, sklearn.preprocessing, functools | |
from joblib import Memory | |
N_TRIALS = 50 | |
memory = Memory('/tmp', verbose=0) | |
@memory.cache | |
def gen_mc(s, N=1000000, K=10): | |
return np.random.randint(K, size=N) |
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
from libc.math cimport sqrt | |
cimport cython | |
cimport numpy as np | |
import numpy as np | |
ctypedef fused my_fused_type: | |
cython.short | |
cython.int | |
cython.long | |
cython.float |
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
class _SparseMultiLabelHelper(object): | |
def __init__(self, y_true, y_pred): | |
self.y_true = y_true.tocsr() | |
self.y_pred = y_pred.tocsr() | |
self.shape = y_true.shape | |
def count_union(self, axis=None) | |
return self._count_nnz(self.y_true + self.y_pred, axis) | |
def count_intersection(self, axis=None) |
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
from sklearn.base import BaseEstimator, TransformerMixin | |
class Transformer(BaseEstimator, TransformerMixin): | |
def __init__(self, fn): | |
self.fn = fn | |
def fit(self, X, y): | |
return self | |
def transform(self, X): |
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
from cpython cimport PyObject | |
from libc.string cimport strcmp | |
cdef extern from "Python.h": | |
ctypedef struct PyTypeObject: | |
pass | |
cdef extern from "structmember.h": | |
ctypedef struct PyMemberDef: | |
char *name |
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 py4j.GatewayServer; | |
import java.io.File; | |
import java.net.URL; | |
import org.maltparser.concurrent.ConcurrentMaltParserModel; | |
import org.maltparser.concurrent.ConcurrentMaltParserService; | |
import org.maltparser.concurrent.graph.ConcurrentDependencyGraph; | |
import org.maltparser.concurrent.graph.ConcurrentDependencyNode; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.