Building complex TemplateExpression structures #767
Replies: 1 comment 14 replies
-
I think you are almost there! The next thing would be to unpack the ValidVector with Maybe this would work? structure = TemplateStructure{(:f, :c)}(
((; f, c), (x1, x2, x3, x4, x5, x6, y, category)) -> begin
transformed_x1 = c(x1, x3, x4)
o = f(transformed_x1, x2, x3, x4, x5, x6)
residuals = y - o # Changed
unique_category = unique(category.x) # Changed
_mean(_x) = sum(_x) / length(_x) # Just in case it doesn't exist
mean_residuals_by_category = Dict(
group => _mean(residuals.x[category.x .== group]) # Changed
for group in unique_category
)
offsets = [mean_residuals_by_category[category[i]] for i in eachindex(o.x)] # Changed
return ValidVector(o.x .- offsets, o.valid && residuals.valid)
end
) Basically each The When you evaluate an expression like Changes:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Copying @gm89uk from #756 for visibility in case others are wanting to learn more about the internals of TemplateExpressions –
Beta Was this translation helpful? Give feedback.
All reactions