Comments (5)
I see that CountMap
has this implemented with the fit!(o, y=>n)
notation. Is it reasonable to expand this to all stats?
from onlinestats.jl.
It's a reasonable request for fit!(::OnlineStat{T}, x::Pair{T, Int})
methods. I'd be okay with a fallback method and specific types can implement their own methods as needed.
from onlinestats.jl.
I'm looking through OnlineStatsBase
to get an understanding of what I would need to change to get this working. It looks like for OnlineStat{T}
, T
is the type of observation that the stat can work on. So for CountMap
, it is defined as
CountMap{T, A <: AbstractDict{T, Int}} <: OnlineStat{Union{T, Pair{<:T,<:Integer}}}
which means it can accept a T
, or a Pair{T, Int}
. Is it really necessary for Pair{T,Int}
to be part of the type? I can go two ways with a PR:
- Add
Pair{T,Int}
to all stats and implement_fit!(o, xy::Pair)
for each stat - Define
fit!(o::OnlineStat{T}, xy::Pair{<:T, <Integer})
and the fallback method_fit!(o::OnlineStat{T}, xy::Pair{<:T, <Integer})
which can be specialized for certain stats (e.g.Hist
)
I'm inclined towards option 2 as then there is no ambiguity of if a stat can fit a pair-type observation. Generally the new code would be
fit!(o::OnlineStat{T}, xy::Pair{<:T, <:Integer}) where {T} = (_fit!(o, xy); return o)
function _fit!(o::OnlineStat{T}, xy::Pair{<:T, <:Integer}) where {T}
x, y = xy
for _ in 1:y
_fit!(o, x)
end
return o
end
I think CountMap could either keep or drop the Pair{<:T,<:Integer}
in the union type. I think it would be cleaner to drop it, but I'm not sure if that counts as a breaking change.
from onlinestats.jl.
Is it really necessary for Pair{T,Int} to be part of the type?
So now I'm remembering why I haven't done this...
fit!(o::OnlineStat{T}, x::S)
will iterate through x
and fit!
each element, so adding pair methods is a breaking change, e.g. fit!(Mean(), 1 => 5)
would work differently. Previously this would result in value=3 and nobs=2. Adding this new method would result in value=1 and nobs=5.
I think we need a new function to indicate counts, fitn!
or similar.
In retrospect, building fit!
around iteration was a mistake. OnlineStats 2.0 should have a push!
/append!
-like approach to make things more explicit.
from onlinestats.jl.
fit!(Mean(), 1 => 5)
feels more like a bug than anything. Instead of introducing fitn!
, why not dispatch on fit!(o, x, k)
? That shouldn't be breaking and is easy to fall back on.
from onlinestats.jl.
Related Issues (20)
- Group with 3 Stats not working for multi-observations? HOT 3
- Julia VS Code extension reports "Possible method call error" for `fit!` HOT 3
- _fit! on AutoCov is not type stable HOT 1
- Extract field of an observation before feeding an OnlineStats - ValueExtractor wrapper HOT 2
- Feature Request: OnlineStat Chaining HOT 1
- Using StatLag without depending on OnlineStats (just OnlineStatsBase) HOT 4
- ExtremeValues doesn't work HOT 2
- Odd interaction of `Group` with broadcast HOT 2
- [speculative] `NullStat` HOT 1
- Plot of GroupBy of HeatMap fails HOT 1
- when fit!-ing a Group to a NamedTuple, the names are ignored HOT 2
- Documentation Request: List which Monoids support merge HOT 1
- Feature Request: PCA wrapper around CovMatrix which also supports transform methods
- Pretty printing is unpretty inside DataFrame HOT 5
- Support `keys` and `values` on `GroupBy` HOT 1
- Bug: Y-Marginals for heatmap are wrong HOT 1
- Suggestions for OnlineStats v2 HOT 1
- Standard Deviation - StdDev HOT 1
- Integrate `StreamSampling` in `OnlineStats` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onlinestats.jl.