Skip to content

Instantly share code, notes, and snippets.

Avatar

Maxim Grechkin maximsch2

View GitHub Profile
View binned_precision_recall_curve.py
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
maximsch2 / binned_pr_metric.py
Created Feb 26, 2021
Binned Recall@Precision metric
View binned_pr_metric.py
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.
"""
View keybase.md

Keybase proof

I hereby claim:

  • I am maximsch2 on github.
  • I am maximsch2 (https://keybase.io/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
maximsch2 / jld_misc.jl
Created Jan 23, 2017
JLD optimizations
View jld_misc.jl
using JLD
type VectorOfVectorsSerializer{T}
data::Vector{T}
lengths::Vector{Int64}
VectorOfVectorsSerializer{T}(val::Vector{Vector{T}}) = new(vcat(val...), Int64[length(x) for x in val])
end
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
maximsch2 / test.jl
Created Sep 4, 2015
Julia 0.4 method dispatch bug?
View test.jl
abstract Abs
type Foo <: Abs
end
type Bar
val::Int64
end
type Baz
@maximsch2
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
maximsch2 / test.py
Created Sep 28, 2012
[BUG] Bug in scikit-learn.linear_model.Lasso in v 0.12
View test.py
# data is here: http://dl.dropbox.com/u/226605/data.txt.bz2
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
model.fit(X, y)
print model.coef_ # 1