### Friday, July 29, 2005

## Fuzzy Logic and Fuzzy SQL, or Richard's Big & Tall Shop

These explanations are based on my readings so far in Earl Cox's Fuzzy Modeling and Genetic Algorithms for Data Mining and Exploration

Fuzzy Logic, or Are you tall?

A more complete explanation can be found here, but here's a short version. Fuzzy Logic is a superset of Boolean Logic. In Boolean Logic, you're either in a set or not, and this can be represented by a membership function that returns either 0 or 1. In Fuzzy Logic, an item's membership in a set is measured in a continuous number from 0 to 1, determined by a membership function.

As an example, let's talk about "tall". A boolean membership function would be something like "if you're six feet or over, you're tall, else you're not". 0 or 1. A fuzzy membership function could be "if you're 5 feet or under, your tallness is 0. If you're 6 feet or over, your tallness is 1. From 5 feet to 6 feet it's a continuous slope". So, if someone is 5'9" their membership in the "tallness" set is .75.

In this logic system, a fuzzy AND of two numbers is the minimum of the numbers, a fuzzy OR is the maximum of the numbers, and a fuzzy NOT is 1 - a number. If you think of booleans as either 0 or 1, these operators are the same. Fuzzy is a superset of boolean.

Fuzzy SQL, or are you Tall and Heavy?

Let's say I'm opening a new chain of Big & Tall stores, and let's say I bought a database or broke into some insurer and have a huge list of names, addresses, heights and weights. I want to determine who in the database it would be worth my while to send a direct mailing. In regular SQL a query would look something like

select name, address from prospects where height => 74 and weight => 210;

That would give me a subset to work with, but what about someone who's 72 inches and 240? He's probably a pretty good prospect, but my boolean filtering would miss him. I could play with the cutoffs, but there would always be someone just outside, and if I move them too far I increase my chances of adding people who wouldn't be interested, and exclude the tall but not too heavy or heavy but not too tall.

Fuzzy SQL is a way of managing this problem. A Fuzzy SQL statement that we would use would look like

select name, address from prospects where height is tall and weight is heavy;

Looks kind of meaningless. What's "tall and heavy"? Well, first you start by computing individual membership numbers for the "tall" set and the "heavy" set using membership functions I wrote about above. Then with these individual numbers you compute what Cox calls a "Query Compatibility Index" (QCIX), which are different ways of combining the individual numbers. One way is the classic fuzzy AND, the minimum of the numbers. Another way is to average the numbers, perhaps with a weighted average, if for example I thought heavy was more important than tall. The Fuzzy SQL query should also return extra columns, such as the QCIX and perhaps the individual membership numbers calculated by the membership functions.

Sticking with a regular average would be OK for my direct mailing purposes. Tall and heavy would give a high QCIX, but also would very tall but not that heavy, and vice versa. So, the query is run and the rows sorted according to the QCIX, and we give a cutoff value for the QCIX below which rows are not returned. Print them envelopes, throw in a coupon and we're good to go.

The source code in the book is in Visual Basic, but what's the fun in that? What we really need is language that can add extra keywords such as the "is" and make it look like the rest of the language, that can take symbols like "tall" and "heavy" and associate them with membership functions....

Fuzzy Logic, or Are you tall?

A more complete explanation can be found here, but here's a short version. Fuzzy Logic is a superset of Boolean Logic. In Boolean Logic, you're either in a set or not, and this can be represented by a membership function that returns either 0 or 1. In Fuzzy Logic, an item's membership in a set is measured in a continuous number from 0 to 1, determined by a membership function.

As an example, let's talk about "tall". A boolean membership function would be something like "if you're six feet or over, you're tall, else you're not". 0 or 1. A fuzzy membership function could be "if you're 5 feet or under, your tallness is 0. If you're 6 feet or over, your tallness is 1. From 5 feet to 6 feet it's a continuous slope". So, if someone is 5'9" their membership in the "tallness" set is .75.

In this logic system, a fuzzy AND of two numbers is the minimum of the numbers, a fuzzy OR is the maximum of the numbers, and a fuzzy NOT is 1 - a number. If you think of booleans as either 0 or 1, these operators are the same. Fuzzy is a superset of boolean.

Fuzzy SQL, or are you Tall and Heavy?

Let's say I'm opening a new chain of Big & Tall stores, and let's say I bought a database or broke into some insurer and have a huge list of names, addresses, heights and weights. I want to determine who in the database it would be worth my while to send a direct mailing. In regular SQL a query would look something like

select name, address from prospects where height => 74 and weight => 210;

That would give me a subset to work with, but what about someone who's 72 inches and 240? He's probably a pretty good prospect, but my boolean filtering would miss him. I could play with the cutoffs, but there would always be someone just outside, and if I move them too far I increase my chances of adding people who wouldn't be interested, and exclude the tall but not too heavy or heavy but not too tall.

Fuzzy SQL is a way of managing this problem. A Fuzzy SQL statement that we would use would look like

select name, address from prospects where height is tall and weight is heavy;

Looks kind of meaningless. What's "tall and heavy"? Well, first you start by computing individual membership numbers for the "tall" set and the "heavy" set using membership functions I wrote about above. Then with these individual numbers you compute what Cox calls a "Query Compatibility Index" (QCIX), which are different ways of combining the individual numbers. One way is the classic fuzzy AND, the minimum of the numbers. Another way is to average the numbers, perhaps with a weighted average, if for example I thought heavy was more important than tall. The Fuzzy SQL query should also return extra columns, such as the QCIX and perhaps the individual membership numbers calculated by the membership functions.

Sticking with a regular average would be OK for my direct mailing purposes. Tall and heavy would give a high QCIX, but also would very tall but not that heavy, and vice versa. So, the query is run and the rows sorted according to the QCIX, and we give a cutoff value for the QCIX below which rows are not returned. Print them envelopes, throw in a coupon and we're good to go.

The source code in the book is in Visual Basic, but what's the fun in that? What we really need is language that can add extra keywords such as the "is" and make it look like the rest of the language, that can take symbols like "tall" and "heavy" and associate them with membership functions....

Comments:

<< Home

Well, that is one way to define fuzzy logic. There are other ways to do it as well, e.g. by moving from 2 values (yes / no) to three values (yes / no / unknown).

Private label contemt makes it possible to maintain multiple blogs or websites. You simply make minor modifications to the prvate label content and post it to your blog or web site.

Hello, my name is Long.

I am a final year IT student.

I have to develop a simple database to demonstrate a "Fuzzy Relational Database" application. I have seen some examples of fuzzy constraints to create a database and also query it. However, I could not found any information how to develop such a database on Oracle with those specific fuzzy constraints. The only closest thing to what I need is on this page: http://www.lcc.uma.es/~ppgg/FSQL/

Unfortunately, documentation is in Spanish. There is a download section below for an FSQL server for Oracle. I downloaded the file and it includes some files with .sql extension. But I do not know how to install that FSQL server so that I will be able to develop a database making use of those fuzzy comparators, for instance.

Has anyone worked with FSQL or developed a Fuzzy Relational Database?

Thanks in advance.

I am a final year IT student.

I have to develop a simple database to demonstrate a "Fuzzy Relational Database" application. I have seen some examples of fuzzy constraints to create a database and also query it. However, I could not found any information how to develop such a database on Oracle with those specific fuzzy constraints. The only closest thing to what I need is on this page: http://www.lcc.uma.es/~ppgg/FSQL/

Unfortunately, documentation is in Spanish. There is a download section below for an FSQL server for Oracle. I downloaded the file and it includes some files with .sql extension. But I do not know how to install that FSQL server so that I will be able to develop a database making use of those fuzzy comparators, for instance.

Has anyone worked with FSQL or developed a Fuzzy Relational Database?

**Please show me how to install FuzzySQL Server that run well!!!**Thanks in advance.

Hello, my name is Long.

I am a final year IT student.

I have to develop a simple database to demonstrate a "Fuzzy Relational Database" application. I have seen some examples of fuzzy constraints to create a database and also query it. However, I could not found any information how to develop such a database on Oracle with those specific fuzzy constraints. The only closest thing to what I need is on this page: http://www.lcc.uma.es/~ppgg/FSQL/

Unfortunately, documentation is in Spanish. There is a download section below for an FSQL server for Oracle. I downloaded the file and it includes some files with .sql extension. But I do not know how to install that FSQL server so that I will be able to develop a database making use of those fuzzy comparators, for instance.

Has anyone worked with FSQL or developed a Fuzzy Relational Database?

Thanks in advance.

Post a Comment
I am a final year IT student.

I have to develop a simple database to demonstrate a "Fuzzy Relational Database" application. I have seen some examples of fuzzy constraints to create a database and also query it. However, I could not found any information how to develop such a database on Oracle with those specific fuzzy constraints. The only closest thing to what I need is on this page: http://www.lcc.uma.es/~ppgg/FSQL/

Unfortunately, documentation is in Spanish. There is a download section below for an FSQL server for Oracle. I downloaded the file and it includes some files with .sql extension. But I do not know how to install that FSQL server so that I will be able to develop a database making use of those fuzzy comparators, for instance.

Has anyone worked with FSQL or developed a Fuzzy Relational Database?

**Please show me how to install FuzzySQL Server that run well!!!**Thanks in advance.

<< Home