Skip to content

Commit e1e766d

Browse files
committed
Merge branch 'feature/travis' into develop
2 parents 579236d + 4891ef2 commit e1e766d

File tree

7 files changed

+103
-5
lines changed

7 files changed

+103
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/.idea
2+
*.egg-info/
3+
__pycache__/

.travis.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# (from: https://qiita.com/masashi127/items/5bfcba5cad8e82958844)
2+
3+
language: python
4+
5+
python:
6+
- 3.4
7+
- 3.5
8+
- 3.6
9+
10+
addons:
11+
apt:
12+
packages:
13+
# (from: https://github.com/dnouri/nolearn/blob/master/.travis.yml)
14+
- libblas-dev
15+
- liblapack-dev
16+
- gfortran
17+
18+
19+
before_install:
20+
- pip install -U pip setuptools wheel # (from: https://github.com/dnouri/nolearn/blob/master/.travis.yml)
21+
22+
install:
23+
- travis_wait travis_retry pip install -r requirements.txt # (from: https://github.com/dnouri/nolearn/blob/master/.travis.yml)
24+
- pip install coveralls
25+
26+
script:
27+
- coverage run --source=nwtgck_hello_test setup.py test
28+
29+
after_success:
30+
- coveralls
31+
32+
cache:
33+
- apt
34+
- directories:
35+
- $HOME/.cache/pip

requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
certifi==2017.11.5
2+
chardet==3.0.4
3+
docopt==0.6.2
4+
idna==2.6
5+
numpy==1.13.3
6+
requests==2.18.4
7+
scikit-learn==0.19.1
8+
scipy==1.0.0
9+
urllib3==1.22

setup.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# (from: https://github.com/masaponto/Python-MLP/blob/master/setup.py)
2-
from distutils.core import setup
2+
# (from: https://qiita.com/masashi127/items/5bfcba5cad8e82958844)
3+
# (from: https://qiita.com/hotoku/items/4789533f5e497f3dc6e0)
4+
5+
from setuptools import setup, find_packages
6+
import sys
7+
8+
sys.path.append('./src')
9+
sys.path.append('./tests')
310

411
setup(
512
name='multi_svr',
613
version='0.1.0-SNAPSHOT',
714
description='Multiple-targets Support Vector Regression',
815
author='Ryo Ota',
916
author_email='[email protected]',
10-
install_requires=['scikit-learn', 'numpy'],
17+
install_requires=['scikit-learn', 'numpy', 'SciPy'],
1118
py_modules=["multi_svr"],
12-
package_dir={'': 'src'}
19+
packages=find_packages(),
20+
test_suite='tests'
1321
)

src/multi_svr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def predict(self, X):
7070
regressor.fit(X, y)
7171

7272
pred_y = regressor.predict(X)
73-
err = metrics.mean_squared_error(y, pred_y, multioutput='raw_values')
73+
errs = metrics.mean_squared_error(y, pred_y, multioutput='raw_values')
7474

7575
print('pred_y:', pred_y)
76-
print('err:', err)
76+
print('errs:', errs)

tests/__init__.py

Whitespace-only changes.

tests/multi_svr_test.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import unittest
2+
from sklearn import metrics
3+
4+
import multi_svr
5+
6+
class MultiSVRTest(unittest.TestCase):
7+
8+
def test_prediction(self):
9+
X = [
10+
[0, 0],
11+
[0, 10],
12+
[1, 10],
13+
[1, 20],
14+
[1, 30],
15+
[1, 40]
16+
]
17+
18+
y = [
19+
[0, 0],
20+
[0, 10],
21+
[2, 10],
22+
[2, 20],
23+
[2, 30],
24+
[2, 40]
25+
]
26+
27+
# Create SVR
28+
regressor = multi_svr.MutilSVR(kernel='linear')
29+
# Fit
30+
regressor.fit(X, y)
31+
# Predict
32+
pred_y = regressor.predict(X)
33+
# Calc errors
34+
errs = metrics.mean_squared_error(y, pred_y, multioutput='raw_values')
35+
36+
# Errors should be small
37+
assert(errs[0] < 0.05)
38+
assert(errs[1] < 0.05)
39+
40+
41+
def suite():
42+
suite = unittest.TestSuite()
43+
suite.addTest(unittest.makeSuite(MultiSVRTest))
44+
return suite

0 commit comments

Comments
 (0)