A tiny LeetCode-style practice site for data science fundamentals: Python basics, Linear Regression, Logistic Regression, and PCA — all implemented from scratch with numpy (no scikit-learn).
pip install -r requirements.txt
streamlit run app.pyThen open the URL Streamlit prints (usually http://localhost:8501).
problems/— each file defines one or moreProblems: a title, markdown description, starter code, and a list ofTestCases that check the learner's implementation (numeric tolerance checks, shape checks, accuracy thresholds, etc.), plus a spoiler reference solution.executor.py— the "backend". Takes the code you typed in the editor,execs it in a namespace with a reduced builtins set + numpy available, under a 10s timeout, then runs each test case against that namespace and reports pass/fail with a message.app.py— the Streamlit frontend: sidebar problem list with solved progress, a description pane, a code editor (st.text_area), and a "Run tests" button that calls the executor and renders results.
- Add a new function/
Problem(...)to an existing file inproblems/(or create a new module) and wrap it inregister(...). - Import that module from
problems/__init__.pyif it's a new file. - Write
TestCases — eachrunner(namespace) -> (bool, message)receives the learner's exec'd globals dict, so pull functions out of it by name (e.g.ns["two_sum"]) and check behavior/tolerances rather than exact output for anything numeric/randomized.
The executor's sandboxing (restricted builtins + thread timeout) is meant for a personal/trusted-user practice tool run locally — it is not a hardened sandbox. Don't deploy this as-is to accept code from untrusted strangers on the public internet; run submissions in an isolated subprocess/container with real resource limits for that use case.