Giter Site home page Giter Site logo

Comments (9)

joshday avatar joshday commented on June 27, 2024 1

I've become fond of wrapper types since you can compose them. At some point I should change FTSeries to be FilterTransform wrapper type.

How about something like this that tracks the CountMap of exceptions you run into?

struct TryCatchStat{T, O<:OnlineStat{T}} <: OnlineStat{T}
    stat::O
    exceptions::CountMap{Exception}
end
TryCatchStat(stat::OnlineStat) = TryCatchStat(stat, CountMap(Exception))

nobs(o::TryCatchStat) = nobs(o.stat)

value(o::TryCatchStat) = value(o.stat)

function _fit!(o::TryCatchStat, y)
    try
        _fit!(o.stat, y)
    catch ex
        _fit!(o.exceptions, ex)
    end
end

from onlinestatsbase.jl.

joshday avatar joshday commented on June 27, 2024 1

Doing a little bit of work on this and I'm liking how it's turning out:

julia> o = TryCatch(FilterTransform(Mean(), String; transform = x -> parse(Int, x)))
TryCatch(FilterTransform(Mean)): n=0 | value=0.0

julia> fit!(o, "1")
TryCatch(FilterTransform(Mean)): n=1 | value=1.0

julia> fit!(o, "1.5")
TryCatch(FilterTransform(Mean)): n=1 | errors=1 | value=1.0

julia> OnlineStatsBase.errors(o)
OrderedCollections.OrderedDict{DataType, Int64} with 1 entry:
  ArgumentError => 1

from onlinestatsbase.jl.

joshday avatar joshday commented on June 27, 2024 1

Awesome, thanks for your input! I've incorporated most of your suggestions.

The only thing I left out was using Groupby to organize error messages by Exception for TryCatch. I tried it out and the code started looking a little too gnarly for the added benefit.

from onlinestatsbase.jl.

brucala avatar brucala commented on June 27, 2024

oh, I think that's really smart!

With that proposal one would't just be keeping track of failed transformations like in my proposal, but also of any other possible exceptions. Following the FTSeries example, these extra exceptions could be for instance errors in the filter function call, cases where the type of the transformed input does't correspond to the expected type, ....

And I agree, moving from FTSeries to a FilterTransform wrapper makes a lot of sense.

from onlinestatsbase.jl.

brucala avatar brucala commented on June 27, 2024

I had a quick look at the new commit and it looks awesome 🎉

Few comments came to mind, I'll leave few suggestions (even though the code is already merged) if I find some time later today.

from onlinestatsbase.jl.

joshday avatar joshday commented on June 27, 2024

Please do. I haven't tagged a new release yet.

from onlinestatsbase.jl.

brucala avatar brucala commented on June 27, 2024

Left few suggestions. Things are already looking great, so feel free to ignore them

from onlinestatsbase.jl.

brucala avatar brucala commented on June 27, 2024

awesome! Makes sense to leave out the GroupBy suggestion... i liked the idea but it was a bit convoluted.

Did you push the changes?

from onlinestatsbase.jl.

joshday avatar joshday commented on June 27, 2024

Oops, they're pushed now

from onlinestatsbase.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.