Skip to content

Instantly share code, notes, and snippets.

@BastinRobin
Last active March 24, 2021 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BastinRobin/33e81d2af94f971257bc3c72bf500042 to your computer and use it in GitHub Desktop.
Save BastinRobin/33e81d2af94f971257bc3c72bf500042 to your computer and use it in GitHub Desktop.
Implement Naive Bayes

Implement Naive Bayes Classifier

Naive Bayes methods are a set of supervised learning algorithms based on applying Bayes' theorem with the “naive” assumption of conditional independence between every pair of features given the value of the class variable.

enter image description here

enter image description here

Use the above dataframe as reference and build a Naive Bayes Classifier using python. Follow the guidelines.

  1. Build a production ready classifier following the API interfaces.

  2. Class should be reusable using new dataframes.

  3. fit method should take data which is complete dataframe X list of only feature names and y target name not complete nd.array.

  4. predict method should accept X only one example as list or tuple and return predicted probability.

    class NB:
    
        def __init__(self):
            pass
    
    
        def fit(self, data,  X, y):
            pass
    
    
        def predict(self, X):
            pass
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment