Skip to content

Commit caeacab

Browse files
authored
Merge pull request #906 from Kaggle/install-pkg-from-pip
Install pkg from pip
2 parents 7d829bd + 4c68822 commit caeacab

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ RUN pip install mpld3 && \
196196
pip install missingno && \
197197
pip install pandas-profiling && \
198198
pip install s2sphere && \
199-
pip install git+https://github.com/fmfn/BayesianOptimization.git && \
199+
pip install bayesian-optimization && \
200200
pip install matplotlib-venn && \
201201
pip install pyldavis && \
202202
pip install mlxtend && \
@@ -283,8 +283,7 @@ RUN pip install --upgrade cython && \
283283
pip install fasttext && \
284284
apt-get install -y libhunspell-dev && pip install hunspell && \
285285
pip install annoy && \
286-
# Need to use CountEncoder from category_encoders before it's officially released
287-
pip install git+https://github.com/scikit-learn-contrib/categorical-encoding.git && \
286+
pip install category_encoders && \
288287
# google-cloud-automl 2.0.0 introduced incompatible API changes, need to pin to 1.0.1
289288
pip install google-cloud-automl==1.0.1 && \
290289
# Newer version crashes (latest = 1.14.0) when running tensorflow.
@@ -347,8 +346,7 @@ RUN pip install bcolz && \
347346
pip install --upgrade Pillow && \
348347
# Install openslide and its python binding
349348
apt-get install -y openslide-tools && \
350-
# b/152402322 install latest from pip once is in: https://github.com/openslide/openslide-python/pull/76
351-
pip install git+git://github.com/rosbo/openslide-python.git@fix-setup && \
349+
pip install openslide-python && \
352350
pip install ptyprocess && \
353351
pip install Pygments && \
354352
pip install pyparsing && \

tests/test_bayes_opt.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import unittest
2+
3+
from bayes_opt import BayesianOptimization
4+
5+
6+
class TestBayesOpt(unittest.TestCase):
7+
def test_optimize(self):
8+
# Bounded region of parameter space
9+
pbounds = {'x': (2, 4), 'y': (-3, 3)}
10+
11+
optimizer = BayesianOptimization(
12+
f=black_box_function,
13+
pbounds=pbounds,
14+
random_state=1,
15+
)
16+
17+
optimizer.maximize(
18+
init_points=2,
19+
n_iter=1,
20+
)
21+
22+
self.assertAlmostEqual(-7, optimizer.max['target'], places=0) # compares using 0 decimal
23+
24+
25+
def black_box_function(x, y):
26+
"""Function with unknown internals we wish to maximize.
27+
28+
This is just serving as an example, for all intents and
29+
purposes think of the internals of this function, i.e.: the process
30+
which generates its output values, as unknown.
31+
"""
32+
return -x ** 2 - (y - 1) ** 2 + 1

tests/test_category_encoders.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import unittest
22

3+
from category_encoders import CountEncoder
4+
import pandas as pd
5+
6+
37
## Need to make sure we have CountEncoder available from the category_encoders library
48
class TestCategoryEncoders(unittest.TestCase):
59
def test_count_encoder(self):
6-
7-
from category_encoders import CountEncoder
8-
import pandas as pd
9-
1010
encoder = CountEncoder(cols="data")
1111

1212
data = pd.DataFrame([1, 2, 3, 1, 4, 5, 3, 1], columns=["data"])

0 commit comments

Comments
 (0)