{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-fuzzy/scikit-fuzzy/issues/70","labels_url":"https://api.github.com/repos/scikit-fuzzy/scikit-fuzzy/issues/70/labels{/name}","comments_url":"https://api.github.com/repos/scikit-fuzzy/scikit-fuzzy/issues/70/comments","events_url":"https://api.github.com/repos/scikit-fuzzy/scikit-fuzzy/issues/70/events","html_url":"https://github.com/scikit-fuzzy/scikit-fuzzy/pull/70","id":118535084,"number":70,"title":"FEAT: High-level fuzzy control system API","user":{"login":"JDWarner","id":2184487,"avatar_url":"https://avatars.githubusercontent.com/u/2184487?v=3","gravatar_id":"","url":"https://api.github.com/users/JDWarner","html_url":"https://github.com/JDWarner","followers_url":"https://api.github.com/users/JDWarner/followers","following_url":"https://api.github.com/users/JDWarner/following{/other_user}","gists_url":"https://api.github.com/users/JDWarner/gists{/gist_id}","starred_url":"https://api.github.com/users/JDWarner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDWarner/subscriptions","organizations_url":"https://api.github.com/users/JDWarner/orgs","repos_url":"https://api.github.com/users/JDWarner/repos","events_url":"https://api.github.com/users/JDWarner/events{/privacy}","received_events_url":"https://api.github.com/users/JDWarner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":28,"created_at":"2015-11-24T05:39:02Z","updated_at":"2015-12-15T02:34:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scikit-fuzzy/scikit-fuzzy/pulls/70","html_url":"https://github.com/scikit-fuzzy/scikit-fuzzy/pull/70","diff_url":"https://github.com/scikit-fuzzy/scikit-fuzzy/pull/70.diff","patch_url":"https://github.com/scikit-fuzzy/scikit-fuzzy/pull/70.patch"},"body":"This PR adds what many people (see #69, #66, and multiple posts on the mailing list) have asked for: a much improved framework to implement fuzzy systems from end to end. \r\n\r\n* One major new dependency: **networkx**.\r\n* This API lives in `skfuzzy.control`, and primarily uses four classes\r\n    * `Antecedent`\r\n    * `Consequent`\r\n    * `Rule`\r\n    * `ControlSystem`\r\n\r\nPresently it's functional but sill a WIP. It is stable enough for other people to kick the tires at this point. If there are things missing you would like to see, speak up!\r\n\r\nThe major benefit is a simple yet very powerful API to build a fuzzy system, from input/antecedents to output/consequents, including all of the rules. Documentation will improve over the course of this PR, but here is the tipping problem implemented with this PR:\r\n\r\n``` python\r\nimport numpy as np\r\nimport skfuzzy as fuzz\r\n\r\n# New Antecedent/Consequent objects hold universe variables and membership functions\r\nquality = fuzz.Antecedent(np.arange(0, 11, 1), 'quality')\r\nservice = fuzz.Antecedent(np.arange(0, 11, 1), 'service')\r\ntip = fuzz.Consequent(np.arange(0, 26, 1), 'tip')\r\n\r\n# Auto-membership function population is possible with .automf(3, 5, or 7)\r\nquality.automf(3)\r\nservice.automf(3)\r\n\r\n# Custom membership functions can be built interactively with a familiar, Pythonic API\r\ntip['poor'] = fuzz.trimf(tip.universe, [0, 0, 13])\r\ntip['average'] = fuzz.trimf(tip.universe, [0, 13, 25])\r\ntip['good'] = fuzz.trimf(tip.universe, [13, 25, 25])\r\n\r\n# You can see how these look with .view()\r\nquality.view()\r\nservice.view()\r\ntip.view()\r\n\r\n# Rule objects connect one or more antecedent membership functions with \r\n# one or more consequent membership functions, using 'or' or 'and' to combine the antecedents.\r\n#   * rule1: \"If food is poor OR services is poor, then tip will be poor\r\n#   * rule2: \"If service is average, then tip will be average\r\n#   * rule3: \"If service is good OR food is good, then tip will be good\r\nrule1 = fuzz.Rule([quality['poor'], service['poor']], tip['poor'], kind='or')\r\nrule2 = fuzz.Rule(service['average'], tip['average'])\r\nrule3 = fuzz.Rule([service['good'], quality['good']], tip['good'])\r\n\r\n# Create a new ControlSystem with these rules added\r\n# Note: it is possible to create an empty ControlSystem() and build it up interactively.\r\ntipping = fuzz.ControlSystem([rule1, rule2, rule3])\r\n\r\n# Pass inputs to the ControlSystem using Antecedent labels with Pythonic API\r\n# Note: if you like passing many inputs all at once, use .inputs(dict_of_data)\r\ntipping.input['quality'] = 6.5\r\ntipping.input['service'] = 9.8\r\n\r\n# Crunch the numbers\r\ntipping.compute()\r\n\r\n# Output available as a dict, for arbitrary number of consequents\r\ntipping.output\r\n\r\n# Viewing the Consequent again after computation shows the calculated system\r\ntip.view()\r\n```\r\n\r\nA lot shorter than [the old way,](http://pythonhosted.org/scikit-fuzzy/auto_examples/plot_tipping_problem.html) and more intuitive!"},"comment":{"url":"https://api.github.com/repos/scikit-fuzzy/scikit-fuzzy/issues/comments/164624539","html_url":"https://github.com/scikit-fuzzy/scikit-fuzzy/pull/70#issuecomment-164624539","issue_url":"https://api.github.com/repos/scikit-fuzzy/scikit-fuzzy/issues/70","id":164624539,"user":{"login":"mohammedaljawad","id":15655076,"avatar_url":"https://avatars.githubusercontent.com/u/15655076?v=3","gravatar_id":"","url":"https://api.github.com/users/mohammedaljawad","html_url":"https://github.com/mohammedaljawad","followers_url":"https://api.github.com/users/mohammedaljawad/followers","following_url":"https://api.github.com/users/mohammedaljawad/following{/other_user}","gists_url":"https://api.github.com/users/mohammedaljawad/gists{/gist_id}","starred_url":"https://api.github.com/users/mohammedaljawad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohammedaljawad/subscriptions","organizations_url":"https://api.github.com/users/mohammedaljawad/orgs","repos_url":"https://api.github.com/users/mohammedaljawad/repos","events_url":"https://api.github.com/users/mohammedaljawad/events{/privacy}","received_events_url":"https://api.github.com/users/mohammedaljawad/received_events","type":"User","site_admin":false},"created_at":"2015-12-15T02:34:54Z","updated_at":"2015-12-15T02:34:54Z","body":"Dear Mr. Warner, \r\nI got this message after adding all my rules which are only nine.\r\nTraceback (most recent call last):\r\n  File \"mine4.py\", line 105, in <module>\r\n    trusting.compute()\r\n  File \"/home/mohammed/scikit-fuzzy/skfuzzy/control/controlsystem.py\", line 293, in compute\r\n    consequent.compute()\r\n  File \"/home/mohammed/scikit-fuzzy/skfuzzy/control/antecedent_consequent.py\", line 179, in compute\r\n    self.output = defuzz(self.universe, self.output_mf, mode)\r\n  File \"/home/mohammed/scikit-fuzzy/skfuzzy/defuzzify/defuzz.py\", line 132, in defuzz\r\n    assert tot_area != 0, 'Total area is zero in defuzzification!'\r\nAssertionError: Total area is zero in defuzzification!\r\n"}}