# Path: lxmls/classifiers/multinomial_naive_bayes.py
# class MultinomialNaiveBayes(lc.LinearClassifier):
#     def __init__(self, xtype="gaussian"):
#     def train(self, x, y):


import sys
import os
import pytest
import warnings
import lxmls.classifiers.gaussian_naive_bayes as gnbc
import lxmls.classifiers.max_ent_batch as mebc
import lxmls.classifiers.max_ent_online as meoc
import lxmls.classifiers.mira as mirac
import lxmls.classifiers.perceptron as percc
import lxmls.classifiers.svm as svmc
import lxmls.readers.sentiment_reader as srs
import lxmls.readers.simple_data_set as sds
from numpy import allclose
from lxmls.classifiers import multinomial_naive_bayes as mnbb


def test_maxent_online(scr):
    me_sgd = meoc.MaxEntOnline()
    me_sgd.regularizer = 1.0
    params_meo_sc = me_sgd.train(scr.train_X,scr.train_y)

    y_pred_train = me_sgd.test(scr.train_X,params_meo_sc)
    acc_train = me_sgd.evaluate(scr.train_y, y_pred_train)
    assert allclose(acc_train, 0.860000, tolerance)

    y_pred_test = me_sgd.test(scr.test_X,params_meo_sc)
    acc_test = me_sgd.evaluate(scr.test_y, y_pred_test)
    assert allclose(acc_test, 0.795000, tolerance)   


# Exercise 1.5
def test_svm_online(sd, scr):
    svm = svmc.SVM()
    svm.regularizer = 1.0 # This is lambda
    params_svm_sd = svm.train(sd.train_X,sd.train_y)

    y_pred_train = svm.test(sd.train_X,params_svm_sd)
    acc_train = svm.evaluate(sd.train_y, y_pred_train)
    assert allclose(acc_train, 0.940000, tolerance)

    y_pred_test = svm.test(sd.test_X,params_svm_sd)
    acc_test = svm.evaluate(sd.test_y, y_pred_test)
    assert allclose(acc_test, 0.960000, tolerance)


# Path: lxmls/classifiers/multinomial_naive_bayes.py
# class MultinomialNaiveBayes(lc.LinearClassifier):
#     def __init__(self, xtype="gaussian"):
#     def train(self, x, y):


# Path: tests/test_linear_classifier.py
import sys
import os
import pytest
import warnings
import lxmls.classifiers.gaussian_naive_bayes as gnbc
import lxmls.classifiers.max_ent_batch as mebc
import lxmls.classifiers.max_ent_online as meoc
import lxmls.classifiers.mira as mirac
import lxmls.classifiers.perceptron as percc
import lxmls.classifiers.svm as svmc
import lxmls.readers.sentiment_reader as srs
import lxmls.readers.simple_data_set as sds
from numpy import allclose
from lxmls.classifiers import multinomial_naive_bayes as mnbb



def test_maxent_online(scr):
    me_sgd = meoc.MaxEntOnline()
    me_sgd.regularizer = 1.0
    params_meo_sc = me_sgd.train(scr.train_X,scr.train_y)

    y_pred_train = me_sgd.test(scr.train_X,params_meo_sc)
    acc_train = me_sgd.evaluate(scr.train_y, y_pred_train)
    assert allclose(acc_train, 0.860000, tolerance)

    y_pred_test = me_sgd.test(scr.test_X,params_meo_sc)
    acc_test = me_sgd.evaluate(scr.test_y, y_pred_test)
    assert allclose(acc_test, 0.795000, tolerance)   


# Exercise 1.5
def test_svm_online(sd, scr):
    svm = svmc.SVM()
    svm.regularizer = 1.0 # This is lambda
    params_svm_sd = svm.train(sd.train_X,sd.train_y)

    y_pred_train = svm.test(sd.train_X,params_svm_sd)
    acc_train = svm.evaluate(sd.train_y, y_pred_train)
    assert allclose(acc_train, 0.940000, tolerance)

    y_pred_test = svm.test(sd.test_X,params_svm_sd)
    acc_test = svm.evaluate(sd.test_y, y_pred_test)
    assert allclose(acc_test, 0.960000, tolerance)


    params_svm_sc = svm.train(scr.train_X,scr.train_y)