Skip to content

Mathematical pattern recognition for discovering complete causal sequences.

Notifications You must be signed in to change notification settings

kmesiab/pure-causal-chain-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Pure Causal Chain Detection System 🔍

Mathematical Pattern Recognition for Unsupervised Causal Discovery and

Prediction

This project presents a novel approach to discovering and predicting causal relationships in streaming numerical data purely through mathematical pattern recognition, without the need for labeled datasets or explicit domain knowledge.

Key Innovation: Unlike traditional event detection systems, this system captures entire causal mechanisms — the complete sequence of changes from a period of stability through various transformations, leading to a "dramatic outcome." Each unique pattern discovered is assigned a Global Unique Identifier (GUID), essentially becoming a learned "causal law" for future predictive matching.


✨ Features

  • Unsupervised Causal Discovery: Automatically identifies and learns sequences of data changes that consistently precede significant events.

  • Pure Mathematical Pattern Recognition: Operates solely on statistical summaries of numerical tensors, making it highly adaptable across diverse domains (e.g., video streams, financial markets, system monitoring) without domain-specific training.

  • Complete Sequence Capture: Stores the full "causal chain" from stability to dramatic outcome, providing deep insights into event precursors.

  • GUID-based Causal Laws: Each learned pattern receives a unique identifier, making the discovered "laws" traceable and reusable for prediction.

  • Predictive Intelligence: Leverages learned causal laws to match against new, incoming data streams and predict future dramatic outcomes with a quantifiable similarity confidence.

  • Real-time Streaming Ready: Designed with efficient data structures (deque) to handle continuous, frame-by-frame data processing.


🚀 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Python 3.7+

  • numpy

You can install numpy using pip:

pip install numpy

Installation

  1. Clone the repository:

    git clone [https://github.com/kmesiab/pure-causal-chain-detection.git](https://github.com/kmesiab/pure-causal-chain-detection.git)
    cd pure-causal-chain-detection
  2. Save the code: Copy the provided Python code into a file named causal_detector.py (or any .py file you prefer) within the cloned directory.


Running the Demo

The project includes a built-in demonstration function (test_pure_causal_detection) that simulates a data stream, learns a causal pattern, and then tests its predictive capabilities.

To run the demo:

python causal_detector.py

You will see output similar to this:

🧮 Pure Mathematical Causal Detection System
==================================================
Discovering causal laws through mathematical pattern recognition...
Each sequence gets a unique GUID representing a causal mechanism.

Step  0: 3 objects, change=0.000 (initial)
Step  1: 3 objects, change=0.000 (stable)
Step  2: 3 objects, change=0.000 (stable)
Step  3: 3 objects, change=0.000 (stable)
Step  4: 3 objects, change=0.097 (normal)
Step  5: 3 objects, change=0.024 (stable)
Step  6: 3 objects, change=0.041 (stable)
🔍 CAUSAL SEQUENCE: cfcb711e
    Length: 3 steps
    Effect: 0.151
    Pattern: transformation_diminishment_convergence
---
Step  7: 3 objects, change=0.088 (stable)
Step  8: 3 objects, change=0.185 (DRAMATIC)
Step  9: 6 objects, change=0.383 (DRAMATIC)
Step 10: 6 objects, change=0.515 (DRAMATIC)
Step 11: 4 objects, change=0.160 (DRAMATIC)

📊 DISCOVERY COMPLETE
System learned 1 complete causal sequences
Each GUID now represents a mathematical law for prediction.

🔍 Discovered Causal Laws:
    • cfcb711e: 3 steps → effect 0.151
      Pattern: transformation_diminishment_convergence

🔮 PREDICTIVE INTELLIGENCE TEST
----------------------------------------
Testing prediction on new, unseen sequence...
System will match against learned causal patterns.

🎯 CAUSAL PREDICTION SUCCESSFUL!
    📋 Matching Law: cfcb711e
    🎲 Similarity: 99.0%
    ⚡ Expected Effect: 0.151
    ⚠️  Prediction: Dramatic change likely
    🔖 Pattern Type: transformation_diminishment_convergence

💡 The system recognized this sequence matches a known causal law!
    Pure mathematical intelligence achieved predictive capability.

============================================================
🧠 PURE MATHEMATICAL CAUSAL INTELLIGENCE ACHIEVED
============================================================
✅ System discovers causal laws through pattern recognition
✅ Each law gets unique GUID for predictive matching
✅ High-confidence predictions from mathematical similarity
✅ No domain knowledge or training labels required
✅ Ready for real-world streaming data applications

Total discovered causal laws: 1
System ready for deployment! 🚀

⚙️ Project Structure

  • causal_detector.py (or your chosen file name): Contains the main Python classes and logic for the causal detection system.
    • CausalSequence: A dataclass for storing discovered causal patterns.
    • PureCausalDetector: The core class for learning and predicting causal sequences.
    • StreamingCausalProcessor: An interface for real-time data processing.
    • test_pure_causal_detection(): A demonstration function.

💡 Potential Applications

This system's domain-agnostic nature and focus on causal sequence detection open up numerous possibilities:

  • Video Stream Analysis: Predict critical events (e.g., object fragmentation, abnormal movement) in surveillance, autonomous driving, or robotics feeds.
  • Behavioral Pattern Recognition: Learn and predict complex animal or human behaviors in scientific studies or interactive systems.
  • Complex System Monitoring: Identify early warning signs and failure patterns in industrial machinery, IT infrastructure, or smart grids.
  • Financial Market Analysis: Discover recurring price movement patterns that precede significant market shifts or asset value changes.
  • Scientific Discovery: Automatically uncover novel causal relationships in large experimental datasets in biology, chemistry, or physics.

🛣️ Roadmap

  • Expand Feature Set: Investigate additional mathematical features for tensor summarization to capture more nuanced patterns (e.g., entropy, specific moment calculations).
  • Advanced Sequence Alignment: Explore dynamic time warping (DTW) or other sequence alignment algorithms for more flexible similarity comparisons.
  • Pattern Generalization: Implement methods to generalize or cluster similar discovered causal laws to reduce redundancy and improve robustness.
  • Persistence Layer: Add functionality to save and load discovered causal sequences to/from a file or database for long-term learning.
  • Visualization Tools: Develop interactive visualizations to better understand the learned sequences and the feature_history and change_history.
  • Real-world Data Integration: Demonstrate the system's capabilities with real-world streaming datasets from various application domains.

🤝 Contributing

Contributions are welcome! If you have suggestions for improvements, new features, or bug fixes, please feel free to open an issue or submit a pull request. Please read our Code of Conduct before contributing.


🔒 Security

If you discover any security-related issues, please do not open a public issue. Instead, please contact kmesiab directly via email. We appreciate your responsible disclosure.


📝 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙏 Acknowledgments

  • Inspired by the pursuit of fundamental intelligence in complex systems.
  • Built with the power of numpy and standard Python libraries.

📚 Related Research & Articles

This project operationalizes concepts discussed in the following articles:


📧 Contact

For any questions, collaboration opportunities, or further information, please reach out to:


👨‍💻 About the Author

This project was developed by kmesiab, and it operationalizes the concepts discussed in the linked articles.

About

Mathematical pattern recognition for discovering complete causal sequences.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published