Skip to content
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

Improve criteria performance #66

Merged
merged 23 commits into from
Apr 30, 2024
Merged

Improve criteria performance #66

merged 23 commits into from
Apr 30, 2024

Conversation

alyst
Copy link
Contributor

@alyst alyst commented Apr 25, 2024

Another pass on optimizing criterion performance:

  • replace Ones() * M and similar constructs with sum(M, dims=...) -- it should be faster
  • replace tr(A' * B) with dot(A, B) where possible -- should be much faster
  • more uses of ∇Q (if available) as a temporary matrix for intermediate operations to reduce memory footprint
  • simplify and unify the criterion code for CF and Oblimin (now it is more apparent that it's a weighted sum of column and row sums)
  • add Equamax and Parsimax on top of the generalized CF/Oblimin criterion code
  • TargetRotation: skip weighting if all target matrix elements are specified

@alyst alyst changed the title Improve criterions Improve criteria performance Apr 26, 2024
@p-gw
Copy link
Owner

p-gw commented Apr 26, 2024

I've added a github action with benchmarks for criterion_and_gradient! in #67. I think they should run if you rebase on main.

@alyst alyst force-pushed the improve_criterion branch from 0c4a1ca to b0bd692 Compare April 26, 2024 15:45
Copy link
Contributor

github-actions bot commented Apr 26, 2024

Benchmark Results

main 00ae4f0... main/00ae4f044f7dac...
criterion_and_gradient!/FactorRotations.Biquartimin{FactorRotations.Oblique}() 0.572 ± 0.027 μs 0.565 ± 0.3 μs 1.01
criterion_and_gradient!/FactorRotations.CrawfordFerguson{FactorRotations.Oblique, Float64}(0.5) 1.22 ± 0.03 μs 0.396 ± 0.0081 μs 3.09
criterion_and_gradient!/FactorRotations.Geomin{Float64}(0.01) 1.27 ± 4.6 μs 0.932 ± 0.17 μs 1.37
criterion_and_gradient!/FactorRotations.Infomax{FactorRotations.Oblique}() 2.82 ± 2.1 μs 1.39 ± 0.51 μs 2.03
criterion_and_gradient!/FactorRotations.MinimumEntropy() 0.473 ± 0.027 μs 0.457 ± 0.17 μs 1.04
criterion_and_gradient!/FactorRotations.MinimumEntropyRatio() 15.7 μs 16 μs 0.98
criterion_and_gradient!/FactorRotations.Oblimax{FactorRotations.Oblique}() 0.314 ± 0.001 μs 0.315 ± 0.001 μs 0.997
criterion_and_gradient!/FactorRotations.Oblimin{FactorRotations.Oblique, Float64}(0.5) 1.68 ± 0.31 μs 0.389 ± 0.008 μs 4.31
criterion_and_gradient!/FactorRotations.Oblimin{FactorRotations.Orthogonal, Float64}(0.5) 1.66 ± 0.9 μs 0.393 ± 0.0081 μs 4.23
criterion_and_gradient!/FactorRotations.Quartimax() 0.218 ± 0.001 μs 0.217 ± 0.001 μs 1
criterion_and_gradient!/FactorRotations.Simplimax(5) 0.786 ± 0.036 μs 0.595 ± 0.029 μs 1.32
criterion_and_gradient!/FactorRotations.TandemCriterionI() 3.45 ± 1.9 μs 3.14 ± 1.7 μs 1.1
criterion_and_gradient!/FactorRotations.TandemCriterionII() 2.05 ± 0.15 μs 1.58 ± 0.052 μs 1.29
criterion_and_gradient!/FactorRotations.Varimax() 0.156 ± 0.0001 μs 0.155 ± 0.001 μs 1.01
time_to_load 0.54 ± 0.0085 s 0.527 ± 0.0062 s 1.03

Copy link
Owner

@p-gw p-gw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks very good. We can merge this after the minor changes I proposed.

Also, can you add Parsimax and Equamax to the rotation_methods docs for completeness?

closes #27; closes #28

This was linked to issues Apr 29, 2024
@alyst alyst force-pushed the improve_criterion branch from 42c91a8 to 00ae4f0 Compare April 30, 2024 06:01
@alyst
Copy link
Contributor Author

alyst commented Apr 30, 2024

@p-gw Thank you for the review. I've addressed your comments + tweaked the infomax and biquartimin.

Copy link
Owner

@p-gw p-gw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, very nice PR!

@p-gw p-gw merged commit c333da6 into p-gw:main Apr 30, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Parsimax Implement Equamax
2 participants