-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can fit return something useful? #52
Comments
I like the concept, but unless I did something wrong here there's a big performance hit for: function fit!(o::OnlineStat, y::Union{AVec, AMat})
for i in 1:size(y, 1)
fit!(o, row(y, i))
end
end I tried adding the following: function fit2!(o::OnlineStat, y::Union{AVec, AMat})
for i in 1:size(y, 1)
fit2!(o, row(y, i))
end
end
fit2!(o::OnlineStat, y::Real) = (fit!(o, y); o) julia> y = randn(10_000_000);
julia> o1 = Variance(); o2 = Variance()'
▌ Variance
▶ value: 0.0
▶ nobs: 0
julia> @time fit!(o1, y)
0.059439 seconds (4 allocations: 160 bytes)
julia> @time OnlineStats.fit2!(o2, y)
0.131593 seconds (10.00 M allocations: 152.588 MB, 7.01% gc time) Before the rewrite, we had |
Something seems weird here. I don't think you can use the same Also, it's really bad to take Finally we need to revisit the idea of row-based vs column-based storage. We should consider a type Thoughts? |
The function fit!(o::OnlineStat, y::AMat)
for i in 1:size(y, 1)
fit!(o, row(y, i))
end
end
function fit!(o::OnlineStat, y::AVec)
for yi in y
fit!(o, yi)
end
end |
I think I understand now. There's a
This should be better. Back to the original point... I'd be really surprised if returning the |
Strange, I just tried it again and saw no time/allocation difference. In that case, I like the idea of returning the object. I'll run through everything and add it. |
|
Cool thanks!
|
If I want to create a trace vector of fitted values, I have to do something like:
But if
fit!
returned theOnlineStat
object then I can do something like:I don't think it should return the value itself, because many times you'll want to do something else with the object.
There is precedence for this sort of thing... for example
push!
will return the object you are pushing to.The text was updated successfully, but these errors were encountered: