AlgoLens.
AI-Assisted Static Code Analysis
Problem: Recognizing an algorithm and estimating its complexity from source code is hard to do by inspection. Solution: A pipeline that extracts structural features from the code and classifies the algorithm with machine learning.
An AI-assisted static code analysis system that parses source code, extracts structural features, and uses machine learning to classify algorithm types and predict time and space complexity.
- Source-code parsing
- AST analysis
- Structural feature extraction
- Algorithm classification
- Time and space complexity prediction
- Feature-level explainability
- 96% classification accuracy across 25 algorithm classes
- AST-based feature extractor feeding a Random Forest classifier
- Feature-level explanations show which signals drove each result
How it works.
From the problem to the decisions and trade-offs behind the build.
Problem
Source code contains structural clues about the algorithm it implements, but recognizing those patterns and estimating complexity from code alone can be difficult. AlgoLens explores how static analysis can extract those signals for further analysis.
Solution
AlgoLens combines AST-based structural feature extraction with machine-learning classification and rule-based time and space complexity estimates, then presents the analysis through a React interface.
Architecture
Source Code → AST Parsing → Feature Extraction → Machine Learning Model → Prediction → FastAPI → React Interface. The Python pipeline uses a 36-feature extractor and a Random Forest classifier trained on 285 labeled samples across 16 algorithm categories.
Key Engineering Challenges
Different implementations can express similar algorithms in different ways. Static structural features are useful signals, but cannot represent every runtime behavior or edge case; the training set also defines the scope of the classifier.
Technical Decisions
Parsing into an abstract syntax tree makes it possible to work with code structure rather than surface-level text. Classification and rule-based complexity estimates are separate steps, so an estimate is not presented as a direct guarantee from the model.
Implementation
The analysis pipeline parses source code, extracts structural features, classifies an algorithm with a Random Forest model, and estimates time and space complexity with rules. Feature-level explanations expose signals behind the output.
What I Learned
Useful ML tooling depends on thoughtful feature design, a clear distinction between model predictions and rule-based estimates, and honest communication about uncertainty.