Docs Navigation +

Getting Started

fuzzy.ai is an API that lets any developer easily add machine intelligence to their working code. fuzzy.ai lets you deploy fuzzy agents in the cloud that can help you make decisions automatically.


What is a fuzzy agent?

A fuzzy agent is a virtual intelligent machine that helps your code make complex decisions. The agent works like this:

  1. It receives one or more named input values, like ‘temperature’ or ‘numberOfShares’. Each value must be a number, like 80 or -1000.5.
  2. It converts these numbers into fuzzy set membership. For each fuzzy set you define, it determines the degree of membership of the input in the set. So, a temperature of 80°F might be about 70% “Pleasant” and about 20% “Hot”. This process is called fuzzification.
  3. It uses the rules you provide to do fuzzy inference on the input. If the agent has rules like “If the temperature is Pleasant, then the AirConditioning is Off” and “IF the temperature is Hot, then the Air-Conditioning is High”, then the AirConditioning fuzzy output will be 70% “Off” and 20% “High” for 80°F input value.
  4. Finally, it converts the fuzzy output into “crisp” numbers. The fuzzy output memberships are balanced out geometrically to find a good number that blends them all together. This process is called defuzzification. The crisp numbers are then returned to the caller as output.

When should you use fuzzy logic?

Fuzzy logic is great for certain kinds of applications. Fuzzy logic works great when…

  • … You already know your business rules. If you know that you want to give a big discount to new customers, and little to no discount to regular customers, then you don’t need a machine learning algorithm to derive that rule. Instead, you can get right to implementing it in fuzzy logic. You can always add new rules to a fuzzy agent; you don’t have to know all your rules before you get started.
  • … Your business rules use common-sense, qualitative terms. If you have a rule that a good sales representative should get a big bonus, then your rules are qualitative. They use common-sense intuitive terms that regular people understand. You can turn terms like good and big into fuzzy sets so that your fuzzy agent can understand them, too.
  • … Your rules can be contradictory. If you have one rule that says to give a high priority to sales prospects interested in your new product, and another rule that says to give a low priority to sales prospects with low annual revenue, what do you do when a low-revenue prospect is interested in your new product? Fuzzy agents are good at balancing contradictory rules to come up with reasonable compromises.
  • … You want to add, modify and remove rules easily. Because the fuzzy agents balance contradictory rules, you can easily add more rules, remove rules, or modify existing rules. As you develop more understanding of your problem space, or you have a changing situation on the ground, your fuzzy agent can change and adapt also.
  • … You have numerical input. Fuzzy logic only works with numbers as inputs. Sometimes it’s hard to see the numbers in your problems, but usually it’s easy. Let’s say you’re trying to figure out whether a salesman has been performing well in order to determine their monthly bonus. A number that you could use as input to the fuzzy agent is their sales revenue as a percentage of their sales quota. Or if you want to measure if a Tweet is about your company, you can use a regular expression to count the number of times your company name, initials, Twitter handle or domain name are mentioned in the text.
  • … You want to see how it works. The internal workings of your fuzzy agent, although complex, are relatively easy to audit. Because it’s using the fuzzy sets and fuzzy rules you provide, most of its decisions will “make sense” quickly. For those that aren’t obvious, you can review the intermediate values to determine why.
  • … You need to deploy quickly. Setting up a fuzzy agent with a half-dozen or so inputs and a few outputs should take under an hour. Integrating that fuzzy agent with your code can take only a few minutes. You can get good-quality intelligence working in your application very quickly.

Next steps

To get a fuzzy agent working in your software, you need to follow these steps.

  1. Create a new fuzzy agent. Use the New Agent tool to create and name your fuzzy agent. It will start off with an ID and some sample rules and input and output fuzzy sets.
  2. Configure your fuzzy agent. You have to configure your fuzzy agent to solve your particular business problems.
    1. Define your input variables. Pick the input variables you’ll use for your fuzzy agent. They should be numeric values. You need to define fuzzy sets that map input values into qualitative categories like “Hot” or “Interested” or “Old”.
    2. Define your output variables. What do you want to find out? You can define one or a few output variables. These have fuzzy sets too -- but they work in reverse, taking qualitative outputs from the fuzzy inference and defuzzifying them into crisp numbers.
    3. Define your fuzzy rules. Each rule takes an input fuzzy set -- like when a temperature is hot -- and maps it to an output fuzzy set, like when the air conditioning is on high. Usually, these fuzzy rules are really easy to figure out -- they feel like common sense.
  3. Test your fuzzy agent. You can test your fuzzy agent using the Web interface at fuzzy.ai. Try a few different values for your different inputs -- high and low, complementary and contradictory. If the output seems wrong, try adjusting your fuzzy sets to make sure they make sense.
  4. Call your fuzzy agent from your application code. This is the last step!
    1. Install the fuzzy.ai library for your programming language. There are Open Source libraries for many programming languages available at fuzzy.ai, on fuzzy.ai’s Github account, or from the package repository for your language. If there’s no library for your language, use the (simple) REST API directly.
    2. Prepare your input values. In your code, prepare the input values you’re going to pass to the fuzzy agent. Some may come from your database; others might be entered by the user. Still others may be calculated based on other non-numeric data.
    3. Call the fuzzy agent from your code. Using your API key and the agent ID, pass the input to the fuzzy agent, and get the output values it returns.
    4. Integrate the output. The output values may help you sort database records, or you may show them directly to the user. Or they may be terms in a larger calculation.
    5. NOTE: fuzzy.ai is a remote API, and a lot can go wrong between your computer and your fuzzy agent. You should try to have a sensible default to fall back to for any calculation you pass to a fuzzy agent.
  5. Modify your agent as needed. Often, you can change the fuzzy sets or fuzzy rules in your fuzzy agent without any change to your application code. If you add or remove input or output variables, though, you’ll need to handle those changes in your application code, too.