apache-ignite

Форк
0
55 строк · 2.3 Кб
1
// Licensed to the Apache Software Foundation (ASF) under one or more
2
// contributor license agreements.  See the NOTICE file distributed with
3
// this work for additional information regarding copyright ownership.
4
// The ASF licenses this file to You under the Apache License, Version 2.0
5
// (the "License"); you may not use this file except in compliance with
6
// the License.  You may obtain a copy of the License at
7
//
8
// http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
= Bagging
16

17
Bagging stands for bootstrap aggregation. One way to reduce the variance of an estimate is to average together multiple estimates. For example, we can train M different trees on different subsets of the data (chosen randomly with replacement) and compute the ensemble:
18

19
image::images/bagging.png[]
20

21
Bagging uses bootstrap sampling to obtain the data subsets for training the base learners. For aggregating the outputs of base learners, bagging uses voting for classification and averaging for regression.
22

23

24
[source, java]
25
----
26
// Define the weak classifier.
27
DecisionTreeClassificationTrainer trainer = new DecisionTreeClassificationTrainer(5, 0);
28

29
// Set up the bagging process.
30
BaggedTrainer<Double> baggedTrainer = TrainerTransformers.makeBagged(
31
  trainer, // Trainer for making bagged
32
  10,      // Size of ensemble
33
  0.6,     // Subsample ratio to whole dataset
34
  4,       // Feature vector dimensionality
35
  3,       // Feature subspace dimensionality
36
  new OnMajorityPredictionsAggregator())
37
  .withEnvironmentBuilder(LearningEnvironmentBuilder
38
                          .defaultBuilder()
39
                          .withRNGSeed(1)
40
                         );
41

42
// Train the Bagged Model.
43
BaggedModel mdl = baggedTrainer.fit(
44
  ignite,
45
  dataCache,
46
  vectorizer
47
);
48
----
49

50

51
TIP: A commonly used class of ensemble algorithms are forests of randomized trees.
52

53
== Example
54

55
The full example could be found as a part of the Titanic tutorial https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/ml/tutorial/Step_10_Bagging.java[here].
56

57

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.