Example #1
0
    def train(self, param):
        self.trees = []
        self.param = param

        for i in range(0, self.param.tree_number):
            tree = DTreeLoss(self.sample, param)

            if i == 0:
                residual, self.F0 = tree.initial_residual()
            else:
                last_tree = self.trees[i-1]
                residual = last_tree.next_residual()

            print >>sys.stderr, 'training tree #%d' % (i)
            tree.train(residual)
            self.trees.append(tree)
Example #2
0
    def train(self, param):
        self.trees = []
        self.param = param

        for i in range(0, self.param.tree_number):
            tree = DTreeLoss(self.sample, param)

            if i == 0:
                residual, self.F0 = tree.initial_residual()
            else:
                last_tree = self.trees[i - 1]
                residual = last_tree.next_residual()

            print >> sys.stderr, 'training tree #%d' % (i)
            tree.train(residual)
            self.trees.append(tree)
Example #3
0
# 预测房地产价格
#
# author: yafei([email protected])
#
import sys
import codecs
import locale
from dtree_loss import DTreeLoss
from dtree_parameter import DTreeParameter
from dtree_sample import DTreeSample

if __name__ == '__main__':
    param = DTreeParameter()
    sample = DTreeSample()
    sample.load('real-estate.txt')
    dt = DTreeLoss(sample, param)
    dt.train(None)

    feature_map = {
        0: u'结构',
        1: u'装修',
        2: u'周边',
        3: u'地段',
        4: u'绿化',
        5: u'交通',
        6: u'户均车位',
    }
    # 为了输出中文
    locale.setlocale(locale.LC_ALL, '')
    lang, encoding = locale.getdefaultlocale()
    sys.stdout = codecs.getwriter(encoding)(sys.stdout)
Example #4
0
# 预测房地产价格
#
# author: yafei([email protected])
#
import sys
import codecs
import locale
from dtree_loss import DTreeLoss
from dtree_parameter import DTreeParameter
from dtree_sample import DTreeSample

if __name__ == '__main__':
    param = DTreeParameter()
    sample = DTreeSample()
    sample.load('real-estate.txt')
    dt = DTreeLoss(sample, param)
    dt.train(None)

    feature_map = {
            0: u'结构',
            1: u'装修',
            2: u'周边',
            3: u'地段',
            4: u'绿化',
            5: u'交通',
            6: u'户均车位',
            }
    # 为了输出中文
    locale.setlocale(locale.LC_ALL, '')
    lang, encoding = locale.getdefaultlocale()
    sys.stdout = codecs.getwriter(encoding)(sys.stdout)