Skip to content

Instantly share code, notes, and snippets.


Maxim Grechkin maximsch2

View GitHub Profile
from typing import Tuple, Union, List
import torch
from pytorch_lightning.metrics import Metric
from pytorch_lightning.metrics.utils import METRIC_EPS, to_onehot
# From Lightning's AveragePrecision metric
def _average_precision_compute(
precision: torch.Tensor,
maximsch2 /
Created Feb 26, 2021
Binned Recall@Precision metric
from typing import Tuple
import torch
from pytorch_lightning.metrics import Metric
class BinnedRecallAtFixedPrecision(Metric):
"""Returns a tensor of recalls for a fixed precision threshold.
It is a tensor instead of a single number, because it applies to multi-label inputs.

Keybase proof

I hereby claim:

  • I am maximsch2 on github.
  • I am maximsch2 ( on keybase.
  • I have a public key whose fingerprint is F13E 497C 1056 CEFE 544A CA5F C320 A1D4 ABDC 6271

To claim this, I am signing this object:

maximsch2 / jld_misc.jl
Created Jan 23, 2017
JLD optimizations
View jld_misc.jl
using JLD
type VectorOfVectorsSerializer{T}
VectorOfVectorsSerializer{T}(val::Vector{Vector{T}}) = new(vcat(val...), Int64[length(x) for x in val])
JLD.writeas{T}(data::Vector{Vector{T}}) = VectorOfVectorsSerializer{T}(data)
View GenericAutocomp.elm
module GenericAutocomp exposing (..)
import Autocomplete
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.App as Html
import String
import Json.Decode as Json
import Dom
View Main.elm
import Html exposing (Html, Attribute, div, input, text, button)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, onClick)
import String
import Ports exposing (..)
main =
Html.program { init = init, view = view, update = update, subscriptions = \x -> Sub.none }
maximsch2 / test.jl
Created Sep 4, 2015
Julia 0.4 method dispatch bug?
View test.jl
abstract Abs
type Foo <: Abs
type Bar
type Baz
maximsch2 / picker.jl
Created Sep 2, 2015
String list picker in Escher.jl
View picker.jl
function picker{T}(data::AbstractArray{T,1}, selected = T[])
sinput = Input("")
inp = Input(nokey)
getvals = s -> begin
data = filter(x -> !(x in selected), data)
ldata = map(lowercase, data)
ls = lowercase(s)
maximsch2 /
Created Sep 28, 2012
[BUG] Bug in scikit-learn.linear_model.Lasso in v 0.12
# data is here:
from pylab import *
from sklearn import linear_model
model = linear_model.Lasso(alpha=0.1)
data = loadtxt("data.txt")
X = np.delete(data, 350, 0).T
y = data[350, :].T, y)
print model.coef_ # 1