Skip to content

Added Naive Bayes classifier implementation in C++#6833

Open
YashAstro11 wants to merge 2 commits intoOpenGenus:masterfrom
YashAstro11:NBA
Open

Added Naive Bayes classifier implementation in C++#6833
YashAstro11 wants to merge 2 commits intoOpenGenus:masterfrom
YashAstro11:NBA

Conversation

@YashAstro11
Copy link

🚀 Description

This PR adds the implementation of the Naive Bayes classifier in C++ under the root directory.

  • A machine learning algorithm for classification based on Bayes' theorem.
  • Supports both training and prediction phases.
  • Implements Laplace smoothing for handling unseen feature values.
  • Allows data input via CSV file or interactive input.
  • Time Complexity:
    • fit(): O(n * m) where n is the number of training samples and m is the number of features.
    • predict(): O(t * m * k) where t is the number of test samples, m is the number of features, and k is the number of classes.
  • Space Complexity:
    • fit(): O(k * m) where k is the number of classes and m is the number of features.
    • predict(): O(t) where t is the number of test samples.
    • Data Storage: O(n * m) for training data, O(t * m) for test data.

📂 Files Added

  • naive_bayes_algorithm.cpp

✅ Related Issue

No specific issue linked, but adds the Naive Bayes classifier feature.


Let me know if any changes are required. Glad to contribute! ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant