(self, datas)
[[feature1 , feature2 ,....,featuren , label]]
[[feature1 , feature2 ,....,featuren , label]]
[[ feature1 feature2 .... featuren label ]]
def train(self, datas):
        '''
        [[feature1 , feature2 ,....,featuren , label]]
        '''
        # 初始化权重, 每个数据初始化权重为 weight = ( 1.0 / 数据长度 )
        if len(datas) == 0 or len(self.__boost_classifier) == 0:
            raise ValueError

        for data in datas:
            self.__labels.add(data[-1])
        # 将数据权重初始化为 1.0/ 数据总长度
        trains = [BoostData(data, 1.0 / len(datas)) for data in datas]
        # 开始计算每个分类器的权重
        for _ in range(len(self.__boost_classifier)):
            best_classifier = self.__get_trainer(trains)[0]

            best_classifier[1].weight = math.log((1 - best_classifier[0]) /
                                                 best_classifier[0], math.e) / 2
            self.__update_data_weight(trains, best_classifier[1])
def train ( self , datas ) : # 初始化权重, 每个数据初始化权重为 weight = ( 1.0 / 数据长度 ) if len ( datas ) == 0 or len ( self . __boost_classifier ) == 0 : raise ValueError for data in datas : self . __labels . add ( data [ - 1 ] ) # 将数据权重初始化为 1.0/ 数据总长度 trains = [ BoostData ( data , 1.0 / len ( datas ) ) for data in datas ] # 开始计算每个分类器的权重 for _ in range ( len ( self . __boost_classifier ) ) : best_classifier = self . __get_trainer ( trains ) [ 0 ] best_classifier [ 1 ] . weight = math . log ( ( 1 - best_classifier [ 0 ] ) / best_classifier [ 0 ] , math . e ) / 2 self . __update_data_weight ( trains , best_classifier [ 1 ] )