Skip to content
Snippets Groups Projects
Commit 2d7834ad authored by bbauvin's avatar bbauvin
Browse files

Mumbo classifier

parent b7797ab9
Branches
Tags
No related merge requests found
......@@ -2,6 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="b2cddca2-4818-4b60-b3ce-fb207e328b36" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/Code/MultiView/Mumbo/Classifiers/DecisionTree.py" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<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" />
......@@ -22,12 +24,12 @@
<favorites_list name="Multiview-Machine-Learning-OMIS" />
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="Mumbo.py" pinned="false" current-in-tab="true">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="Mumbo.py" pinned="false" current-in-tab="false">
<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" />
<state vertical-scroll-proportion="0.0">
<caret line="117" column="10" selection-start-line="117" selection-start-column="10" selection-end-line="117" selection-end-column="10" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
......@@ -35,8 +37,27 @@
</provider>
</entry>
</file>
<file leaf-file-name="DecisionTree.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/Code/MultiView/Mumbo/Classifiers/DecisionTree.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.16488549">
<caret line="6" column="47" selection-start-line="6" selection-start-column="47" selection-end-line="6" selection-end-column="47" />
<folding>
<element signature="e#0#24#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
......@@ -44,6 +65,7 @@
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/Code/MultiView/Mumbo/Mumbo.py" />
<option value="$PROJECT_DIR$/Code/MultiView/Mumbo/Classifiers/DecisionTree.py" />
</list>
</option>
</component>
......@@ -77,6 +99,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
......@@ -150,9 +173,34 @@
<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_ELEMENT>
<option name="myItemId" value="Classifiers" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
......@@ -283,6 +331,9 @@
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false" />
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="b2cddca2-4818-4b60-b3ce-fb207e328b36" name="Default" comment="" />
......@@ -296,25 +347,33 @@
<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="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="7" 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="Project" active="false" 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="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="7" 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="2" 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="7" 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="7" 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="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="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="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="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="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
......@@ -325,13 +384,33 @@
<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" />
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Code/MultiView/Mumbo/Mumbo.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="117" column="10" selection-start-line="117" selection-start-column="10" selection-end-line="117" selection-end-column="10" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Code/MultiView/Mumbo/Classifiers/DecisionTree.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.16488549">
<caret line="6" column="47" selection-start-line="6" selection-start-column="47" selection-end-line="6" selection-end-column="47" />
<folding>
<element signature="e#0#24#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
from sklearn import tree
from sklearn.multiclass import OneVsRestClassifier
def decisionTree(data, labels, arg):
classifier = OneVsRestClassifier(tree.DecisionTreeClassifier(max_depth=arg))
classifier.fit(data, labels)
return classifier, classifier.predict(data)
\ No newline at end of file
......@@ -9,7 +9,7 @@ def initialize(NB_CLASS, NB_VIEW, NB_ITER, DATASET_LENGTH, CLASS_LABELS):
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+1)
]) for viewIndice in range(NB_VIEW)]) if iteration==0 else np.zeros((NB_VIEW, DATASET_LENGTH, NB_CLASS)) for iteration in range(NB_ITER+1)
])
generalCostMatrix = np.array([
np.array([
......@@ -85,10 +85,10 @@ def chooseView(predictions, generalCostMatrix, iterIndice, NB_VIEW):
return bestView, edges[bestView]
def updateGeneralFs(generalFs, iterIndice, predictions, alphas, DATASET_LENGTH, NB_CLASS, bestView, generalAlpha, CLASS_LABELS):
def updateGeneralFs(generalFs, iterIndice, predictions, alphas, DATASET_LENGTH, NB_CLASS, bestView, generalAlphas, 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)]))
generalFs[iterIndice, exampleIndice, classe]=np.sum(np.array([generalAlphas[pastIterIndice] if predictions[pastIterIndice, bestView, exampleIndice]==CLASS_LABELS[exampleIndice] else 0 for pastIterIndice in range(iterIndice)]))
return generalFs
......@@ -101,9 +101,18 @@ def updateGeneralCostMatrix(generalCostMatrix, generalFs, iterIndice, DATASET_LE
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):
def mumbo(DATASET, CLASS_LABELS, NB_CLASS, NB_VIEW, NB_ITER, DATASET_LENGTH, classifier):
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)
poulet = trainWeakClassifers(classifier, costMatrices)
for viewIndice in range(NB_VIEW):
edges[iterIndice, viewIndice] = computeEdge(predictions[iterIndice, viewIndice], costMatrices[])
\ No newline at end of file
edges[iterIndice, viewIndice] = computeEdge(predictions[iterIndice, viewIndice], costMatrices[iterIndice+1, viewIndice])
alphas[iterIndice, viewIndice] = computeAlpha(edges[iterIndice, viewIndice])
ds = updateDs(ds, predictions, CLASS_LABELS, NB_VIEW, DATASET_LENGTH, NB_CLASS, iterIndice)
fs = updateFs(predictions, ds, alphas, fs, iterIndice, NB_VIEW, DATASET_LENGTH, NB_CLASS, CLASS_LABELS)
costMatrices = updateCostmatrices(costMatrices, fs, iterIndice, NB_VIEW, DATASET_LENGTH, NB_CLASS, CLASS_LABELS)
bestView, edge = chooseView(predictions, generalCostMatrix, iterIndice, NB_VIEW)
generalAlphas[iterIndice] = computeAlpha(edge)
generalFs = updateGeneralFs(generalFs, iterIndice, predictions, alphas, DATASET_LENGTH, NB_CLASS, bestView, generalAlphas, CLASS_LABELS)
generalCostMatrix = updateGeneralCostMatrix(generalCostMatrix, generalFs, iterIndice, DATASET_LENGTH, NB_CLASS, CLASS_LABELS)
return
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment