diff --git a/README.md b/README.md index dddc0ad..326a68e 100644 --- a/README.md +++ b/README.md @@ -8,25 +8,21 @@ Hopefully, you can get the predicted result within **15-30 minutes** after the c ## Features * ⚡️ Fast - * The core Elo rating algorithm is significantly enhanced by a **Just-In-Time (JIT) compiler** through [Numba](https://numba.pydata.org), reducing execution time to approximately 20 seconds on a dual-core *Intel(R) Xeon(R) Platinum 8255C CPU* (@ 2.50GHz). - * In addition to the JIT implementation, this project incorporates a [Fast Fourier Transform (FFT) implementation](https://github.com/baoliay2008/lccn_predictor/pull/43). The Elo rating system employed by LeetCode benefits significantly from the FFT algorithm, achieving speedups ranging from **65 to 1,000 times** for individual contest predictions. The most efficient FFT implementation (`EXPAND_SIZE=1`) completes predictions in under **0.25 seconds**, maintaining an impressively low Mean Squared Error (MSE) of approximately 0.027. + * The core Elo rating algorithm is significantly enhanced by a **JIT compiler** through [Numba](https://numba.pydata.org), reducing execution time to approximately 20 seconds on a dual-core *Intel(R) Xeon(R) Platinum 8255C CPU* (@ 2.50GHz). + * In addition to the JIT implementation, this project incorporates a **FFT implementation**. The Elo rating system employed by LeetCode benefits significantly from the FFT algorithm, achieving speedups ranging from **65 to 1,000 times** for individual contest predictions. The most efficient FFT implementation (`EXPAND_SIZE=1`) completes predictions in under **0.25 seconds**, maintaining an impressively low MSE of approximately 0.027. * **Caching** the user's latest rating before initiating the prediction process leads to a substantial reduction in the time required for data retrieval. + * Fully **asynchronous**, using non-blocking libraries. * 🎯 Accurate - * If there were no significant rejudges (assuming everyone's global ranking remains unchanged), it is ensured that the prediction error for rating deltas for **EACH** participant is within the precision limit of 0.05. As a result, the rating difference should be negligible. + * If there were no significant rejudges (assuming everyone's global ranking remains unchanged), it is **ensured** that the prediction error for rating deltas for **EACH** participant is within the precision limit of 0.05. As a result, the rating difference should be negligible. * Please note that a normal case is that there would be some misconduct detection, so your global ranking will be slightly higher even if your submissions are not rejudged, which results in a slightly higher rating :) * 📱 Responsive web page * Tested on phones and tablets. -## More Information - -* [🔗 refined-leetcode](https://github.com/XYShaoKang/refined-leetcode): A Chrome extension for leetcode.cn, created by [@XYShaoKang](https://github.com/XYShaoKang) - # Underlying Mechanism ## Algorithm * [🔗 English official illustration on leetcode.com](https://leetcode.com/discuss/general-discussion/468851/New-Contest-Rating-Algorithm-(Coming-Soon)) -* [🔗 Chinese official illustration on leetcode.cn](https://leetcode.cn/circle/article/neTUV4/) * 🔗 Detailed post about FFT acceleration - ❤️ Special thanks to [@tiger2005](https://github.com/tiger2005) for proposing this idea in [issue #8](https://github.com/baoliay2008/lccn_predictor/issues/8) @@ -37,7 +33,6 @@ Hopefully, you can get the predicted result within **15-30 minutes** after the c ## Backend -* [APScheduler](https://apscheduler.readthedocs.io/en/3.x/): background tasks * [Numpy](https://numpy.org/) and [Numba](https://numba.pydata.org/): core prediction algorithm implementation and acceleration * [FastAPI](https://fastapi.tiangolo.com/): restful API * 🚮 ~~[Jinja](https://jinja.palletsprojects.com/): HTML templates for server-side rendering~~ @@ -83,13 +78,13 @@ cp config.yaml.template config.yaml vi config.yaml # build docker image -docker image build -t lccn_predictor:0.1.2 . +docker image build -t lccn_predictor:0.2.4 . # create docker volume docker volume create lccn_predictor # run container -docker run -d -v lccn_predictor:/lccn_predictor -p 55555:55555 --name lp lccn_predictor:0.1.2 +docker run -d -v lccn_predictor:/lccn_predictor -p 55555:55555 --name lp lccn_predictor:0.2.4 docker exec -it lp bash @@ -120,6 +115,10 @@ npm run build ``` +## More Information + +* [🔗 refined-leetcode](https://github.com/XYShaoKang/refined-leetcode): A Chrome extension for leetcode.cn, created by [@XYShaoKang](https://github.com/XYShaoKang) + # License @@ -137,6 +136,14 @@ npm run build > refine backend logic to enhance robustness and clean up deprecated static site rendering code * v0.1.3(2023/12/28) > last version prior to the rewrite of the Elo rating algorithm +* v0.2.1(2023/12/29) + > add FFT implementation +* v0.2.2(2024/01/12) + > refactor to improve backend code clarity +* v0.2.3(2024/08/31) + > add visualization for the number of contest entrants +* v0.2.4(2024/09/16) + > improvement(frontend): add pageNum URL parameter --- # Supported by diff --git a/app/core/fft.py b/app/core/fft.py index c824a41..bbb78b3 100644 --- a/app/core/fft.py +++ b/app/core/fft.py @@ -1,10 +1,12 @@ +from typing import Final + import numpy as np from scipy.signal import fftconvolve from app.core.elo import delta_coefficients -EXPAND_SIZE = 100 -MAX_RATING = 4000 * EXPAND_SIZE +EXPAND_SIZE: Final[int] = 100 +MAX_RATING: Final[int] = 4000 * EXPAND_SIZE def pre_calc_convolution(old_rating: np.ndarray) -> np.ndarray: diff --git a/client/src/components/Footer.jsx b/client/src/components/Footer.jsx index a812320..75812bb 100644 --- a/client/src/components/Footer.jsx +++ b/client/src/components/Footer.jsx @@ -18,7 +18,7 @@ const Footer = () => {

LeetCode weekly and biweekly contest rating predictor.

- Copyright 2022-2024   + Copyright 2022-2025   L. Bao.