From 4606b052b883425952843afb641ec35f5dc0208d Mon Sep 17 00:00:00 2001 From: Dominique Benielli <dominique.benielli@lis-lab.fr> Date: Mon, 10 Feb 2020 18:05:23 +0100 Subject: [PATCH] bug views_ind --- .../auto_examples/auto_examples_jupyter.zip | Bin 32034 -> 31942 bytes .../auto_examples/auto_examples_python.zip | Bin 26186 -> 26094 bytes .../cumbo/plot_cumbo_2_views_2_classes.ipynb | 2 +- .../cumbo/plot_cumbo_2_views_2_classes.py | 8 +++---- .../cumbo/plot_cumbo_2_views_2_classes.py.md5 | 2 +- .../cumbo/plot_cumbo_2_views_2_classes.rst | 16 ++++++------- ...lot_cumbo_2_views_2_classes_codeobj.pickle | Bin 2224 -> 2224 bytes .../cumbo/sg_execution_times.rst | 10 +++++--- .../auto_examples/mvml/plot_mvml_.ipynb | 2 +- doc/tutorial/auto_examples/mvml/plot_mvml_.py | 20 ++++++++-------- .../auto_examples/mvml/plot_mvml_.py.md5 | 2 +- .../auto_examples/mvml/plot_mvml_.rst | 22 +++++++++--------- .../mvml/plot_mvml__codeobj.pickle | Bin 3867 -> 3824 bytes .../auto_examples/mvml/sg_execution_times.rst | 4 ++-- multimodal/datasets/data_sample.py | 7 +++++- multimodal/kernels/lpMKL.py | 1 + multimodal/kernels/mvml.py | 5 +++- 17 files changed, 56 insertions(+), 45 deletions(-) diff --git a/doc/tutorial/auto_examples/auto_examples_jupyter.zip b/doc/tutorial/auto_examples/auto_examples_jupyter.zip index a0fbdaf0bca00c7f6941fd01e4cbfac684eadd05..71cae011e4df6bcb56b719d0678e194a7fb1fbb0 100644 GIT binary patch delta 272 zcmZ4Vi}Bb`#tj?9c)vw^1!P_jxKt+2z)-e%uh=bt$y1dDCQI7cGAS!eRur&dRgTG1 zR@khd!D7PqBibuq{_Fj&2jv(T4$5sdim4W0$t}yxne31+#Tt{R9FsRWF;{M~TyFd1 zwYl<>&*m;*1xXu&<R?$fn>X1yUw(3Q{$xpzsHt8-QEEzNa*0MsYH>+?MLdYTS)jm~ zd9p)=+~$&EAx1D`d5Ii^@vKx9!cZxfWZdjfF_{_F^^+e|r!yu^_NWPE+%|b$jk!Fk Xa~T*!84zGeqvGT*H5zQ9)gUnd;M-tZ delta 338 zcmX^1lX1~6#tj?9c=ygV3ve=QlE@clV94LRSL~L+<j&9qo9#5-8uM8+n+HUlu}M>r zXJAl~-)tFEEx?mkpjVuko~MypmYXxVF;_}RK~q6lp(HUoRRJWfkd|LG`JlQOYfPSU zOx|RRT)D|#bJ{szx+d4;%1@q^yO0+q05ZlHWX|Nsy!j}iCSXyq{3!^{tMa8bAI^7X zX4X+Kn7p=3ZnH|U5F?xuQX+@oOemEFb2hInGY2!k>X|A^nNfW_xurUtDOzuGou1a@ s+!~(A$~AI~>nA(am@A-qo`FG>0RfgYO2tgJjS-)`p+<nMuo@%*07Zpv$p8QV diff --git a/doc/tutorial/auto_examples/auto_examples_python.zip b/doc/tutorial/auto_examples/auto_examples_python.zip index e9eb1dd58513cedc034ae8595e7d768f4a1f4ed3..e13a39541dfa82aba880d1fdda529b9a231ae61b 100644 GIT binary patch delta 253 zcmX?ghVk8L#toT5ykDce0s^)MP0|%+V9?!MCNzhSNm*gCow4WS9zKrA748C)=Nc=s zD03+*Y@Vu^smc2-+ACnCp#5V-Nd^YR&D`ETyp!W2<R&kTSjw7PmYZWV`F51l<f6#g zV4g9UXBstg^0g@W$={;-Cig^3ZC)NN%Dj1hoHFC&{c*CJnG%E`43k6w2qPtl7s8mB zT*ip%z{w)1DNN^8Cx0{-p4^*i$8^Vh@<(&^$$qIk@+c0IWMB|tK!7EUzbDJ5sj~T` GfW!dird4PF delta 327 zcmaENn(@>b#toT5ynE-G1sMA;JfSAcz@WCdOlS_@<U+TZn>Q&2Yx0^kn+L3D`E#^I zl7XRRvyitBFGpU1UU6o6p2p<32st4IO$B9zlEmy(1(29RT7J=Fhgh-6H4#e@>J%g8 zC)-EPK?vNAl%M=FauzSlq};OH9FxfpBBds8jOs@ybBLDO92qUf%&eneF!^AD?B<?0 zHbyvSeY_Buv-x0xE|>vU!kxs6;Fu<tF{1iz@{W`grW2}@3sZ$B|5Fv2JU@kJ@-uT0 mZU!h=(s*@pL8^&7ink>h7=)nmAZkhDm&u1yRoPagfOr4}1Z=SY diff --git a/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.ipynb b/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.ipynb index 81b05f4..86a0330 100644 --- a/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.ipynb +++ b/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.ipynb @@ -26,7 +26,7 @@ }, "outputs": [], "source": [ - "import numpy as np\nfrom multimodal.boosting.cumbo import MuCumboClassifier\nfrom matplotlib import pyplot as plt\n\n\ndef generate_data(n_samples, lim):\n \"\"\"Generate random data in a rectangle\"\"\"\n lim = np.array(lim)\n n_features = lim.shape[0]\n data = np.random.random((n_samples, n_features))\n data = (lim[:, 1]-lim[:, 0]) * data + lim[:, 0]\n return data\n\n\nseed = 12\nnp.random.seed(seed)\n\nn_samples = 100\n\nview_0 = np.concatenate((generate_data(n_samples, [[0., 1.], [0., 1.]]),\n generate_data(n_samples, [[1., 2.], [0., 1.]]),\n generate_data(n_samples, [[0., 1.], [0., 1.]]),\n generate_data(n_samples, [[0., 1.], [1., 2.]])))\n\nview_1 = np.concatenate((generate_data(n_samples, [[1., 2.], [0., 1.]]),\n generate_data(n_samples, [[0., 1.], [0., 1.]]),\n generate_data(n_samples, [[0., 1.], [1., 2.]]),\n generate_data(n_samples, [[0., 1.], [0., 1.]])))\n\nX = np.concatenate((view_0, view_1), axis=1)\n\ny = np.zeros(4*n_samples, dtype=np.int64)\ny[2*n_samples:] = 1\n\nviews_ind = np.array([0, 2, 4])\n\nn_estimators = 3\nclf = MuCumboClassifier(n_estimators=n_estimators)\nclf.fit(X, y, views_ind)\n\nprint('\\nAfter 3 iterations, the MuCuMBo classifier reaches exact '\n 'classification for the\\nlearning samples:')\nfor ind, score in enumerate(clf.staged_score(X, y)):\n print(' - iteration {}, score: {}'.format(ind + 1, score))\n\n\nprint('\\nThe resulting MuCuMBo classifier uses three sub-classifiers that are '\n 'wheighted\\nusing the following weights:\\n'\n ' estimator weights: {}'.format(clf.estimator_weights_alpha_))\n\n# print('\\nThe two first sub-classifiers use the data of view 0 to compute '\n# 'their\\nclassification results, while the third one uses the data of '\n# 'view 1:\\n'\n# ' best views: {}'. format(clf.best_views_))\n\nprint('\\nThe first figure displays the data, splitting the representation '\n 'between the\\ntwo views.')\n\nfig = plt.figure(figsize=(10., 8.))\nfig.suptitle('Representation of the data', size=16)\nfor ind_view in range(2):\n ax = plt.subplot(2, 1, ind_view + 1)\n ax.set_title('View {}'.format(ind_view))\n ind_feature = ind_view * 2\n styles = ('.b', 'xb', '.r', 'xr')\n labels = ('non-separated', 'separated')\n for ind in range(4):\n ind_class = ind // 2\n label = labels[(ind + ind_view) % 2]\n ax.plot(X[n_samples*ind:n_samples*(ind+1), ind_feature],\n X[n_samples*ind:n_samples*(ind+1), ind_feature + 1],\n styles[ind],\n label='Class {} ({})'.format(ind_class, label))\n ax.legend()\n\nprint('\\nThe second figure displays the classification results for the '\n 'sub-classifiers\\non the learning sample data.\\n')\n\nstyles = ('.b', '.r')\n# fig = plt.figure(figsize=(12., 7.))\n# fig.suptitle('Classification results on the learning data for the '\n# 'sub-classifiers', size=16)\n# for ind_estimator in range(n_estimators):\n# best_view = clf.best_views_[ind_estimator]\n# y_pred = clf.estimators_[ind_estimator].predict(\n# X[:, 2*best_view:2*best_view+2])\n# background_color = (1.0, 1.0, 0.9)\n# for ind_view in range(2):\n# ax = plt.subplot(2, 3, ind_estimator + 3*ind_view + 1)\n# if ind_view == best_view:\n# ax.set_facecolor(background_color)\n# ax.set_title(\n# 'Sub-classifier {} - View {}'.format(ind_estimator, ind_view))\n# ind_feature = ind_view * 2\n# for ind_class in range(2):\n# ind_samples = (y_pred == ind_class)\n# ax.plot(X[ind_samples, ind_feature],\n# X[ind_samples, ind_feature + 1],\n# styles[ind_class],\n# label='Class {}'.format(ind_class))\n# ax.legend(title='Predicted class:')\n\nplt.show()" + "import numpy as np\nfrom multimodal.boosting.cumbo import MuCumboClassifier\nfrom matplotlib import pyplot as plt\n\n\ndef generate_data(n_samples, lim):\n \"\"\"Generate random data in a rectangle\"\"\"\n lim = np.array(lim)\n n_features = lim.shape[0]\n data = np.random.random((n_samples, n_features))\n data = (lim[:, 1]-lim[:, 0]) * data + lim[:, 0]\n return data\n\n\nseed = 12\nnp.random.seed(seed)\n\nn_samples = 100\n\nview_0 = np.concatenate((generate_data(n_samples, [[0., 1.], [0., 1.]]),\n generate_data(n_samples, [[1., 2.], [0., 1.]]),\n generate_data(n_samples, [[0., 1.], [0., 1.]]),\n generate_data(n_samples, [[0., 1.], [1., 2.]])))\n\nview_1 = np.concatenate((generate_data(n_samples, [[1., 2.], [0., 1.]]),\n generate_data(n_samples, [[0., 1.], [0., 1.]]),\n generate_data(n_samples, [[0., 1.], [1., 2.]]),\n generate_data(n_samples, [[0., 1.], [0., 1.]])))\n\nX = np.concatenate((view_0, view_1), axis=1)\n\ny = np.zeros(4*n_samples, dtype=np.int64)\ny[2*n_samples:] = 1\n\nviews_ind = np.array([0, 2, 4])\n\nn_estimators = 3\nclf = MuCumboClassifier(n_estimators=n_estimators)\nclf.fit(X, y, views_ind)\n\nprint('\\nAfter 3 iterations, the MuCuMBo classifier reaches exact '\n 'classification for the\\nlearning samples:')\nfor ind, score in enumerate(clf.staged_score(X, y)):\n print(' - iteration {}, score: {}'.format(ind + 1, score))\n\n\nprint('\\nThe resulting MuCuMBo classifier uses three sub-classifiers that are '\n 'wheighted\\nusing the following weights:\\n'\n ' estimator weights: {}'.format(clf.estimator_weights_alpha_))\n\n# print('\\nThe two first sub-classifiers use the data of view 0 to compute '\n# 'their\\nclassification results, while the third one uses the data of '\n# 'view 1:\\n'\n# ' best views: {}'. format(clf.best_views_))\n\nprint('\\nThe first figure displays the data, splitting the representation '\n 'between the\\ntwo views.')\n\nfig = plt.figure(figsize=(10., 8.))\nfig.suptitle('Representation of the data', size=16)\nfor ind_view in range(2):\n ax = plt.subplot(2, 1, ind_view + 1)\n ax.set_title('View {}'.format(ind_view))\n ind_feature = ind_view * 2\n styles = ('.b', 'xb', '.r', 'xr')\n labels = ('non-separated', 'separated')\n for ind in range(4):\n ind_class = ind // 2\n label = labels[(ind + ind_view) % 2]\n ax.plot(X[n_samples*ind:n_samples*(ind+1), ind_feature],\n X[n_samples*ind:n_samples*(ind+1), ind_feature + 1],\n styles[ind],\n label='Class {} ({})'.format(ind_class, label))\n ax.legend()\n\n# print('\\nThe second figure displays the classification results for the '\n# 'sub-classifiers\\non the learning sample data.\\n')\n#\n# styles = ('.b', '.r')\n# fig = plt.figure(figsize=(12., 7.))\n# fig.suptitle('Classification results on the learning data for the '\n# 'sub-classifiers', size=16)\n# for ind_estimator in range(n_estimators):\n# best_view = clf.best_views_[ind_estimator]\n# y_pred = clf.estimators_[ind_estimator].predict(\n# X[:, 2*best_view:2*best_view+2])\n# background_color = (1.0, 1.0, 0.9)\n# for ind_view in range(2):\n# ax = plt.subplot(2, 3, ind_estimator + 3*ind_view + 1)\n# if ind_view == best_view:\n# ax.set_facecolor(background_color)\n# ax.set_title(\n# 'Sub-classifier {} - View {}'.format(ind_estimator, ind_view))\n# ind_feature = ind_view * 2\n# for ind_class in range(2):\n# ind_samples = (y_pred == ind_class)\n# ax.plot(X[ind_samples, ind_feature],\n# X[ind_samples, ind_feature + 1],\n# styles[ind_class],\n# label='Class {}'.format(ind_class))\n# ax.legend(title='Predicted class:')\n\nplt.show()" ] } ], diff --git a/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.py b/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.py index c669f69..77d0588 100644 --- a/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.py +++ b/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.py @@ -97,10 +97,10 @@ for ind_view in range(2): label='Class {} ({})'.format(ind_class, label)) ax.legend() -print('\nThe second figure displays the classification results for the ' - 'sub-classifiers\non the learning sample data.\n') - -styles = ('.b', '.r') +# print('\nThe second figure displays the classification results for the ' +# 'sub-classifiers\non the learning sample data.\n') +# +# styles = ('.b', '.r') # fig = plt.figure(figsize=(12., 7.)) # fig.suptitle('Classification results on the learning data for the ' # 'sub-classifiers', size=16) diff --git a/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.py.md5 b/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.py.md5 index 06630ff..0b84b4f 100644 --- a/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.py.md5 +++ b/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.py.md5 @@ -1 +1 @@ -5b1bad9179e6c052ce9a8198c8443c9a \ No newline at end of file +ac125b9b4b4a1f4600b8a804ce421f11 \ No newline at end of file diff --git a/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.rst b/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.rst index f47b92a..fd2ac27 100644 --- a/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.rst +++ b/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes.rst @@ -54,10 +54,8 @@ rightly classify the points. The first figure displays the data, splitting the representation between the two views. - - The second figure displays the classification results for the sub-classifiers - on the learning sample data. - + /home/dominique/projets/ANR-Lives/scikit-multimodallearn/examples/cumbo/plot_cumbo_2_views_2_classes.py:127: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. + plt.show() @@ -145,10 +143,10 @@ rightly classify the points. label='Class {} ({})'.format(ind_class, label)) ax.legend() - print('\nThe second figure displays the classification results for the ' - 'sub-classifiers\non the learning sample data.\n') - - styles = ('.b', '.r') + # print('\nThe second figure displays the classification results for the ' + # 'sub-classifiers\non the learning sample data.\n') + # + # styles = ('.b', '.r') # fig = plt.figure(figsize=(12., 7.)) # fig.suptitle('Classification results on the learning data for the ' # 'sub-classifiers', size=16) @@ -177,7 +175,7 @@ rightly classify the points. .. rst-class:: sphx-glr-timing - **Total running time of the script:** ( 0 minutes 0.616 seconds) + **Total running time of the script:** ( 0 minutes 0.926 seconds) .. _sphx_glr_download_tutorial_auto_examples_cumbo_plot_cumbo_2_views_2_classes.py: diff --git a/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes_codeobj.pickle b/doc/tutorial/auto_examples/cumbo/plot_cumbo_2_views_2_classes_codeobj.pickle index c952702cb6c9aef634d994d47180af94e03b0775..46f31f8bc0410beb38b60cce658754762051120c 100644 GIT binary patch delta 267 zcmdlWxIu7&o&#rId~srKK~8G%l-em8JuG>Nxv5inm^1TAru4Ao=BJeAq)zGKNGi?D zDap($p3=hu5sNR*$S*3HlEFDyl*w)K9HzL*32X+85|h&yohDw&XH=U!lig=>9jo`` zXeP(W=NUaFPi9kQw43b7uFmK*iCvM&t#qQU_~f_jev^HfLncSE=uBS7ti%{G`7(<> zW6b1bjB1PtlMC6^8B-=dW{;T6%BsPbJ6Vd&ZSn&)dG@kWko!_53$n^ER!x4+T*S&! zoSF*ePu|9+HCcsSg|U0`aaIk+{>dL$H5n&QUc;isIDN7nYrw?SDvS#z|6mGbkx9-; Nn_S2tH93+a900g-Su+3t delta 296 zcmdlWxIu7&o|T|)sdH&=QoeIeVsUY1T4rj|l-em8JuG>Nxv5inu*mkX<>sf9=A=%U z9LOfa-@^mp#TRGf7nMwze34mV@<DbLM*hjojD;K$r9CXgsi`TG^I2sWWhOf_I!)fk zqQa;;`81Q)!~&PeJxq=hx5Q0;!5%#MC3DE+Oco_}_tGBb%shw=@5!QUMU!n=bhtS4 z;)@e=3vyD6!A3<)_F`9KjG5fSqR*HxIgwS1F=cWgd%$EzChy5V+0+<|CM&ROGL}v5 zVRf4<#Av`+KUtVrb@B=}t;v^I<r%vtCo(HC_D{aRrp7pVvL&-R<MhdoS=1S4PyWj2 WGntn)j726nCv9>eht%Xqj&J|~8Db{@ diff --git a/doc/tutorial/auto_examples/cumbo/sg_execution_times.rst b/doc/tutorial/auto_examples/cumbo/sg_execution_times.rst index 7979643..8a8e3b0 100644 --- a/doc/tutorial/auto_examples/cumbo/sg_execution_times.rst +++ b/doc/tutorial/auto_examples/cumbo/sg_execution_times.rst @@ -1,10 +1,14 @@ +:orphan: + +.. _sphx_glr_tutorial_auto_examples_cumbo_sg_execution_times: + Computation times ================= -**00:01.113** total execution time for **tutorial_auto_examples_cumbo** files: +**00:00.926** total execution time for **tutorial_auto_examples_cumbo** files: +--------------------------------------------------------------------------------------------------------------------+-----------+--------+ -| :ref:`sphx_glr_tutorial_auto_examples_cumbo_plot_cumbo_2_views_2_classes.py` (``plot_cumbo_2_views_2_classes.py``) | 00:00.616 | 0.0 MB | +| :ref:`sphx_glr_tutorial_auto_examples_cumbo_plot_cumbo_2_views_2_classes.py` (``plot_cumbo_2_views_2_classes.py``) | 00:00.926 | 0.0 MB | +--------------------------------------------------------------------------------------------------------------------+-----------+--------+ -| :ref:`sphx_glr_tutorial_auto_examples_cumbo_plot_cumbo_3_views_3_classes.py` (``plot_cumbo_3_views_3_classes.py``) | 00:00.497 | 0.0 MB | +| :ref:`sphx_glr_tutorial_auto_examples_cumbo_plot_cumbo_3_views_3_classes.py` (``plot_cumbo_3_views_3_classes.py``) | 00:00.000 | 0.0 MB | +--------------------------------------------------------------------------------------------------------------------+-----------+--------+ diff --git a/doc/tutorial/auto_examples/mvml/plot_mvml_.ipynb b/doc/tutorial/auto_examples/mvml/plot_mvml_.ipynb index 211b617..61b53bc 100644 --- a/doc/tutorial/auto_examples/mvml/plot_mvml_.ipynb +++ b/doc/tutorial/auto_examples/mvml/plot_mvml_.ipynb @@ -44,7 +44,7 @@ }, "outputs": [], "source": [ - "kernel_dict = {}\ntest_kernel_dict = {}\nkernel_dict[0] = rbf_kernel(X0[0:n_tr, :])\nkernel_dict[1] = rbf_kernel(X1[0:n_tr, :])\ntest_kernel_dict[0] = rbf_kernel(X0[n_tr:n_tot, :], X0[0:n_tr, :])\ntest_kernel_dict[1] = rbf_kernel(X1[n_tr:n_tot, :], X1[0:n_tr, :])\nx_dict = {}\nx_dict[0] = X0[0:n_tr, :]\nx_dict[1] = X1[0:n_tr, :]\ntest_x_dict = {}\ntest_x_dict[0] = X0[n_tr:n_tot, :]\ntest_x_dict[1] = X1[n_tr:n_tot, :]\n# d= DataSample(kernel_dict)\n# a = d.data\n#\n# =========== use MVML in classifying the data ============\n# kernel precomputed\n# demo on how the code is intended to be used; parameters are not cross-validated, just picked some\n# # with approximation\n# # default: learn A, don't learn w (learn_A=1, learn_w=0)\nmvml = MVML(lmbda=0.1, eta=1, nystrom_param=0.2, kernel='precomputed')\nmvml.fit(kernel_dict, Y[0:n_tr])\n\n\n#\n\npred1 = np.sign(mvml.predict(test_kernel_dict) ) # take sign for classification result\n#\n# without approximation\nmvml2 = MVML(lmbda=0.1, eta=1, nystrom_param=1, kernel='precomputed') # without approximation\nmvml2.fit(kernel_dict, Y[0:n_tr])\npred2 = np.sign(mvml2.predict(test_kernel_dict))\n#\n# use MVML_Cov, don't learn w\nmvml3 = MVML(lmbda=0.1, eta=1,learn_A=3, nystrom_param=1, kernel='precomputed')\nmvml3.fit(kernel_dict, Y[0:n_tr])\npred3 = np.sign(mvml3.predict(test_kernel_dict))\n#\n# use MVML_I, don't learn w\nmvml4 = MVML(lmbda=0.1, eta=1,learn_A=4, nystrom_param=1, kernel='precomputed')\nmvml4.fit(kernel_dict, Y[0:n_tr])\npred4 = np.sign(mvml4.predict(test_kernel_dict))\n#\n# use kernel rbf equivalent to case 1\nmvml5 = MVML(lmbda=0.1, eta=1, nystrom_param=0.2, kernel='rbf')\nmvml5.fit(x_dict, Y[0:n_tr])\npred5 = np.sign(mvml5.predict(test_x_dict))\n#\n#\n# # =========== show results ============\n#\n# # accuracies\nacc1 = accuracy_score(Y[n_tr:n_tot], pred1)\nacc2 = accuracy_score(Y[n_tr:n_tot], pred2)\nacc3 = accuracy_score(Y[n_tr:n_tot], pred3)\nacc4 = accuracy_score(Y[n_tr:n_tot], pred4)\nacc5 = accuracy_score(Y[n_tr:n_tot], pred5)\n#\n# # display obtained accuracies\n#\nprint(\"MVML: \", acc1)\nprint(\"MVMLsparse: \", acc2)\nprint(\"MVML_Cov: \", acc3)\nprint(\"MVML_I: \", acc4)\nprint(\"MVML_rbf: \", acc5)\n#\n#\n# # plot data and some classification results\n#\nplt.figure(2, figsize=(10., 8.))\nplt.subplot(341)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=Y[n_tr:n_tot])\nplt.title(\"orig. view 1\")\nplt.subplot(342)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=Y[n_tr:n_tot])\nplt.title(\"orig. view 2\")\n#\npred1[np.where(pred1[:, 0] != Y[n_tr:n_tot])] = 0\npred1 = pred1.reshape((pred1.shape[0]))\nplt.subplot(343)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred1)\nplt.title(\"MVML view 1\")\nplt.subplot(344)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred1)\nplt.title(\"MVML view 2\")\n#\npred2[np.where(pred2[:, 0] != Y[n_tr:n_tot])] = 0\npred2 = pred2.reshape((pred2.shape[0]))\nplt.subplot(345)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred2)\nplt.title(\"MVMLsparse view 1\")\nplt.subplot(346)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred2)\nplt.title(\"MVMLsparse view 2\")\n#\npred3[np.where(pred3[:, 0] != Y[n_tr:n_tot])] = 0\npred3 = pred3.reshape((pred3.shape[0]))\n#\nplt.subplot(347)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred3)\nplt.title(\"MVML_Cov view 1\")\nplt.subplot(348)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred3)\nplt.title(\"MVML_Cov view 2\")\n#\npred4[np.where(pred4[:, 0] != Y[n_tr:n_tot])] = 0\npred4 = pred4.reshape((pred4.shape[0]))\nplt.subplot(349)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred4)\nplt.title(\"MVML_I view 1\")\nplt.subplot(3,4,10)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred4)\nplt.title(\"MVML_I view 2\")\n#\npred5[np.where(pred5[:, 0] != Y[n_tr:n_tot])] = 0\npred5 = pred5.reshape((pred5.shape[0]))\nplt.subplot(3,4,11)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred5)\nplt.title(\"MVML_rbf_kernel view 1\")\nplt.subplot(3,4,12)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred5)\nplt.title(\"MVML_rbf_kernel view 2\")\n#\nplt.show()" + "kernel_dict = {}\ntest_kernel_dict = {}\nkernel_dict[0] = rbf_kernel(X0[0:n_tr, :])\nkernel_dict[1] = rbf_kernel(X1[0:n_tr, :])\ntest_kernel_dict[0] = rbf_kernel(X0[n_tr:n_tot, :], X0[0:n_tr, :])\ntest_kernel_dict[1] = rbf_kernel(X1[n_tr:n_tot, :], X1[0:n_tr, :])\nx_dict = {}\nx_dict[0] = X0[0:n_tr, :]\nx_dict[1] = X1[0:n_tr, :]\ntest_x_dict = {}\ntest_x_dict[0] = X0[n_tr:n_tot, :]\ntest_x_dict[1] = X1[n_tr:n_tot, :]\n# d= DataSample(kernel_dict)\n# a = d.data\n#\n# =========== use MVML in classifying the data ============\n# kernel precomputed\n# demo on how the code is intended to be used; parameters are not cross-validated, just picked some\n# # with approximation\n# # default: learn A, don't learn w (learn_A=1, learn_w=0)\nmvml = MVML(lmbda=0.1, eta=1, nystrom_param=0.2, kernel='precomputed')\nmvml.fit(kernel_dict, Y[0:n_tr])\n\n\n#\n\npred1 = mvml.predict(test_kernel_dict)\n#\n# without approximation\nmvml2 = MVML(lmbda=0.1, eta=1, nystrom_param=1, kernel='precomputed') # without approximation\nmvml2.fit(kernel_dict, Y[0:n_tr])\npred2 = mvml2.predict(test_kernel_dict)\n#\n# use MVML_Cov, don't learn w\nmvml3 = MVML(lmbda=0.1, eta=1,learn_A=3, nystrom_param=1, kernel='precomputed')\nmvml3.fit(kernel_dict, Y[0:n_tr])\npred3 = mvml3.predict(test_kernel_dict)\n#\n# use MVML_I, don't learn w\nmvml4 = MVML(lmbda=0.1, eta=1,learn_A=4, nystrom_param=1, kernel='precomputed')\nmvml4.fit(kernel_dict, Y[0:n_tr])\npred4 = mvml4.predict(test_kernel_dict)\n#\n# use kernel rbf equivalent to case 1\nmvml5 = MVML(lmbda=0.1, eta=1, nystrom_param=0.2, kernel='rbf')\nmvml5.fit(x_dict, Y[0:n_tr])\npred5 = mvml5.predict(test_x_dict)\n#\n#\n# # =========== show results ============\n#\n# # accuracies\nacc1 = accuracy_score(Y[n_tr:n_tot], pred1)\nacc2 = accuracy_score(Y[n_tr:n_tot], pred2)\nacc3 = accuracy_score(Y[n_tr:n_tot], pred3)\nacc4 = accuracy_score(Y[n_tr:n_tot], pred4)\nacc5 = accuracy_score(Y[n_tr:n_tot], pred5)\n#\n# # display obtained accuracies\n#\nprint(\"MVML: \", acc1)\nprint(\"MVMLsparse: \", acc2)\nprint(\"MVML_Cov: \", acc3)\nprint(\"MVML_I: \", acc4)\nprint(\"MVML_rbf: \", acc5)\n#\n#\n# # plot data and some classification results\n#\nplt.figure(2, figsize=(10., 8.))\nplt.subplot(341)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=Y[n_tr:n_tot])\nplt.title(\"orig. view 1\")\nplt.subplot(342)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=Y[n_tr:n_tot])\nplt.title(\"orig. view 2\")\n#\npred1[np.where(pred1[:] != Y[n_tr:n_tot])] = 0\npred1 = pred1.reshape((pred1.shape[0]))\nplt.subplot(343)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred1)\nplt.title(\"MVML view 1\")\nplt.subplot(344)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred1)\nplt.title(\"MVML view 2\")\n#\npred2[np.where(pred2[:] != Y[n_tr:n_tot])] = 0\npred2 = pred2.reshape((pred2.shape[0]))\nplt.subplot(345)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred2)\nplt.title(\"MVMLsparse view 1\")\nplt.subplot(346)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred2)\nplt.title(\"MVMLsparse view 2\")\n#\npred3[np.where(pred3[:] != Y[n_tr:n_tot])] = 0\npred3 = pred3.reshape((pred3.shape[0]))\n#\nplt.subplot(347)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred3)\nplt.title(\"MVML_Cov view 1\")\nplt.subplot(348)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred3)\nplt.title(\"MVML_Cov view 2\")\n#\npred4[np.where(pred4[:] != Y[n_tr:n_tot])] = 0\npred4 = pred4.reshape((pred4.shape[0]))\nplt.subplot(349)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred4)\nplt.title(\"MVML_I view 1\")\nplt.subplot(3,4,10)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred4)\nplt.title(\"MVML_I view 2\")\n#\npred5[np.where(pred5[:] != Y[n_tr:n_tot])] = 0\npred5 = pred5.reshape((pred5.shape[0]))\nplt.subplot(3,4,11)\nplt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred5)\nplt.title(\"MVML_rbf_kernel view 1\")\nplt.subplot(3,4,12)\nplt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred5)\nplt.title(\"MVML_rbf_kernel view 2\")\n#\nplt.show()" ] } ], diff --git a/doc/tutorial/auto_examples/mvml/plot_mvml_.py b/doc/tutorial/auto_examples/mvml/plot_mvml_.py index a449a7c..8989230 100644 --- a/doc/tutorial/auto_examples/mvml/plot_mvml_.py +++ b/doc/tutorial/auto_examples/mvml/plot_mvml_.py @@ -106,27 +106,27 @@ mvml.fit(kernel_dict, Y[0:n_tr]) # -pred1 = np.sign(mvml.predict(test_kernel_dict) ) # take sign for classification result +pred1 = mvml.predict(test_kernel_dict) # # without approximation mvml2 = MVML(lmbda=0.1, eta=1, nystrom_param=1, kernel='precomputed') # without approximation mvml2.fit(kernel_dict, Y[0:n_tr]) -pred2 = np.sign(mvml2.predict(test_kernel_dict)) +pred2 = mvml2.predict(test_kernel_dict) # # use MVML_Cov, don't learn w mvml3 = MVML(lmbda=0.1, eta=1,learn_A=3, nystrom_param=1, kernel='precomputed') mvml3.fit(kernel_dict, Y[0:n_tr]) -pred3 = np.sign(mvml3.predict(test_kernel_dict)) +pred3 = mvml3.predict(test_kernel_dict) # # use MVML_I, don't learn w mvml4 = MVML(lmbda=0.1, eta=1,learn_A=4, nystrom_param=1, kernel='precomputed') mvml4.fit(kernel_dict, Y[0:n_tr]) -pred4 = np.sign(mvml4.predict(test_kernel_dict)) +pred4 = mvml4.predict(test_kernel_dict) # # use kernel rbf equivalent to case 1 mvml5 = MVML(lmbda=0.1, eta=1, nystrom_param=0.2, kernel='rbf') mvml5.fit(x_dict, Y[0:n_tr]) -pred5 = np.sign(mvml5.predict(test_x_dict)) +pred5 = mvml5.predict(test_x_dict) # # # # =========== show results ============ @@ -157,7 +157,7 @@ plt.subplot(342) plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=Y[n_tr:n_tot]) plt.title("orig. view 2") # -pred1[np.where(pred1[:, 0] != Y[n_tr:n_tot])] = 0 +pred1[np.where(pred1[:] != Y[n_tr:n_tot])] = 0 pred1 = pred1.reshape((pred1.shape[0])) plt.subplot(343) plt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred1) @@ -166,7 +166,7 @@ plt.subplot(344) plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred1) plt.title("MVML view 2") # -pred2[np.where(pred2[:, 0] != Y[n_tr:n_tot])] = 0 +pred2[np.where(pred2[:] != Y[n_tr:n_tot])] = 0 pred2 = pred2.reshape((pred2.shape[0])) plt.subplot(345) plt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred2) @@ -175,7 +175,7 @@ plt.subplot(346) plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred2) plt.title("MVMLsparse view 2") # -pred3[np.where(pred3[:, 0] != Y[n_tr:n_tot])] = 0 +pred3[np.where(pred3[:] != Y[n_tr:n_tot])] = 0 pred3 = pred3.reshape((pred3.shape[0])) # plt.subplot(347) @@ -185,7 +185,7 @@ plt.subplot(348) plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred3) plt.title("MVML_Cov view 2") # -pred4[np.where(pred4[:, 0] != Y[n_tr:n_tot])] = 0 +pred4[np.where(pred4[:] != Y[n_tr:n_tot])] = 0 pred4 = pred4.reshape((pred4.shape[0])) plt.subplot(349) plt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred4) @@ -194,7 +194,7 @@ plt.subplot(3,4,10) plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred4) plt.title("MVML_I view 2") # -pred5[np.where(pred5[:, 0] != Y[n_tr:n_tot])] = 0 +pred5[np.where(pred5[:] != Y[n_tr:n_tot])] = 0 pred5 = pred5.reshape((pred5.shape[0])) plt.subplot(3,4,11) plt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred5) diff --git a/doc/tutorial/auto_examples/mvml/plot_mvml_.py.md5 b/doc/tutorial/auto_examples/mvml/plot_mvml_.py.md5 index 4ee8d03..fee4ef6 100644 --- a/doc/tutorial/auto_examples/mvml/plot_mvml_.py.md5 +++ b/doc/tutorial/auto_examples/mvml/plot_mvml_.py.md5 @@ -1 +1 @@ -870a37ab95c98874716ccd8b360cbc36 \ No newline at end of file +78c8ab5d5b62ecaa8b639a49b4cbaea0 \ No newline at end of file diff --git a/doc/tutorial/auto_examples/mvml/plot_mvml_.rst b/doc/tutorial/auto_examples/mvml/plot_mvml_.rst index cce0d8f..88f46af 100644 --- a/doc/tutorial/auto_examples/mvml/plot_mvml_.rst +++ b/doc/tutorial/auto_examples/mvml/plot_mvml_.rst @@ -138,27 +138,27 @@ make kernel dictionaries # - pred1 = np.sign(mvml.predict(test_kernel_dict) ) # take sign for classification result + pred1 = mvml.predict(test_kernel_dict) # # without approximation mvml2 = MVML(lmbda=0.1, eta=1, nystrom_param=1, kernel='precomputed') # without approximation mvml2.fit(kernel_dict, Y[0:n_tr]) - pred2 = np.sign(mvml2.predict(test_kernel_dict)) + pred2 = mvml2.predict(test_kernel_dict) # # use MVML_Cov, don't learn w mvml3 = MVML(lmbda=0.1, eta=1,learn_A=3, nystrom_param=1, kernel='precomputed') mvml3.fit(kernel_dict, Y[0:n_tr]) - pred3 = np.sign(mvml3.predict(test_kernel_dict)) + pred3 = mvml3.predict(test_kernel_dict) # # use MVML_I, don't learn w mvml4 = MVML(lmbda=0.1, eta=1,learn_A=4, nystrom_param=1, kernel='precomputed') mvml4.fit(kernel_dict, Y[0:n_tr]) - pred4 = np.sign(mvml4.predict(test_kernel_dict)) + pred4 = mvml4.predict(test_kernel_dict) # # use kernel rbf equivalent to case 1 mvml5 = MVML(lmbda=0.1, eta=1, nystrom_param=0.2, kernel='rbf') mvml5.fit(x_dict, Y[0:n_tr]) - pred5 = np.sign(mvml5.predict(test_x_dict)) + pred5 = mvml5.predict(test_x_dict) # # # # =========== show results ============ @@ -189,7 +189,7 @@ make kernel dictionaries plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=Y[n_tr:n_tot]) plt.title("orig. view 2") # - pred1[np.where(pred1[:, 0] != Y[n_tr:n_tot])] = 0 + pred1[np.where(pred1[:] != Y[n_tr:n_tot])] = 0 pred1 = pred1.reshape((pred1.shape[0])) plt.subplot(343) plt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred1) @@ -198,7 +198,7 @@ make kernel dictionaries plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred1) plt.title("MVML view 2") # - pred2[np.where(pred2[:, 0] != Y[n_tr:n_tot])] = 0 + pred2[np.where(pred2[:] != Y[n_tr:n_tot])] = 0 pred2 = pred2.reshape((pred2.shape[0])) plt.subplot(345) plt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred2) @@ -207,7 +207,7 @@ make kernel dictionaries plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred2) plt.title("MVMLsparse view 2") # - pred3[np.where(pred3[:, 0] != Y[n_tr:n_tot])] = 0 + pred3[np.where(pred3[:] != Y[n_tr:n_tot])] = 0 pred3 = pred3.reshape((pred3.shape[0])) # plt.subplot(347) @@ -217,7 +217,7 @@ make kernel dictionaries plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred3) plt.title("MVML_Cov view 2") # - pred4[np.where(pred4[:, 0] != Y[n_tr:n_tot])] = 0 + pred4[np.where(pred4[:] != Y[n_tr:n_tot])] = 0 pred4 = pred4.reshape((pred4.shape[0])) plt.subplot(349) plt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred4) @@ -226,7 +226,7 @@ make kernel dictionaries plt.scatter(X1[n_tr:n_tot, 0], X1[n_tr:n_tot, 1], c=pred4) plt.title("MVML_I view 2") # - pred5[np.where(pred5[:, 0] != Y[n_tr:n_tot])] = 0 + pred5[np.where(pred5[:] != Y[n_tr:n_tot])] = 0 pred5 = pred5.reshape((pred5.shape[0])) plt.subplot(3,4,11) plt.scatter(X0[n_tr:n_tot, 0], X0[n_tr:n_tot, 1], c=pred5) @@ -268,7 +268,7 @@ make kernel dictionaries .. rst-class:: sphx-glr-timing - **Total running time of the script:** ( 0 minutes 5.285 seconds) + **Total running time of the script:** ( 0 minutes 4.803 seconds) .. _sphx_glr_download_tutorial_auto_examples_mvml_plot_mvml_.py: diff --git a/doc/tutorial/auto_examples/mvml/plot_mvml__codeobj.pickle b/doc/tutorial/auto_examples/mvml/plot_mvml__codeobj.pickle index 25388d951eb345c5a8f5fb3a7b5596ef70993a1f..951ac413d82c84bd33834d8ac8a159f8d182c9d4 100644 GIT binary patch delta 562 zcmbO&_d%Amfo1AbzKN`wR!k9wQ);JZ^swY5=B7^RVb4oREGkN@oYKRVo1apelRBk` zHLo<cpmItN4@4loI3vHPWJ(6-<dwYoOc{KWqqzcEbIWpbj3<BO2x4XN4fFMx{E*d& zl?5a?`5~+G<c-|!%uJPrlO4Ea8MP+|vbaso<?saSF`E35BYbiyxA)|DUInHM=gF7& z+}V3r3yM-xOu)*0CJQnKO%~=>VGN!8lg*GZa`FQn6{d{X$=|qrCYv$4Ouow~$C+K) z!wb@4IQbyEE@yse4>yQsG?|fIld~8qX9ALAET1gG5j8o5QHil(vM`s|<bRAxjGdF) z8G|PGGHEhSnyk$pJ^2ksI5ShF0oeKllWW<k8COnz&#BD0wiMzpV~`BzMyR<)Aal94 zmiDk!X6B_7gFVT*v$TgX5~PfA@8r9@UX!_bm6<Y*O`gc9&3I}uJB!cc{ha!YmnYxn zGGx3y*?~ue@%Cf~RyD@^lXtS4ay%~W;Q$9+Kcm;==`6t$-zhPEocx|$h3#u;4^srh zVLvA;vZ-?ZE$!h1DK(l5Qrp9-I$4jGos}gqIoWXXJw_SUEG|X{hKaijShM&T85ky8 zaI5fU2{AG-K;3RU`5?OvYnB*D&XF@{@&<0!$q!haCqH6VX3bIoiQZz0W-8SK0H7DQ AxBvhE delta 571 zcmew$J6n#mfn}-y|3p?z4UXKh+#J2M%#ta!Q#5*5@)C1Xr}S|6hWYw{1$)?X^HWN5 zQm0H-WS8Ra;eqhti!<_zN~TOMWE7wLnM0Y8f3g*?0aJ$XWM&=}M)Apin1d!4vMF;a zl=g6fj5nD)kH?FZB{4bKWU@YwETiV+yKE|Kx}`l#5r&iRG0QR<PPS+CoE*Zg$!IlM zk3)&kZt`Tl=*eQNu8f8t4IDnDJuD!DCePz^o1D)l&y*25*^tX;vK5od<W1bc6JJKK zu~lZ~r4&yN<dI{{o$Sk_#8^1_8IL+sM(N~h%&Lr)lNI^ACKvH2b2gRs@D>!MrkG4# zz^lWQ(Kb1dqnfdQaxse`<K)S8?9r2F^BOW`%$cmsZOXV{vIdU|<C4h|Y*CZznLH-f zvKn!2D(&F~ImLA1`=H5}c>~zEOHzwV;wSsFC^H_IT+L<3cx3Wf4rRs@lc%zIO`Pq| z3bM=yV%fFHYq<;=Z%y`LQDeL}IiFXBDdW*(8RnqL=NUaFpJnly{E$nD?Q3ZdQzbZ9 zIDbOzGMe~4hz)Fz>EwINGOSrlj0_Bu?{TV5=H+Fd?9Zvpn#BbY$zfLF%;IBYU?}Zj zjD)BZVq{>Ln4!;_B?eM3jnixLCRRP&EP1dZ_PheU;>`3sP}FCz^{{~185}*Vd8N4p Wl~XdfvXsHPc!DQSW_DpJ)dK)Lk+cT@ diff --git a/doc/tutorial/auto_examples/mvml/sg_execution_times.rst b/doc/tutorial/auto_examples/mvml/sg_execution_times.rst index bca9ff8..7b21dbe 100644 --- a/doc/tutorial/auto_examples/mvml/sg_execution_times.rst +++ b/doc/tutorial/auto_examples/mvml/sg_execution_times.rst @@ -5,8 +5,8 @@ Computation times ================= -**00:05.285** total execution time for **tutorial_auto_examples_mvml** files: +**00:04.803** total execution time for **tutorial_auto_examples_mvml** files: +-------------------------------------------------------------------------------+-----------+--------+ -| :ref:`sphx_glr_tutorial_auto_examples_mvml_plot_mvml_.py` (``plot_mvml_.py``) | 00:05.285 | 0.0 MB | +| :ref:`sphx_glr_tutorial_auto_examples_mvml_plot_mvml_.py` (``plot_mvml_.py``) | 00:04.803 | 0.0 MB | +-------------------------------------------------------------------------------+-----------+--------+ diff --git a/multimodal/datasets/data_sample.py b/multimodal/datasets/data_sample.py index 377eea8..c56ec4f 100644 --- a/multimodal/datasets/data_sample.py +++ b/multimodal/datasets/data_sample.py @@ -365,13 +365,18 @@ class MultiModalArray(np.ndarray, MultiModalData): views_ind = np.array([0, new_data.shape[1] // 2, new_data.shape[1]]) else: views_ind = np.array([0, new_data.shape[1]]) + elif not isinstance(views_ind, np.ndarray): + try: + views_ind = np.asarray(views_ind) + except Exception: + raise TypeError("format of views_ind is not list or nd array") except Exception as e: raise ValueError('Reshape your data') if new_data.ndim < 2 : raise ValueError('Reshape your data') if new_data.ndim > 1 and (new_data.shape == (1, 1) or new_data.shape == ()): raise ValueError('Reshape your data') - if views_ind.ndim < 2 and new_data.ndim <2 and views_ind[-1] > new_data.shape[1]: + if views_ind.ndim < 2 and new_data.ndim < 2 and views_ind[-1] > new_data.shape[1]: raise ValueError('Reshape your data') # views_ind_self = views_ind diff --git a/multimodal/kernels/lpMKL.py b/multimodal/kernels/lpMKL.py index ca61b8c..44a15eb 100644 --- a/multimodal/kernels/lpMKL.py +++ b/multimodal/kernels/lpMKL.py @@ -133,6 +133,7 @@ class MKL(BaseEstimator, ClassifierMixin, MKernel): self.weights = weights return self + def learn_lpMKL(self): """ function of lpMKL learning diff --git a/multimodal/kernels/mvml.py b/multimodal/kernels/mvml.py index 29df9f9..706bc28 100644 --- a/multimodal/kernels/mvml.py +++ b/multimodal/kernels/mvml.py @@ -136,7 +136,8 @@ class MVML(MKernel, BaseEstimator, ClassifierMixin): def _more_tags(self): return {'X_types': ["2darray"], 'binary_only': True, - 'multilabel' : False} + 'multilabel' : False, + } def fit(self, X, y= None, views_ind=None): """ @@ -457,6 +458,8 @@ class MVML(MKernel, BaseEstimator, ClassifierMixin): return np.take(self.classes_, pred) + + def _predict_mvml(self, test_kernels, g, w): """ -- GitLab