-
Notifications
You must be signed in to change notification settings - Fork 6
Cleanup fitmeasures mg #311
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
Open
Maximilian-Stefan-Ernst
wants to merge
10
commits into
devel
Choose a base branch
from
cleanup_fitmeasures_mg
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+108
−59
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
57ec89b
add helper functions for heterogenous lossfuns and scaling corrections
Maximilian-Stefan-Ernst 1db3106
adapt default multigroup weights and give info about defaults used
Maximilian-Stefan-Ernst 8b5de2e
refactor minus2ll
Maximilian-Stefan-Ernst f13704e
refactor minus2ll
Maximilian-Stefan-Ernst 618e2df
refactor chi2
Maximilian-Stefan-Ernst c63ca4c
refactor RMSEA
Maximilian-Stefan-Ernst e8c867b
adapt mg models and fitmeasures
Maximilian-Stefan-Ernst 685a7f7
Apply suggestion from @github-actions[bot]
Maximilian-Stefan-Ernst 441f037
Apply suggestion from @github-actions[bot]
Maximilian-Stefan-Ernst 9c372cc
Apply suggestion from @github-actions[bot]
Maximilian-Stefan-Ernst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -192,10 +192,7 @@ end | |||||||||||
| function SemEnsemble(models...; weights = nothing, groups = nothing, kwargs...) | ||||||||||||
| n = length(models) | ||||||||||||
| # default weights | ||||||||||||
| if isnothing(weights) | ||||||||||||
| nsamples_total = sum(nsamples, models) | ||||||||||||
| weights = [nsamples(model) / nsamples_total for model in models] | ||||||||||||
| end | ||||||||||||
| weights = isnothing(weights) ? multigroup_weights(models, n) : weights | ||||||||||||
| # default group labels | ||||||||||||
| groups = isnothing(groups) ? Symbol.(:g, 1:n) : groups | ||||||||||||
| # check parameters equality | ||||||||||||
|
|
@@ -226,7 +223,25 @@ function SemEnsemble(; specification, data, groups, column = :group, kwargs...) | |||||||||||
| model = Sem(; specification = ram_matrices, data = data_group, kwargs...) | ||||||||||||
| push!(models, model) | ||||||||||||
| end | ||||||||||||
| return SemEnsemble(models...; weights = nothing, groups = groups, kwargs...) | ||||||||||||
| return SemEnsemble(models...; groups = groups, kwargs...) | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| function multigroup_weights(models, n) | ||||||||||||
| nsamples_total = sum(nsamples, models) | ||||||||||||
| uniform_lossfun = check_single_lossfun(models...; throw_error = false) | ||||||||||||
| if !uniform_lossfun | ||||||||||||
| @info "Your ensemble model contains heterogeneous loss functions. | ||||||||||||
| Default weights of (#samples per group/#total samples) will be used". | ||||||||||||
| return [(nsamples(model)) / (nsamples_total) for model in models] | ||||||||||||
|
Comment on lines
+234
to
+235
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||
| end | ||||||||||||
| lossfun = models[1].loss.functions[1] | ||||||||||||
| if !applicable(mg_correction, lossfun) | ||||||||||||
| @info "We don't know how to choose group weights for the specified loss function. | ||||||||||||
| Default weights of (#samples per group/#total samples) will be used". | ||||||||||||
| return [(nsamples(model)) / (nsamples_total) for model in models] | ||||||||||||
|
Comment on lines
+240
to
+241
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||
| end | ||||||||||||
| c = mg_correction(lossfun) | ||||||||||||
| return [(nsamples(model)+c) / (nsamples_total+n*c) for model in models] | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| param_labels(ensemble::SemEnsemble) = ensemble.param_labels | ||||||||||||
|
|
||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶