Skip to content

Commit 6de754d

Browse files
committed
Fix CI build errors and warnings
1 parent 19c0016 commit 6de754d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2478
-779
lines changed

modules/ml/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ ocv_create_module()
77

88
ocv_add_accuracy_tests()
99
ocv_add_perf_tests()
10-
ocv_add_samples(opencv_imgproc opencv_imgcodecs opencv_objdetect opencv_videoio opencv_video)
10+
ocv_add_samples(opencv_imgproc opencv_objdetect opencv_video)

modules/ml/doc/ml.bib

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@inproceedings{RPROP93,
2+
author = {Riedmiller, Martin and Braun, Heinrich},
3+
title = {A direct adaptive method for faster backpropagation learning: The RPROP algorithm},
4+
booktitle = {Neural Networks, 1993., IEEE International Conference on},
5+
year = {1993},
6+
pages = {586--591},
7+
publisher = {IEEE}
8+
}
9+
@article{Kirkpatrick83,
10+
author = {Kirkpatrick, S. and Gelatt, C. D. Jr and Vecchi, M. P.},
11+
title = {Optimization by Simulated Annealing},
12+
year = {1983},
13+
pages = {671--680},
14+
journal = {Science},
15+
volume = {220},
16+
number = {4598},
17+
publisher = {American Association for the Advancement of Science},
18+
url = {http://sci2s.ugr.es/sites/default/files/files/Teaching/GraduatesCourses/Metaheuristicas/Bibliography/1983-Science-Kirkpatrick-sim_anneal.pdf}
19+
}
20+
@incollection{bottou2010large,
21+
title = {Large-scale machine learning with stochastic gradient descent},
22+
author = {Bottou, L{\'e}on},
23+
booktitle = {Proceedings of COMPSTAT'2010},
24+
pages = {177--186},
25+
year = {2010},
26+
publisher = {Springer}
27+
}
28+
@article{LibSVM,
29+
author = {Chang, Chih-Chung and Lin, Chih-Jen},
30+
title = {LIBSVM: a library for support vector machines},
31+
year = {2011},
32+
pages = {27},
33+
journal = {ACM Transactions on Intelligent Systems and Technology (TIST)},
34+
volume = {2},
35+
number = {3},
36+
publisher = {ACM}
37+
}
38+
@book{Breiman84,
39+
title = {Classification and regression trees},
40+
author = {Breiman, Leo and Friedman, Jerome and Stone, Charles J and Olshen, Richard A},
41+
year = {1984},
42+
publisher = {CRC press},
43+
url = {https://projecteuclid.org/download/pdf_1/euclid.aos/1016218223}
44+
}
45+
@article{HTF01,
46+
author = {Trevor, Hastie and Robert, Tibshirani and Jerome, Friedman},
47+
title = {The elements of statistical learning: data mining, inference and prediction},
48+
year = {2001},
49+
pages = {371--406},
50+
journal = {New York: Springer-Verlag},
51+
volume = {1},
52+
number = {8},
53+
url = {http://www.stat.auckland.ac.nz/~yee/784/files/ch09AdditiveModelsTrees.pdf}
54+
}
55+
@article{FHT98,
56+
author = {Friedman, Jerome and Hastie, Trevor and Tibshirani, Robert},
57+
title = {Additive Logistic Regression: a Statistical View of Boosting},
58+
year = {1998},
59+
url = {https://projecteuclid.org/download/pdf_1/euclid.aos/1016218223}
60+
}

modules/ml/doc/ml_intro.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,6 @@ training error and ensuring high training accuracy:
476476
"setMiniBatchSize".
477477

478478
A sample set of training parameters for the Logistic Regression classifier can be initialized as follows:
479-
@snippet samples/cpp/logistic_regression.cpp init
479+
@snippet samples/logistic_regression.cpp init
480480

481481
@sa cv::ml::LogisticRegression
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python
2+
3+
# Python 2/3 compatibility
4+
from __future__ import print_function
5+
import sys
6+
PY3 = sys.version_info[0] == 3
7+
8+
if PY3:
9+
xrange = range
10+
11+
import numpy as np
12+
from numpy import random
13+
import cv2 as cv
14+
15+
def make_gaussians(cluster_n, img_size):
16+
points = []
17+
ref_distrs = []
18+
for _ in xrange(cluster_n):
19+
mean = (0.1 + 0.8*random.rand(2)) * img_size
20+
a = (random.rand(2, 2)-0.5)*img_size*0.1
21+
cov = np.dot(a.T, a) + img_size*0.05*np.eye(2)
22+
n = 100 + random.randint(900)
23+
pts = random.multivariate_normal(mean, cov, n)
24+
points.append( pts )
25+
ref_distrs.append( (mean, cov) )
26+
points = np.float32( np.vstack(points) )
27+
return points, ref_distrs
28+
29+
from tests_common import NewOpenCVTests
30+
31+
class gaussian_mix_test(NewOpenCVTests):
32+
33+
def test_gaussian_mix(self):
34+
35+
np.random.seed(10)
36+
cluster_n = 5
37+
img_size = 512
38+
39+
points, ref_distrs = make_gaussians(cluster_n, img_size)
40+
41+
em = cv.ml.EM_create()
42+
em.setClustersNumber(cluster_n)
43+
em.setCovarianceMatrixType(cv.ml.EM_COV_MAT_GENERIC)
44+
em.trainEM(points)
45+
means = em.getMeans()
46+
covs = em.getCovs() # Known bug: https://github.com/opencv/opencv/pull/4232
47+
#found_distrs = zip(means, covs)
48+
49+
matches_count = 0
50+
51+
meanEps = 0.05
52+
covEps = 0.1
53+
54+
for i in range(cluster_n):
55+
for j in range(cluster_n):
56+
if (cv.norm(means[i] - ref_distrs[j][0], cv.NORM_L2) / cv.norm(ref_distrs[j][0], cv.NORM_L2) < meanEps and
57+
cv.norm(covs[i] - ref_distrs[j][1], cv.NORM_L2) / cv.norm(ref_distrs[j][1], cv.NORM_L2) < covEps):
58+
matches_count += 1
59+
60+
self.assertEqual(matches_count, cluster_n)
61+
62+
63+
if __name__ == '__main__':
64+
NewOpenCVTests.bootstrap()
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
from __future__ import print_function
3+
4+
import numpy as np
5+
import cv2 as cv
6+
7+
from tests_common import NewOpenCVTests
8+
9+
class Bindings(NewOpenCVTests):
10+
11+
def test_inheritance(self):
12+
13+
boost = cv.ml.Boost_create()
14+
boost.getBoostType() # from ml::Boost
15+
boost.getMaxDepth() # from ml::DTrees
16+
boost.isClassifier() # from ml::StatModel
17+
18+
class Arguments(NewOpenCVTests):
19+
20+
def test_class_from_submodule_has_global_alias(self):
21+
self.assertTrue(hasattr(cv.ml, "Boost"),
22+
msg="Class is not registered in the submodule")
23+
self.assertTrue(hasattr(cv, "ml_Boost"),
24+
msg="Class from submodule doesn't have alias in the "
25+
"global module")
26+
self.assertEqual(cv.ml.Boost, cv.ml_Boost,
27+
msg="Classes from submodules and global module don't refer "
28+
"to the same type")
29+
30+
if __name__ == '__main__':
31+
NewOpenCVTests.bootstrap()

modules/ml/samples/introduction_to_pca/introduction_to_pca.cpp

-146
This file was deleted.

0 commit comments

Comments
 (0)