diff --git a/.idea/Multiview-Machine-Learning-OMIS.iml b/.idea/Multiview-Machine-Learning-OMIS.iml new file mode 100644 index 0000000000000000000000000000000000000000..6711606311e2664bd835f92b5c114681d2e284f5 --- /dev/null +++ b/.idea/Multiview-Machine-Learning-OMIS.iml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="PYTHON_MODULE" version="4"> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$" /> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> + <component name="TestRunnerService"> + <option name="PROJECT_TEST_RUNNER" value="Unittests" /> + </component> +</module> \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000000000000000000000000000000000000..97626ba45445dc9f3afa66e6a149914dc39e3df6 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Encoding"> + <file url="PROJECT" charset="UTF-8" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..5f7ced0530cb25681f34d3f9d0808968d276fb72 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.4.3 (/usr/bin/python3.4)" project-jdk-type="Python SDK" /> +</project> \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..e91da3bb396812cbe293bdd07b3945f8581cfbe5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/Multiview-Machine-Learning-OMIS.iml" filepath="$PROJECT_DIR$/.idea/Multiview-Machine-Learning-OMIS.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..94a25f7f4cb416c083d265558da75d457237d671 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000000000000000000000000000000000000..4a8d408d9639efdd5c3b9fe0e2546af17441b028 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,337 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ChangeListManager"> + <list default="true" id="b2cddca2-4818-4b60-b3ce-fb207e328b36" name="Default" comment=""> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/Code/MultiView/Mumbo/Mumbo.py" afterPath="$PROJECT_DIR$/Code/MultiView/Mumbo/Mumbo.py" /> + </list> + <ignored path="Multiview-Machine-Learning-OMIS.iws" /> + <ignored path=".idea/workspace.xml" /> + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> + <option name="TRACKING_ENABLED" value="true" /> + <option name="SHOW_DIALOG" value="false" /> + <option name="HIGHLIGHT_CONFLICTS" value="true" /> + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> + <option name="LAST_RESOLUTION" value="IGNORE" /> + </component> + <component name="ChangesViewManager" flattened_view="true" show_ignored="false" /> + <component name="CreatePatchCommitExecutor"> + <option name="PATCH_PATH" value="" /> + </component> + <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" /> + <component name="FavoritesManager"> + <favorites_list name="Multiview-Machine-Learning-OMIS" /> + </component> + <component name="FileEditorManager"> + <leaf> + <file leaf-file-name="Mumbo.py" pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/Code/MultiView/Mumbo/Mumbo.py"> + <provider selected="true" editor-type-id="text-editor"> + <state vertical-scroll-proportion="0.30229008"> + <caret line="11" column="97" selection-start-line="11" selection-start-column="97" selection-end-line="11" selection-end-column="97" /> + <folding> + <element signature="e#0#18#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </file> + </leaf> + </component> + <component name="Git.Settings"> + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> + </component> + <component name="IdeDocumentHistory"> + <option name="CHANGED_PATHS"> + <list> + <option value="$PROJECT_DIR$/Code/MultiView/Mumbo/Mumbo.py" /> + </list> + </option> + </component> + <component name="ProjectFrameBounds"> + <option name="y" value="25" /> + <option name="width" value="1280" /> + <option name="height" value="775" /> + </component> + <component name="ProjectLevelVcsManager" settingsEditedManually="false"> + <OptionsSetting value="true" id="Add" /> + <OptionsSetting value="true" id="Remove" /> + <OptionsSetting value="true" id="Checkout" /> + <OptionsSetting value="true" id="Update" /> + <OptionsSetting value="true" id="Status" /> + <OptionsSetting value="true" id="Edit" /> + <ConfirmationsSetting value="0" id="Add" /> + <ConfirmationsSetting value="0" id="Remove" /> + </component> + <component name="ProjectView"> + <navigator currentView="ProjectPane" proportions="" version="1"> + <flattenPackages /> + <showMembers /> + <showModules /> + <showLibraryContents /> + <hideEmptyPackages /> + <abbreviatePackageNames /> + <autoscrollToSource /> + <autoscrollFromSource /> + <sortByType /> + <manualOrder /> + <foldersAlwaysOnTop value="true" /> + </navigator> + <panes> + <pane id="Scratches" /> + <pane id="ProjectPane"> + <subPane> + <PATH> + <PATH_ELEMENT> + <option name="myItemId" value="Multiview-Machine-Learning-OMIS" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> + </PATH_ELEMENT> + </PATH> + <PATH> + <PATH_ELEMENT> + <option name="myItemId" value="Multiview-Machine-Learning-OMIS" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="Multiview-Machine-Learning-OMIS" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + </PATH> + <PATH> + <PATH_ELEMENT> + <option name="myItemId" value="Multiview-Machine-Learning-OMIS" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="Multiview-Machine-Learning-OMIS" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="Code" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + </PATH> + <PATH> + <PATH_ELEMENT> + <option name="myItemId" value="Multiview-Machine-Learning-OMIS" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="Multiview-Machine-Learning-OMIS" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="Code" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="MultiView" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + </PATH> + <PATH> + <PATH_ELEMENT> + <option name="myItemId" value="Multiview-Machine-Learning-OMIS" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="Multiview-Machine-Learning-OMIS" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="Code" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="MultiView" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="Mumbo" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + </PATH> + </subPane> + </pane> + <pane id="Scope" /> + </panes> + </component> + <component name="PropertiesComponent"> + <property name="last_opened_file_path" value="$PROJECT_DIR$" /> + </component> + <component name="RunManager"> + <configuration default="true" type="PythonConfigurationType" factoryName="Python"> + <option name="INTERPRETER_OPTIONS" value="" /> + <option name="PARENT_ENVS" value="true" /> + <envs> + <env name="PYTHONUNBUFFERED" value="1" /> + </envs> + <option name="SDK_HOME" value="" /> + <option name="WORKING_DIRECTORY" value="" /> + <option name="IS_MODULE_SDK" value="true" /> + <option name="ADD_CONTENT_ROOTS" value="true" /> + <option name="ADD_SOURCE_ROOTS" value="true" /> + <module name="Multiview-Machine-Learning-OMIS" /> + <option name="SCRIPT_NAME" value="" /> + <option name="PARAMETERS" value="" /> + <option name="SHOW_COMMAND_LINE" value="false" /> + <method /> + </configuration> + <configuration default="true" type="tests" factoryName="Attests"> + <option name="INTERPRETER_OPTIONS" value="" /> + <option name="PARENT_ENVS" value="true" /> + <envs /> + <option name="SDK_HOME" value="" /> + <option name="WORKING_DIRECTORY" value="" /> + <option name="IS_MODULE_SDK" value="false" /> + <option name="ADD_CONTENT_ROOTS" value="true" /> + <option name="ADD_SOURCE_ROOTS" value="true" /> + <module name="Multiview-Machine-Learning-OMIS" /> + <option name="SCRIPT_NAME" value="" /> + <option name="CLASS_NAME" value="" /> + <option name="METHOD_NAME" value="" /> + <option name="FOLDER_NAME" value="" /> + <option name="TEST_TYPE" value="TEST_SCRIPT" /> + <option name="PATTERN" value="" /> + <option name="USE_PATTERN" value="false" /> + <method /> + </configuration> + <configuration default="true" type="tests" factoryName="Doctests"> + <option name="INTERPRETER_OPTIONS" value="" /> + <option name="PARENT_ENVS" value="true" /> + <envs /> + <option name="SDK_HOME" value="" /> + <option name="WORKING_DIRECTORY" value="" /> + <option name="IS_MODULE_SDK" value="false" /> + <option name="ADD_CONTENT_ROOTS" value="true" /> + <option name="ADD_SOURCE_ROOTS" value="true" /> + <module name="Multiview-Machine-Learning-OMIS" /> + <option name="SCRIPT_NAME" value="" /> + <option name="CLASS_NAME" value="" /> + <option name="METHOD_NAME" value="" /> + <option name="FOLDER_NAME" value="" /> + <option name="TEST_TYPE" value="TEST_SCRIPT" /> + <option name="PATTERN" value="" /> + <option name="USE_PATTERN" value="false" /> + <method /> + </configuration> + <configuration default="true" type="tests" factoryName="Nosetests"> + <option name="INTERPRETER_OPTIONS" value="" /> + <option name="PARENT_ENVS" value="true" /> + <envs /> + <option name="SDK_HOME" value="" /> + <option name="WORKING_DIRECTORY" value="" /> + <option name="IS_MODULE_SDK" value="false" /> + <option name="ADD_CONTENT_ROOTS" value="true" /> + <option name="ADD_SOURCE_ROOTS" value="true" /> + <module name="Multiview-Machine-Learning-OMIS" /> + <option name="SCRIPT_NAME" value="" /> + <option name="CLASS_NAME" value="" /> + <option name="METHOD_NAME" value="" /> + <option name="FOLDER_NAME" value="" /> + <option name="TEST_TYPE" value="TEST_SCRIPT" /> + <option name="PATTERN" value="" /> + <option name="USE_PATTERN" value="false" /> + <option name="PARAMS" value="" /> + <option name="USE_PARAM" value="false" /> + <method /> + </configuration> + <configuration default="true" type="tests" factoryName="Unittests"> + <option name="INTERPRETER_OPTIONS" value="" /> + <option name="PARENT_ENVS" value="true" /> + <envs /> + <option name="SDK_HOME" value="" /> + <option name="WORKING_DIRECTORY" value="" /> + <option name="IS_MODULE_SDK" value="false" /> + <option name="ADD_CONTENT_ROOTS" value="true" /> + <option name="ADD_SOURCE_ROOTS" value="true" /> + <module name="Multiview-Machine-Learning-OMIS" /> + <option name="SCRIPT_NAME" value="" /> + <option name="CLASS_NAME" value="" /> + <option name="METHOD_NAME" value="" /> + <option name="FOLDER_NAME" value="" /> + <option name="TEST_TYPE" value="TEST_SCRIPT" /> + <option name="PATTERN" value="" /> + <option name="USE_PATTERN" value="false" /> + <option name="PUREUNITTEST" value="true" /> + <option name="PARAMS" value="" /> + <option name="USE_PARAM" value="false" /> + <method /> + </configuration> + <configuration default="true" type="tests" factoryName="py.test"> + <option name="INTERPRETER_OPTIONS" value="" /> + <option name="PARENT_ENVS" value="true" /> + <envs /> + <option name="SDK_HOME" value="" /> + <option name="WORKING_DIRECTORY" value="" /> + <option name="IS_MODULE_SDK" value="false" /> + <option name="ADD_CONTENT_ROOTS" value="true" /> + <option name="ADD_SOURCE_ROOTS" value="true" /> + <module name="Multiview-Machine-Learning-OMIS" /> + <option name="SCRIPT_NAME" value="" /> + <option name="CLASS_NAME" value="" /> + <option name="METHOD_NAME" value="" /> + <option name="FOLDER_NAME" value="" /> + <option name="TEST_TYPE" value="TEST_SCRIPT" /> + <option name="PATTERN" value="" /> + <option name="USE_PATTERN" value="false" /> + <option name="testToRun" value="" /> + <option name="keywords" value="" /> + <option name="params" value="" /> + <option name="USE_PARAM" value="false" /> + <option name="USE_KEYWORD" value="false" /> + <method /> + </configuration> + </component> + <component name="ShelveChangesManager" show_recycled="false" /> + <component name="TaskManager"> + <task active="true" id="Default" summary="Default task"> + <changelist id="b2cddca2-4818-4b60-b3ce-fb207e328b36" name="Default" comment="" /> + <created>1459504457506</created> + <option name="number" value="Default" /> + <updated>1459504457506</updated> + </task> + <servers /> + </component> + <component name="ToolWindowManager"> + <frame x="0" y="25" width="1280" height="775" extended-state="6" /> + <editor active="true" /> + <layout> + <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> + <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> + <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> + <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> + <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> + <window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> + <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> + <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" /> + <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" /> + <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> + <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> + <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> + <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> + <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> + <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> + <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> + <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> + </layout> + </component> + <component name="VcsContentAnnotationSettings"> + <option name="myLimit" value="2678400000" /> + </component> + <component name="XDebuggerManager"> + <breakpoint-manager /> + <watches-manager /> + </component> + <component name="editorHistoryManager"> + <entry file="file://$PROJECT_DIR$/Code/MultiView/Mumbo/Mumbo.py"> + <provider selected="true" editor-type-id="text-editor"> + <state vertical-scroll-proportion="0.30229008"> + <caret line="11" column="97" selection-start-line="11" selection-start-column="97" selection-end-line="11" selection-end-column="97" /> + <folding> + <element signature="e#0#18#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </component> +</project> \ No newline at end of file diff --git a/Code/MultiView/Mumbo/Mumbo.py b/Code/MultiView/Mumbo/Mumbo.py index 31ad2bbcdd37f5fb7734d061e043713382245a3b..616869858653ddd10b7f6b17e6cb87f99ea45df4 100644 --- a/Code/MultiView/Mumbo/Mumbo.py +++ b/Code/MultiView/Mumbo/Mumbo.py @@ -1,13 +1,109 @@ import numpy as np +import math def initialize(NB_CLASS, NB_VIEW, NB_ITER, DATASET_LENGTH, CLASS_LABELS): costMatrices = np.array([ np.array([ np.array([ - np.array([ 1 if CLASS_LABELS[exampleIndice]!=classe + np.array([1 if CLASS_LABELS[exampleIndice]!=classe else -(NB_CLASS-1) for classe in range(NB_CLASS) ]) for exampleIndice in range(DATASET_LENGTH) - ]) for viewIndice in range(NB_VIEW)]) for iteration in range(NB_ITER) + ]) for viewIndice in range(NB_VIEW)]) for iteration in range(NB_ITER+1) ]) - return costMatrices, generalCostMatrix, f \ No newline at end of file + generalCostMatrix = np.array([ + np.array([ + np.array([1 if CLASS_LABELS[exampleIndice]!=classe + else -(NB_CLASS-1) + for classe in range(NB_CLASS) + ]) for exampleIndice in range(DATASET_LENGTH) + ]) for iteration in range(NB_ITER) + ]) + fs = np.zeros((NB_ITER, NB_VIEW, DATASET_LENGTH, NB_CLASS)) + ds = np.zeros((NB_ITER, NB_VIEW, DATASET_LENGTH)) + edges = np.zeros((NB_ITER, NB_VIEW, DATASET_LENGTH)) + alphas = np.zeros((NB_ITER, NB_VIEW)) + predictions = np.zeros((NB_ITER, NB_VIEW, DATASET_LENGTH)) + generalAlphas = np.zeros(NB_ITER) + generalFs = np.zeros((NB_ITER, DATASET_LENGTH, NB_CLASS)) + return costMatrices, generalCostMatrix, fs, ds, edges, alphas, predictions, generalAlphas, generalFs + + +def trainWeakClassifers(classifer, costMatrices): + return + + +def computeEdge (predictionMatrix, costMatrix): + return np.sum(predictionMatrix*costMatrix) + + +def computeAlpha(edge): + return 0.5*math.log((1+edge)/(1-edge)) + + +def allViewsClassifyWell(predictions, pastIterIndice, NB_VIEW, CLASS_LABEL, exampleIndice): + bool = True + for viewIndice in range(NB_VIEW): + if predictions[pastIterIndice, viewIndice, exampleIndice]!=CLASS_LABEL: + bool = False + return bool + + +def updateDs(ds, predictions, CLASS_LABELS, NB_VIEW, DATASET_LENGTH, NB_CLASS, iterIndice): + for viewIndice in range(NB_VIEW): + for exampleIndice in range(DATASET_LENGTH): + for pastIterIndice in range(iterIndice): + if predictions[pastIterIndice, viewIndice, exampleIndice]==CLASS_LABELS[exampleIndice] or allViewsClassifyWell(predictions, pastIterIndice, NB_VIEW, CLASS_LABELS[exampleIndice], exampleIndice): + ds[pastIterIndice, viewIndice, exampleIndice]=1 + else: + ds[pastIterIndice, viewIndice, exampleIndice]=0 + return ds + + +def updateFs(predictions, ds, alphas, fs, iterIndice, NB_VIEW, DATASET_LENGTH, NB_CLASS, CLASS_LABELS): + for viewIndice in range(NB_VIEW): + for exampleIndice in range(DATASET_LENGTH): + for classe in range(NB_CLASS): + fs[iterIndice, viewIndice, exampleIndice, classe] = np.sum(np.array([alphas[pastIterIndice, viewIndice]*ds[pastIterIndice, viewIndice, exampleIndice] if predictions[pastIterIndice, viewIndice, exampleIndice]==CLASS_LABELS[exampleIndice] else 0 for pastIterIndice in range(iterIndice)])) + return fs + +def updateCostmatrices(costMatrices, fs, iterIndice, NB_VIEW, DATASET_LENGTH, NB_CLASS, CLASS_LABELS): + for viewIndice in range(NB_VIEW): + for exampleIndice in range(DATASET_LENGTH): + for classe in range(NB_CLASS): + if classe != CLASS_LABELS[exampleIndice]: + costMatrices[iterIndice, viewIndice, exampleIndice, classe] = math.exp(fs[iterIndice, viewIndice, exampleIndice, classe] - fs[iterIndice, viewIndice, exampleIndice, CLASS_LABELS[exampleIndice]]) + else: + costMatrices[iterIndice, viewIndice, exampleIndice, classe] = -1*np.sum(np.exp(fs[iterIndice, viewIndice, exampleIndice] - fs[iterIndice, viewIndice, exampleIndice, classe])) + + return costMatrices + + +def chooseView(predictions, generalCostMatrix, iterIndice, NB_VIEW): + edges = np.array([computeEdge(predictions[iterIndice, viewIndice], generalCostMatrix) for viewIndice in range(NB_VIEW)]) + bestView = np.argmax(edges) + return bestView, edges[bestView] + + +def updateGeneralFs(generalFs, iterIndice, predictions, alphas, DATASET_LENGTH, NB_CLASS, bestView, generalAlpha, CLASS_LABELS): + for exampleIndice in range(DATASET_LENGTH): + for classe in range(NB_CLASS): + generalFs[iterIndice, exampleIndice, classe]=np.sum(np.array([generalAlpha[pastIterIndice] if predictions[pastIterIndice, bestView, exampleIndice]==CLASS_LABELS[exampleIndice] else 0 for pastIterIndice in range(iterIndice)])) + return generalFs + + +def updateGeneralCostMatrix(generalCostMatrix, generalFs, iterIndice, DATASET_LENGTH, NB_CLASS, CLASS_LABELS): + for exampleIndice in range(DATASET_LENGTH): + for classe in range(NB_CLASS): + if classe != CLASS_LABELS[exampleIndice]: + generalCostMatrix[iterIndice, exampleIndice, classe]=math.exp(generalFs[iterIndice, exampleIndice, classe] - generalFs[iterIndice, exampleIndice, CLASS_LABELS[exampleIndice]]) + else: + generalCostMatrix[iterIndice, exampleIndice, classe]= -1 * np.sum(np.exp(generalFs[iterIndice, exampleIndice] - generalFs[iterIndice, exampleIndice, classe])) + return generalCostMatrix + +def mumbo(DATASET, CLASS_LABELS, NB_CLASS, NB_VIEW, NB_ITER, DATASET_LENGTH): + costMatrices, generalCostMatrix, fs, ds, edges, alphas, predictions, generalAlphas, generalFs = initialize(NB_CLASS, NB_VIEW, NB_ITER, DATASET_LENGTH, CLASS_LABELS) + for iterIndice in range(NB_ITER): + poulet = trainWeakClassifers(classifer, costMatrices) + for viewIndice in range(NB_VIEW): + edges[iterIndice, viewIndice] = computeEdge(predictions[iterIndice, viewIndice], costMatrices[]) \ No newline at end of file