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

[OSCP]使用SPU实现分位数回归算法 #794

Closed
wants to merge 0 commits into from

Conversation

xbw886
Copy link
Contributor

@xbw886 xbw886 commented Jul 29, 2024

not fixed : #258

@deadlywing deadlywing self-requested a review July 29, 2024 08:06
Copy link
Contributor

@deadlywing deadlywing left a comment

Choose a reason for hiding this comment

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

几点可以做一下:

  1. merge 一下 main,改动的文件只限制在linear_model里
  2. clean codes,可以借助ide,clean没有使用的代码
  3. status除了成功和失败其他的都不需要维护,可以简化代码逻辑
  4. while loop可以用原生的python语法去写,看上去更简洁(我看condition都是最大迭代次数)

进一步优化建议:
可以考虑用大M法来求初始可行解,sklearn使用的是两阶段法(即代码里phase 1是求初始可行解,phase 2是真正的求解过程),我本地测试了一下如果不做phase 1,性能可以提升1倍以上,感觉也可以考虑。

sml/linear_model/quantile.py Outdated Show resolved Hide resolved
sml/linear_model/utils/linprog.py Outdated Show resolved Hide resolved
sml/linear_model/utils/linprog.py Outdated Show resolved Hide resolved
sml/linear_model/quantile.py Outdated Show resolved Hide resolved
sml/linear_model/utils/linprog.py Outdated Show resolved Hide resolved
sml/linear_model/utils/linprog.py Outdated Show resolved Hide resolved
sml/linear_model/utils/linprog.py Outdated Show resolved Hide resolved
sml/linear_model/utils/linprog.py Outdated Show resolved Hide resolved
sml/linear_model/utils/linprog.py Outdated Show resolved Hide resolved
)

num, T, basis, pivcol, pivrow, phase, tol, bland, status, complete, nit, maxiter = (
lax.while_loop(
Copy link
Contributor

Choose a reason for hiding this comment

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

即然while loop的执行次数是固定的,就可以直接写成

while nit < 300:
   do_func()

可以简化里面nit的一堆判断之类的。。

@xbw886 xbw886 closed this Sep 23, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

使用SPU实现分位数回归算法
2 participants