BagClassLearner.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:machine-learning-for-trading 作者: arjun-joshua 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号