Instagram Engagement Pattern Analysis and Prediction using Linear Algebra
Gramatrix is a Linear Algebra-based project that analyzes Instagram engagement data and predicts the performance of new posts using matrix operations.
The project models real-world engagement data as a system of linear equations and applies mathematical concepts to extract meaningful insights and make predictions.
- Identify key factors influencing engagement
- Detect and analyze redundancy in features
- Discover dominant engagement patterns
- Predict engagement of new Instagram posts
We model the system as:
[ Ax \approx b ]
- A → Feature matrix (followers, hashtags, etc.)
- x → Weights (importance of each feature)
- b → Actual engagement
We compute the optimal weights using Least Squares:
[ x = (A^T A)^{-1} A^T b ]
- Load real-world dataset
- Convert data into matrix form
- Apply Gaussian Elimination (RREF)
- Analyze rank and linear independence
- Detect redundancy using correlation
- Apply Gram-Schmidt orthogonalization
- Compute least squares solution
- Perform projection (Ax ≈ b)
- Evaluate error (Mean Squared Error)
- Visualize results
- Perform eigenvalue analysis
- Reels (post_type) have the highest impact on engagement
- Hashtags significantly improve engagement
- Previous engagement strongly influences future performance
- Posting time moderately affects reach
- The model shows strong prediction accuracy
The model predicts engagement for new posts using:
[ \hat{b} = A_{new} \cdot x ]
[6000, 1, 120, 8, 19, 6, 400]Predicted Engagement ≈ 928
gramatrix/
│
├── data/
│ └── instagram_data.csv
│
├── screenshots/
│ ├── graph.png
│ ├── weights.png
│ ├── correlation.png
│ ├── prediction.png
│ └── eigen.png
│
├── gramatrix.ipynb
├── README.md
└── requirements.txt
- Python
- NumPy
- Pandas
- Matplotlib
- SymPy
Install dependencies:
pip install numpy pandas matplotlib sympy- Open the notebook in VS Code or Google Colab
- Upload
instagram_data.csv - Run all cells
- View outputs and predictions
- Matrix Representation
- Gaussian Elimination (RREF)
- Rank and Linear Independence
- Gram-Schmidt Orthogonalization
- Least Squares Approximation
- Projection onto Subspace
- Eigenvalues and Eigenvectors
Gramatrix demonstrates how Linear Algebra can be applied to real-world data analysis. It transforms raw Instagram metrics into meaningful insights and enables prediction of engagement using mathematical modeling.
Built by Jashruth K A




