... | ... |
@@ -726,6 +726,59 @@ |
726 | 726 |
"learner.extra_data" |
727 | 727 |
] |
728 | 728 |
}, |
729 |
+ { |
|
730 |
+ "cell_type": "markdown", |
|
731 |
+ "metadata": {}, |
|
732 |
+ "source": [ |
|
733 |
+ "# `Scikit-Optimize`" |
|
734 |
+ ] |
|
735 |
+ }, |
|
736 |
+ { |
|
737 |
+ "cell_type": "markdown", |
|
738 |
+ "metadata": {}, |
|
739 |
+ "source": [ |
|
740 |
+ "We have wrapped the `Optimizer` class from [`scikit-optimize`](https://github.com/scikit-optimize/scikit-optimize), to show how existing libraries can be integrated with `adaptive`.\n", |
|
741 |
+ "\n", |
|
742 |
+ "The `SKOptLearner` attempts to \"optimize\" the given function `g` (i.e. find the global minimum of `g` in the window of interest).\n", |
|
743 |
+ "\n", |
|
744 |
+ "Here we use the same example as in the `scikit-optimize` [tutorial](https://github.com/scikit-optimize/scikit-optimize/blob/master/examples/ask-and-tell.ipynb). Although `SKOptLearner` can optimize functions of arbitrary dimensionality, we can only plot the learner if a 1D function is being learned." |
|
745 |
+ ] |
|
746 |
+ }, |
|
747 |
+ { |
|
748 |
+ "cell_type": "code", |
|
749 |
+ "execution_count": null, |
|
750 |
+ "metadata": { |
|
751 |
+ "collapsed": true |
|
752 |
+ }, |
|
753 |
+ "outputs": [], |
|
754 |
+ "source": [ |
|
755 |
+ "def g(x, noise_level=0.1):\n", |
|
756 |
+ " return (np.sin(5 * x) * (1 - np.tanh(x ** 2))\n", |
|
757 |
+ " + np.random.randn() * noise_level)" |
|
758 |
+ ] |
|
759 |
+ }, |
|
760 |
+ { |
|
761 |
+ "cell_type": "code", |
|
762 |
+ "execution_count": null, |
|
763 |
+ "metadata": {}, |
|
764 |
+ "outputs": [], |
|
765 |
+ "source": [ |
|
766 |
+ "learner = adaptive.SKOptLearner(g, dimensions=[(-2., 2.)],\n", |
|
767 |
+ " base_estimator=\"ET\",\n", |
|
768 |
+ " acq_optimizer=\"sampling\")\n", |
|
769 |
+ "runner = adaptive.Runner(learner, goal=lambda l: l.loss() < 1)\n", |
|
770 |
+ "runner.live_info()" |
|
771 |
+ ] |
|
772 |
+ }, |
|
773 |
+ { |
|
774 |
+ "cell_type": "code", |
|
775 |
+ "execution_count": null, |
|
776 |
+ "metadata": {}, |
|
777 |
+ "outputs": [], |
|
778 |
+ "source": [ |
|
779 |
+ "runner.live_plot()" |
|
780 |
+ ] |
|
781 |
+ }, |
|
729 | 782 |
{ |
730 | 783 |
"cell_type": "markdown", |
731 | 784 |
"metadata": { |