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-5.1,-2.8)
(-6.0,-0.9)
(-5.2,-2.4)
(-1.5,-3.3)
(-4.0,-2.2)
(-5.7,-2.5)
(-3.4,-2.8)
(-4.0,-2.5)
(-3.1,-1.3)
(-5.0,-3.0)
(-4.4,-3.5)
(-2.6,-3.0)
(-4.0,-0.5)
(-2.4,-1.7)
Table 1: Dataset of two classes.
2.Thecorresponding figure as follows(a total of 100 points):
3.
Data
Weak classifier 1
Weak classifier 2
Weak classifier 3
Overall classi
er
(5.8 -3.1), -1
(5.5 -3.1), -1
(3.3 -2.5), -1
(8.1 -2.8), -1
(-6.6 3.5), -1
(-7.3 1.7), -1
(-8.1 2.8), -1
(-5.6 4.7), -1
(-5.8 3.0), -1
(-7.6 4.4), -1
( 8.6 3.8), 1
( 7.0 3.6), 1
(4.0 4.7), 1
(7.9 5.6), 1
(-3.7 -1.9), 1
(-4.0 -3.3), 1
(-3.4 -2.5), 1
(-4.4 -3.0), 1
(-2.6 -3.5), 1
(-2.4 -1.7), 1
-1
-1
-1
-1
1
-1
-1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
Accuracy
50%
70%
50%
70%
Data
Weak classifier 1
Weak classifier 2
Weak classifier 3
Weak classifier 4
Overall classi
er
(5.8 -2.3), -1
(3.3 -2.5), -1
(5.8 -3.5), -1
(8.1 -2.8), -1
(-4.4 9.5), -1
(-7.6 2.8), -1
(-4.9 3.1), -1
(-4.9 4.0 ), -1
(-5.1 3.2), -1
(-6.8 3.2), -1
(5.8 2.9), 1
(5.6 4.0), 1
(4.1 4.5), 1
(4.7 5.2), 1
(3.9 2.0), 1
(6.8 4.6), 1
(-4.6 -1.9), 1
(-5.7 -2.2), 1
(-4.0 -2.8), 1
(-4.4 -3.0), 1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
1
1
1
1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
Accuracy
50%
40%
50%
50%
50%
Data
Weak classifier 1
Weak classifier 2
Weak classifier 3
Weak classifier 4
Weak classifier 5
Overall classi
er
6.5 -3.3), -1
(5.2 -3.4), -1
(4.0 -3.7), -1
(6.3 -3.5), -1
(5.2 -2.0), -1
(-6.0 2.6), -1
(-5.0 3.3), -1
(-6.3 3.1), -1
( -7.6 2.8), -1
(-7.4 1.7), -1
( 5.7 4.1), 1
(3.9 2.0), 1
( 3.3 2.9), 1
(3.6 2.7), 1
(7.9 5.6), 1
(-5.7 -1.8 ), 1
(-3.8 -1.9), 1
( -5.1 -1.6 ), 1
( -4.0 -3.3), 1
(-2.6 -3.5), 1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
-1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
1
-1
1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
Accuracy
50%
55%
75%
50%
60%
75%
4.
Data
Weak classifier 1
Weak classifier 2
Weak classifier 3
Overall classi
er
(3.5 -3.9), -1
(5.8 -2.3), -1
(8.5 -2.0), -1
( 8.1 -2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7;-2.5;-2.1;-2.4;
-3.7;-2.4;-3.5;-2.9;-3.5;-2.0;-4.7;-2.8;9.5;8.2;9.0;3.3;3.5;1.7;2.2;2.6;2.8;4.7;3.3;
2.0;3.1;3.0;2.8;4.4;4.9;3.1;3.2;1.7;4.0;2.1;3.2;3.2;3.8;3.8;2.9;4.1;3.6;4.0;2.0;4.2;
4.5;1.8;4.8;5.2;4.7;5.6;4.6;2.0;2.9;4.3;3.7;2.9;1.8;2.7;3.2;4.5;4.6;5.6;-1.5;-1.9;1.8;
-0.4;1.8;-1.0;-1.8;-1.9;-1.9;-1.6;-2.3;-1.6;-2.8;-0.9;-2.4;-3.3;-2.2;-2.5;-2.8;-2.5;-1.3;
-3.0;-3.5;-0.5;-1.7]
instances =[X1 X2]
%[labels,instances] = libsvmread('n-gram.data');
M = 5;
cv =cvpartition(labels, 'Kfold', 5);
cv_accuracy= zeros(1, cv.NumTestSets);
param = '-t 0 -c 1 -h 0 -w1 %.3f -w-1 %.3f -w ';
for i = 1 : cv.NumTestSets
fprintf('Iteration #%d\n', i);
% initializetraining/testing dataset
training = cv.training(i);
testing = cv.test(i);
x_training = instances(training, :);
y_training = labels(training, :);
x_testing = instances(testing, :);
y_testing = labels(testing, :);
% build theweak learners
n = size(x_training, 1);
learners = cell(M, 1);
for m = 1 : M
indices = randsample(n,randi([round(n/2), n]));
w = ones(size(indices, 1), 1);
positive = numel(indices) /sum(y_training(indices, :) == 1);
negative = numel(indices) /sum(y_training(indices, :) == -1);
learners{m} = svmtrain(y_training(indices,:), x_training(indices, :), sprintf(param, positive, negative, w));
end
% predict onthe testing data
n = size(x_testing, 1);
predictions = zeros(n, M);
for m = 1 : M
[predictions(:, m), ~, ~] = svmpredict(y_testing,x_testing, learners{m});
end
predictions_sign = sign(sum(predictions,2));
cv_accuracy(i) = sum(y_testing ==predictions_sign) / size(y_testing, 1);
end
fprintf('Accuracy => [%s]\nMean => %s\n',num2str(cv_accuracy), num2str(mean(cv_accuracy)));
Appendix2: T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', 5);
cv_accuracy= zeros(1, cv.NumTestSets);
param = '-t 0 -c 1 -h 0 -w1 %.3f -w-1 %.3f -w ';
for i = 1 : cv.NumTestSets
training = cv.training(i);
testing = cv.test(i);
x_training = instances(training, :);
y_training = labels(training, :);
x_testing = instances(testing, :);
y_testing = labels(testing, :);
models = cell(M, 1);
n = size(x_training, 1);
w = repmat(1 / n, n, M);
alpha = zeros(M, 1);
eps = zeros(M, 1);
for m = 1 : M
positive = size(y_training, 1) /sum(y_training == 1);
negative = size(y_training, 1) /sum(y_training == -1);
models{m} = svmtrain( y_training,x_training, sprintf(param, positive, negative, w(:, m) ./ min(w(:, m))));
predictions = svmpredict(y_training,x_training, models{m});
I = (predictions ~= y_training);
eps(m) = (w(:, m)' * I) / sum(w(:, m));
alpha(m) = log ( (1 - eps(m)) / eps(m));
if m < M
w(:, m + 1) = w(:, m) .*exp(alpha(m) * I);
end
end
predictions = zeros(size(y_testing, 1), M);
for m = 1 : M
predictions(:, m) =svmpredict(y_testing, x_testing, models{m});
end
predictions_sign = sign(predictions *alpha);
cv_accuracy(i) = sum(predictions_sign ==y_testing) / size(y_testing, 1);
end
fprintf('Accuracy => [%s]\nMean => %s\n',num2str(cv_accuracy), num2str(mean(cv_accuracy) * 100));
- Ensemble Methods
- Ensemble Methods
- Ensemble methods(集成方法)
- Ensemble methods --Bagging meta-estimator
- Ensemble methods(组合方法,集成方法)
- Ensemble methods 之 Random Forest(随机森林)
- 集成学习(ensemble methods)概述
- scikit-learn(工程中用的相对较多的模型介绍):1.11. Ensemble methods
- sklearn中集成学(Ensemble methods)习部分(上)
- 集成方法,或者叫做组合方法(Ensemble methods)介绍(一)
- METHODS
- Methods
- Methods
- ensemble learning
- Ensemble方法
- Ensemble Learning
- Ensemble Learning
- ensemble 总结 Kaggle-Ensemble-Guide
- (7)我们的十个数字
- js闭包
- JS方法后面加括号
- 第十三周项目五(1)
- PHP安装文件线程安全和非线程安全的区别
- Ensemble Methods
- 第十三周项目四 数组的排序(对字符数组进行冒泡排序)
- 数据库课程设计——宾馆管理系统UML序列图
- Lucene中的分词器
- Terminal快捷键
- android 注意小技巧(持续更新)
- 编译c程序时 gcc编译器
- JavaWeb:报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- 在Myeclipse buildpath 加server lib (server runtime)