|
133 | 133 | }, |
134 | 134 | { |
135 | 135 | "cell_type": "code", |
136 | | - "execution_count": 2, |
| 136 | + "execution_count": 21, |
137 | 137 | "metadata": {}, |
138 | | - "outputs": [ |
139 | | - { |
140 | | - "name": "stdout", |
141 | | - "output_type": "stream", |
142 | | - "text": [ |
143 | | - "[1 2]\n", |
144 | | - "[3]\n" |
145 | | - ] |
146 | | - } |
147 | | - ], |
| 138 | + "outputs": [], |
148 | 139 | "source": [ |
149 | 140 | "import numpy as np\n", |
150 | 141 | "from spotPython.build.kriging import Kriging\n", |
151 | 142 | "n=2\n", |
152 | | - "p=4\n", |
| 143 | + "p=2\n", |
153 | 144 | "S = Kriging(name='kriging', seed=124, n_theta=n, n_p=p, optim_p=True, noise=False)\n", |
154 | 145 | "S.extract_from_bounds(np.array([1, 2, 3]))\n", |
155 | | - "print(S.theta)\n", |
156 | | - "print(S.p)\n", |
| 146 | + "assert len(S.theta) == n\n", |
| 147 | + "\n", |
157 | 148 | "\n", |
158 | 149 | "\n" |
159 | 150 | ] |
160 | 151 | }, |
| 152 | + { |
| 153 | + "cell_type": "markdown", |
| 154 | + "metadata": {}, |
| 155 | + "source": [ |
| 156 | + "## optimize_model" |
| 157 | + ] |
| 158 | + }, |
| 159 | + { |
| 160 | + "cell_type": "code", |
| 161 | + "execution_count": 19, |
| 162 | + "metadata": {}, |
| 163 | + "outputs": [], |
| 164 | + "source": [ |
| 165 | + "from spotPython.build.kriging import Kriging\n", |
| 166 | + "import numpy as np\n", |
| 167 | + "nat_X = np.array([[1, 2], [3, 4]])\n", |
| 168 | + "nat_y = np.array([1, 2])\n", |
| 169 | + "n=2\n", |
| 170 | + "p=2\n", |
| 171 | + "S=Kriging(name='kriging', seed=124, n_theta=n, n_p=p, optim_p=True, noise=True)\n", |
| 172 | + "S.initialize_variables(nat_X, nat_y)\n", |
| 173 | + "S.set_variable_types()\n", |
| 174 | + "S.nat_to_cod_init()\n", |
| 175 | + "S.set_theta_values()\n", |
| 176 | + "S.initialize_matrices()\n", |
| 177 | + "S.set_de_bounds()\n", |
| 178 | + "new_theta_p_Lambda = S.optimize_model()\n", |
| 179 | + "assert len(new_theta_p_Lambda) == n+p+1\n", |
| 180 | + "# no noise, so Lambda is not considered\n", |
| 181 | + "S=Kriging(name='kriging', seed=124, n_theta=n, n_p=p, optim_p=True, noise=False)\n", |
| 182 | + "S.initialize_variables(nat_X, nat_y)\n", |
| 183 | + "S.set_variable_types()\n", |
| 184 | + "S.nat_to_cod_init()\n", |
| 185 | + "S.set_theta_values()\n", |
| 186 | + "S.initialize_matrices()\n", |
| 187 | + "S.set_de_bounds()\n", |
| 188 | + "new_theta_p_Lambda = S.optimize_model()\n", |
| 189 | + "assert len(new_theta_p_Lambda) == n+p" |
| 190 | + ] |
| 191 | + }, |
161 | 192 | { |
162 | 193 | "cell_type": "code", |
163 | 194 | "execution_count": null, |
|
0 commit comments