Skip to content

Instantly share code, notes, and snippets.

@thejevans
Created March 21, 2019 01:25
Show Gist options
  • Save thejevans/ab0ecbffc14fbf5ba81880604d68d1c0 to your computer and use it in GitHub Desktop.
Save thejevans/ab0ecbffc14fbf5ba81880604d68d1c0 to your computer and use it in GitHub Desktop.
from sklearn.base import BaseEstimator, ClassifierMixin
class DiscreteNB(BaseEstimator, ClassifierMixin):
def __init__(self):
self.MLE_array = np.empty()
BaseEstimator.__init__(self)
ClassifierMixin.__init__(self)
def get_params(self, deep=True):
return BaseEstimator.get_params(self, deep=True)
def set_params(self, **params):
return BaseEstimator.set_params(self, **params)
def score(self, X, y, sample_weight=None):
#predict
#get score based on prediction and actual
#return score
return ClassifierMixin.score(self, X, y, sample_weight=None)
def fit(self):
#get MLE from X,y
#store MLE array
return
def predict(self):
#use MLE array and X to return predicted y
return
x_train, y_train
x_test, y_test
dnb = DiscreteNB()
dnb.fit(x_train, y_train)
dnb.score(x_train, y_train)
dnb.score(x_test, y_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment