-
Notifications
You must be signed in to change notification settings - Fork 10
/
README.html
1 lines (1 loc) · 16.6 KB
/
README.html
1
<html><head><title>KBS Emotion Classifier Documentation</title><style type="text/css">@import url('https://themes.googleusercontent.com/fonts/css?kit=chteh0fSOiSrmusp8u43YOkh9LkJjU7wDXwA7RhVCJc');ol{margin:0;padding:0}p{margin:0}.c10{vertical-align:top;width:156pt;border-style:solid;border-color:#000000;border-width:1pt;padding:5pt 5pt 5pt 5pt}.c12{vertical-align:top;width:156pt;border-style:solid;border-color:#000000;border-width:0pt;padding:5pt 5pt 5pt 5pt}.c15{max-width:468pt;background-color:#ffffff;padding:72pt 72pt 72pt 72pt}.c22{list-style-type:disc;margin:0;padding:0}.c0{height:11pt;direction:ltr}.c13{color:inherit;text-decoration:inherit}.c21{text-align:right;padding-bottom:10pt}.c7{padding-left:0pt;margin-left:36pt}.c2{text-align:justify;direction:ltr}.c3{color:#1155cc;text-decoration:underline}.c1{font-style:italic}.c5{font-family:Consolas}.c19{margin-left:54pt}.c17{border-collapse:collapse}.c11{font-family:Courier New}.c4{direction:ltr}.c9{line-height:1.0}.c20{height:18pt}.c14{text-align:center}.c8{margin-left:18pt}.c6{font-weight:bold}.c16{text-decoration:underline}.c18{text-align:justify}.title{padding-top:24pt;line-height:1.15;text-align:left;color:#000000;font-size:36pt;font-family:Arial;font-weight:bold;padding-bottom:6pt}.subtitle{padding-top:18pt;line-height:1.15;text-align:left;color:#666666;font-style:italic;font-size:24pt;font-family:Georgia;padding-bottom:4pt}body{color:#000000;font-size:11pt;font-family:Arial}h1{padding-top:24pt;line-height:1.15;text-align:left;color:#000000;font-size:18pt;font-family:Arial;font-weight:bold;padding-bottom:6pt}h2{padding-top:18pt;line-height:1.15;text-align:left;color:#000000;font-size:14pt;font-family:Arial;font-weight:bold;padding-bottom:4pt}h3{padding-top:14pt;line-height:1.15;text-align:left;color:#666666;font-size:12pt;font-family:Arial;font-weight:bold;padding-bottom:4pt}h4{padding-top:12pt;line-height:1.15;text-align:left;color:#666666;font-style:italic;font-size:11pt;font-family:Arial;padding-bottom:2pt}h5{padding-top:11pt;line-height:1.15;text-align:left;color:#666666;font-size:10pt;font-family:Arial;font-weight:bold;padding-bottom:2pt}h6{padding-top:10pt;line-height:1.15;text-align:left;color:#666666;font-style:italic;font-size:10pt;font-family:Arial;padding-bottom:2pt}</style></head><body class="c15"><p class="c4 title"><a name="h.kezio5kp0n6a"></a><span>KBS Lab-Exercise E019</span></p><p class="c4 subtitle"><a name="h.tagckwpo0fv8"></a><span>Emotion Classifier - based on Evidence Theory by Dempster-Shafer</span></p><p class="c0"><span></span></p><p class="c0"><span></span></p><p class="c0"><span></span></p><p class="c0"><span></span></p><p class="c0"><span></span></p><p class="c0"><span></span></p><p class="c0"><span></span></p><p class="c0"><span></span></p><p class="c0"><span></span></p><table cellpadding="0" cellspacing="0" class="c17"><tbody><tr><td class="c12"><p class="c4 c9"><span>Thilo Michael</span></p></td><td class="c12"><p class="c4 c9"><span>thilo.michael@gmail.com</span></p></td><td class="c12"><p class="c4 c9"><span>#0450945</span></p></td></tr><tr><td class="c12"><p class="c4 c9"><span>Jeffrey Jedele</span></p></td><td class="c12"><p class="c4 c9"><span>jeffrey.jedele@gmail.com</span></p></td><td class="c12"><p class="c4 c9"><span>#0491204</span></p></td></tr></tbody></table><h1 class="c4 c20"><a name="h.2bhpa3jatrjg"></a></h1><h1 class="c4"><a name="h.wxmptcpucgqu"></a><span>Revision History</span></h1><p class="c0"><span></span></p><table cellpadding="0" cellspacing="0" class="c17"><tbody><tr><td class="c10"><p class="c4 c9 c14"><span class="c6">Date</span></p></td><td class="c10"><p class="c4 c9 c14"><span class="c6">Comment</span></p></td><td class="c10"><p class="c4 c9 c14"><span class="c6">Author</span></p></td></tr><tr><td class="c10"><p class="c4 c9"><span>2012-03-04</span></p></td><td class="c10"><p class="c4 c9"><span>Initial</span></p></td><td class="c10"><p class="c4 c9"><span>Jeffrey Jedele</span></p></td></tr><tr><td class="c10"><p class="c4 c9"><span>2012-03-14</span></p></td><td class="c10"><p class="c4 c9"><span>CSV Reader & Tests</span></p></td><td class="c10"><p class="c4 c9"><span>Thilo Michael</span></p></td></tr></tbody></table><h1 class="c4"><a name="h.vrlrjwpxmu2s"></a><span>Abstract</span></h1><p class="c4"><span>With formal logic, every event can be </span><span class="c1">either true or false</span><span>. Bayesian Probability Theory extends this idea and allows us to assign a </span><span class="c1">likelihood of being true to </span><span class="c1 c6">every</span><span class="c1"> possible event</span><span>. Dempster-Shafer-Theory (DST) further generalizes this idea by:</span></p><ol class="c22" start="1"><li class="c4 c7"><span>allowing the assignment of probability masses to </span><span class="c1 c6">sets</span><span> of events rather than single events and</span></li><li class="c7 c4"><span>providing methods to </span><span class="c1 c6">combine</span><span> such distributions originating from different sources.</span></li></ol><p class="c4"><span>A common use case is the fusion of sensor values or measurements.</span></p><p class="c0"><span></span></p><p class="c4"><span>Another example where different measurements must be combined is the </span><span class="c1">classification of emotions based on pictures</span><span>. Digital image processing methods can be used to extract </span><span class="c1">several features</span><span> from pictures of human faces, e.g. mouth opening, eye aperture and number of furrows. These features allow the </span><span class="c1">assessment of the emotion</span><span> shown by the photographed face.</span></p><p class="c0"><span></span></p><p class="c4"><span>The goal of this exercise is to develop a emotion classifier that </span><span class="c1">reads a list of the above mentioned features</span><span> and uses DST to </span><span class="c1">find the most plausible emotion</span><span> shown in the picture. Pre-extracted example data of 50 pictures is provided for this exercise - the extraction of the features from actual images is </span><span class="c6">not</span><span> in scope.</span></p><p class="c0"><span></span></p><h1 class="c4"><a name="h.ar4j93x3x2ks"></a><span>Table of contents</span></h1><p class="c4 c8"><span class="c3"><a class="c13" href="#h.xpw2yivl5g8x">Architectural and Technical Overview</a></span></p><p class="c4 c8"><span class="c3"><a class="c13" href="#h.xhi5wtjmy1b">Build and Execution</a></span></p><p class="c19 c4"><span class="c3"><a class="c13" href="#h.2wt8hkvmgwf1">Invocation Example:</a></span></p><p class="c4 c19"><span class="c3"><a class="c13" href="#h.5omtmwhtc1hn">Output Example:</a></span></p><p class="c4 c8"><span class="c3"><a class="c13" href="#h.yi9hlc7chcp">API Documentation</a></span></p><p class="c4 c8"><span class="c3"><a class="c13" href="#h.iap9udh6dw2n">Test and Validation</a></span></p><p class="c4 c8"><span class="c3"><a class="c13" href="#h.a1bk2ykksdkg">Summary</a></span></p><p><span></span></p><h1 class="c4"><a name="h.xpw2yivl5g8x"></a><span>Architectural and Technical Overview</span></h1><p class="c4"><span>The project is realized in C++ because it provides the </span><span class="c1">flexibility</span><span> to create widely usable libraries and the </span><span class="c1">performance</span><span> needed for video applications. No external libraries are used. The application logic is distributed over several parts - each one of them is </span><span class="c1">reusable</span><span> on it’s own.</span></p><p class="c0"><span></span></p><p class="c4"><span>Following APIs are provided:</span></p><p class="c4"><span class="c16">dempstershafer.hpp/cpp</span></p><p class="c4"><span>Contains all the Dempster-Shafer-Logic like creating evidences, combining evidences and calculating beliefs and plausabilities.</span></p><p class="c0"><span></span></p><p class="c4"><span class="c16">learningclassificator.hpp/cpp</span></p><p class="c4"><span>Contains the logic used to classify if values are large or small. It uses online learning to adjust the classification with the classified values.</span></p><p class="c0"><span></span></p><p class="c4"><span class="c16">csvreader.hpp/cpp</span></p><p class="c4"><span>Contains the logic needed to read .csv data files.</span></p><p class="c0"><span></span></p><p class="c4"><span>The Dempster-Shafer Library is designed to be very fast and to provide an easy to use and easy to read API at the same time. First, a </span><span class="c11">DempsterShaferUniverse</span><span> object is created and all hypotheseses are added to it. The API uses “untyped” pointers (void-pointers) as hypotheseses, so every kind of object can be used. All comparisons rely only on the memory address. The </span><span class="c11">DempsterShaferUniverse</span><span> can then be used to create instances of the </span><span class="c11">Evidence</span><span> class</span><span>. These are used to add focal hypothesis-sets and to perform all other operations. Details can be found in the API documentation.</span></p><p class="c0"><span></span></p><p class="c4"><span>To detect emotions in videos, several features must be classified to be either large or small. The basic approach taken in this project, is to determine the mean of all values for a feature and classify values larger than the mean as large and values lesser than the mean as small. Because it’s impossible to determine correct means upfront in live-video-applications and because the values could change with perspectives, subjects, etc, the classifier also includes a simple form of online learning, which adjusts the means with every value that is classified.</span></p><p class="c0"><span></span></p><p class="c4"><span>To deal with the fact that a very large or a very small value is more significant than one near to the mean, the classifier returns a value between -1.0 (much lesser than mean) and +1.0 (much larger than mean). This value is also used as mass for the corresponding evidence. A multiplicative bias is added to the value to never allow 1.0 as mass, so the omega set is always contained and the conflict of combining two measure reduced.</span></p><p class="c0"><span></span></p><p class="c4"><span>The CSV Reader class offers a simple API to read information out of a .csv file with a specific structure. The delimiter of the file has to be a semicolon. The first row of the file has to contain the header information. The rest of the file are treated as the actual data. The data has to be convertible to the integer format. When creating a new </span><span class="c11">CSVReader</span><span> object the file is loaded and parsed so that the API calls are executed fast and without accessing the file itself.</span></p><h1 class="c4"><a name="h.xhi5wtjmy1b"></a><span>Build and Execution</span></h1><p class="c4"><span>If the </span><span class="c1">make</span><span> utility is available on the system, simply executing</span></p><p class="c4"><span class="c5">make all</span></p><p class="c4"><span>in the project folder will build the main executable and all tests.</span></p><p class="c0"><span></span></p><p class="c4"><span>To compile the main project without </span><span class="c1">make</span><span>, </span><span class="c11">main.cpp</span><span>, </span><span class="c11">dempstershafer.cpp</span><span>, </span><span class="c11">csvreader.cpp</span><span> and </span><span class="c11">learningclassificator.cpp</span><span> must be compiled and linked together.</span></p><p class="c0"><span></span></p><p class="c4"><span class="c1">make</span><span> creates an executable named </span><span class="c11">lab_exercise</span><span>. It can be run from command line and receives one file with test data as argument. The format of the data file must be similar to the two provided files (which are included in the project folder as well).</span></p><p class="c0"><span></span></p><p class="c4"><span>The project executable iterates over all frames in the data file and classifies the displayed emotion. The output is commented and should be self-explanatory.</span></p><p class="c0"><span></span></p><p class="c4"><span>Details about how the classification works can be found in the API documentation of </span><span class="c11">dempstershafer.hpp</span><span>.</span></p><p class="c0"><span></span></p><h3 class="c4"><a name="h.2wt8hkvmgwf1"></a><span>Invocation Example:</span></h3><p class="c4"><span class="c5">project_folder$ ./lab_exercise test_data.csv</span></p><h3 class="c4"><a name="h.5omtmwhtc1hn"></a><span>Output Example:</span></h3><p class="c4"><span class="c5">---------------------------------</span></p><p class="c4"><span class="c5">### Frame: 046 ###</span></p><p class="c4"><span class="c5">---------------------------------</span></p><p class="c4"><span class="c5">(-1.0: far below average, +1.0 far above average)</span></p><p class="c4"><span class="c5">Eye Aperture: 14 -> -0.19</span></p><p class="c4"><span class="c5">Mouth Opening: 12 -> -0.58</span></p><p class="c4"><span class="c5">Furrow Count: 443 -> -0.25</span></p><p class="c4"><span class="c5">---------------------------------</span></p><p class="c4"><span class="c5">(#: Belief, -: Plausability, .: nothing)</span></p><p class="c4"><span class="c5">Fear | -------------..................................... </span></p><p class="c4"><span class="c5">Surprise | -------------..................................... </span></p><p class="c4"><span class="c5">Disdain | ----------------.................................. </span></p><p class="c4"><span class="c5">Disgust | ####-----------------------------------........... </span></p><p class="c4"><span class="c5">Anger | ##########--------------------------------........ </span></p><p class="c4"><span class="c5">---------------------------------</span></p><p class="c4"><span class="c5">classified as: anger</span></p><p class="c4"><span class="c5">---------------------------------</span></p><h1 class="c4"><a name="h.yi9hlc7chcp"></a><span>API Documentation</span></h1><p class="c4"><span>The three application parts introduced above provide complete API documentation in the corresponding C++-header-files.</span></p><h1 class="c4"><a name="h.iap9udh6dw2n"></a><span>Test and Validation</span></h1><p class="c2"><span>The functionality of the three reusable APIs of the project are tested with unit tests. The interaction of the parts is tested by the lab exercise itself.</span></p><p class="c0 c18"><span></span></p><p class="c2"><span>The Dempster-Shafer Library unit test uses an Dempster-Shafer exercise of an old exam. It creates a set of supects which are added to the universe. Based on witness statements focal and omega sets are created. The reference value are taken from the exam with a maximum variance of 0.001.</span></p><p class="c0 c18"><span></span></p><p class="c2"><span>The Learning Classificator unit test creates a new classifier with an learning rate of 0.1. A feature with the value 100 is added. To test the classification a feature with the value of 100 is classified which results in zero variance. Then the online learning is tested by classifying two features with the value of 90. Each classification changes the average so that the two classifications don’t return the result. Then the cap is being tested by classifying a 1.0 (which results in an variance of -1.0) and a 10000 (which results in a variance of 1.0).</span></p><p class="c0 c18"><span></span></p><p class="c2"><span>The CSV Reader unit test uses the provided test_data.csv file to test the reading of a .csv file. The test assumes that the test_data.csv file is unmodified. First the test checks the correctness of the number of columns and rows. Then the correctness of the header is being tested. Then the extraction of the first row and the fetching of a value via it’s columns name is tested.</span></p><p class="c0 c18"><span></span></p><p class="c4"><span>To test the system as a whole, we calculated the results manually and then compared the values of the program with our manually evaluated results.</span></p><h1 class="c4"><a name="h.a1bk2ykksdkg"></a><span>Summary</span></h1><p class="c4"><span>The solution is fully functional and provides reasonable results for the given data. Yet, it may perform even better by adding </span><span class="c1">more features</span><span> and fine-tuning the </span><span class="c1">learning rate</span><span> of the classifier, the </span><span class="c1">initial averages</span><span> and the </span><span class="c1">bias for evidence masses</span><span>. To do this however, more preclassified test-data would be needed.</span></p><div><p class="c0 c21"><span></span></p></div></body></html>