# Path: core/kover/learning/common/models.py
# class BaseModel(object):
#     def __init__(self):
#         super(BaseModel, self).__init__()
# 
#     def predict(self, X):
#         raise NotImplementedError()
# 
# 	def predict_proba(self, X):
# 	    raise NotImplementedError()
# 
#     @property
#     def learner(self):
#         raise NotImplementedError()
# 
#     def __str__(self):
#         return self._to_string()


import logging
import numpy as np
from .models import BaseModel
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""




class BreimanInfo(object):
	def __init__(self, node_n_examples_by_class, class_priors, total_n_examples_by_class):

		# Eq. 2.2 Probability that an example is in class j and falls into node t
		self.p_j_t = {c: class_priors[c] * node_n_examples_by_class[c] / total_n_examples_by_class[c]
					     for c in class_priors.iterkeys()}

		# Eq. 2.3 Probability that any example falls in node t
		self.p_t = sum(self.p_j_t.values())

		# Eq. 2.4 Probability that an example is in class j given that it falls in node t
		self.p_j_given_t = {c: self.p_j_t[c] / self.p_t for c in class_priors.iterkeys()}

		# Def. 2.10 Probability of misclassification given that an example falls into node t
		self.r_t = 1.0 - max(self.p_j_given_t.values())

		# Contribution of the node to the tree's overall missclassification rate
		self.R_t = self.r_t * self.p_t



# Path: core/kover/learning/common/models.py
# class BaseModel(object):
#     def __init__(self):
#         super(BaseModel, self).__init__()
# 
#     def predict(self, X):
#         raise NotImplementedError()
# 
# 	def predict_proba(self, X):
# 	    raise NotImplementedError()
# 
#     @property
#     def learner(self):
#         raise NotImplementedError()
# 
#     def __str__(self):
#         return self._to_string()


# Path: core/kover/learning/common/tree.py
import logging
import numpy as np
from .models import BaseModel

	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""




class BreimanInfo(object):
	def __init__(self, node_n_examples_by_class, class_priors, total_n_examples_by_class):

		# Eq. 2.2 Probability that an example is in class j and falls into node t
		self.p_j_t = {c: class_priors[c] * node_n_examples_by_class[c] / total_n_examples_by_class[c]
					     for c in class_priors.iterkeys()}

		# Eq. 2.3 Probability that any example falls in node t
		self.p_t = sum(self.p_j_t.values())

		# Eq. 2.4 Probability that an example is in class j given that it falls in node t
		self.p_j_given_t = {c: self.p_j_t[c] / self.p_t for c in class_priors.iterkeys()}

		# Def. 2.10 Probability of misclassification given that an example falls into node t
		self.r_t = 1.0 - max(self.p_j_given_t.values())

		# Contribution of the node to the tree's overall missclassification rate
		self.R_t = self.r_t * self.p_t



class TreeNode(BaseModel):