def query(self, testX):
"""
@summary: Add test data to query individual learners in BagLearner
@param testX: ndarray, X test data with examples in rows & features in columns
Returns pred: 1Darray, the predicted labels
"""
pred = np.empty((testX.shape[0],self.bags)) # initialize pred, no. of
# rows = no. of test examples, no of columns = no. of individual learners
for col in range(pred.shape[1]):
# predictions for each learner in rows of pred
pred[:,col] = self.learnerList[col].query(testX)
modeValue, binCount = stats.mode(pred, axis = 1) # mode and number of
# counts along columns (i.e. over all learners) returned as column vectors
return modeValue[:,0] # return (column) mode of all learners in 1D-array
BagClassLearner.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录