Top Banner
DETERMINING MEMBERSHIP FUNCTION VALUES TO OPTIMIZE RETRIEVAL IN A FUZZY RELATIONAL DATABASE Directed Research Report Directed By: Dr. Lorraine M. Parker Shweta Sanghi May 2005
104
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MemFunc.doc

DETERMINING MEMBERSHIP FUNCTION VALUES TO OPTIMIZE RETRIEVAL IN A FUZZY RELATIONAL

DATABASE

Directed Research Report

Directed By: Dr. Lorraine M. Parker

Shweta Sanghi

May 2005

Page 2: MemFunc.doc

Table of Contents

Page No.

1. Introduction……………………………………………………………………………………................1

1.1. Overview of Fuzzy Relational Databases……………………………......................................2

1.2. Overview of Previous work……………………………………………...................................5

2. Machine Learning Methods to Adjust Weights………………………………………………………….8

3. Methods of Constructing Membership Function……………………………………………………….10

3.1. The Fuzzy Linguistic Approach to Fuzzy Set……………………………………………….10

3.2. Fuzzification………………………………………………………........................................11

3.3. Membership function determination…………………………………………………………12

4. Project Description…………………………………………………………….......................................15

4.1. Testing…..……………………………………………………………………………………15

4.2. Results………………………………………………………………………………………..19

4.3. Obstacles……………………………………………………………………………………..23

5. Future Work………………………………………………………………………………………….…24

References…………………………………………………………………………………….………...25

Appendix A. Stored Procedures………………………………………………………………………...27

Appendix B. Source Code………………………………………………………....................................37

Appendix C. Statistical Method to Construct Membership Weight for Images………………………..79

Appendix D. Instructions to install the Fuzzy Database Research on the Local Machine....................101

Page 3: MemFunc.doc

1. Introduction

Computers have made tremendous progress in the past few decades. They are now

decidedly superior to human beings in speed and preciseness of calculation. However, computers

do not always satisfy users’ requirements. One reason for this dissatisfaction is the lack of

vagueness or imprecision, which are remarkable characteristics of humans. Imprecision is always

part of our thinking and reasoning.

As an approach, fuzzy database systems, which are able to represent and manipulate

imprecise information, have been presented. In these systems, imprecise information can be

stored using fuzzy linguistic terms (e.g. young, big) which are frequently used in daily

conversation. Although these words are ambiguous or uncertain, communities can agree on their

meanings.

This paper presents an overview of fuzzy relational database theory and analyzes the

previous work on a particular fuzzy database implementation [1] designed to retrieve images

using fuzzy constructs whose common-language descriptions were defined by the consensus of a

particular user community. Further, this paper describes research aimed at determining the best

way of setting the membership values via feedback from the community. The desire is to expand

the functioning level of the current prototype in order to implement “smart” database retrieval. It

is proposed to determine membership values using the Direct Rating method. This method of

determining membership function values (described in section 3.3) is then compared with the

original prototype to determine which method is better.

Page 4: MemFunc.doc

1.1 Overview of Fuzzy Relational Database

Conventional relational database systems are based on crisp data, which is precise. Fuzzy

relational databases extend the conventional relational database model to allow for representation

of imprecise data.

A fuzzy set is created to describe the linguistic variables in more detail. The linguistic

variable “age,” for instance, may have overlapping categories (members) of “young,” “very

young,” “middle age,” “old,” and “very old.” Once these categories or members are defined, the

fuzzy set is obtained, and a membership function is then developed for each member in the set.

Fuzzy logic and fuzzy sets were first introduced by Lotfi A. Zadeh [2]. Fuzzy sets were

derived by generalizing the concept of set theory. Fuzzy sets can be thought of as an extension

of classical sets. In a classical set (or crisp set), the objects in the set are called elements or

members of the set. An element x belonging to a set A is defined as x ∈ A, an element that is not

a member in A is noted as x ∉ A. A characteristic function or membership function µA(x) is

defined as an element in the universe U having a crisp value of 1 or 0. For every x ∈ U,

This can also be expressed as ( ) { }1,0∈xAµ

In crisp sets the membership function takes a value of 1or 0. For fuzzy sets, the membership

function takes values in the interval [0, 1]. The range between 0 and 1 is referred to as the

membership grade or degree of membership [5].

( )

∉∈

=A. for 0

A, for 1

x

xxAµ

Page 5: MemFunc.doc

A fuzzy set A is defined as:

Where µA(x) is a membership function belonging to the interval [0, 1]. Fuzzy set theory has

equivalent operations to those of crisp set theory. It includes functions such as equality, union

and intersection [1].

A Fuzzy Relational Database extends a normal relational database by adding fuzzy logic,

fuzzy data and membership functions. Membership functions can be defined as the degree of the

truthfulness of the proposition. For example, the predicate “John (X) is tall (A)” is represented

by number in unit interval µA(x). µA(x) = 0.7 means that John is tall to the degree 0.7. It is

different from probability.

The use of relations is one method of adding fuzzy selection criteria to a query. The rows

contain data that is interpreted according to the elements in them and their fuzziness. For

instance, consider the following height table.

Name Height

John 6’0’’

Bill 5’0’’

Janice 4’0’’

Fred 5’8’’

Meri 5’6’’

The elements in the height column are crisp values because they give the exact height of the

individual. A range query could be created to find people within a certain range of heights, but it

would be more convenient to define the range as a relation:

( )( ) ( ) [ ]{ }1,0,|, ∈∈= xAxxxA AA µµ

Page 6: MemFunc.doc

SELECT NAME FROM HEIGHTS

WHERE HEIGHT IS SHORT;

If SHORT was defined equal to 5’0’’ in the database, only “Bill” would be selected since he is

the only short person in the group. A query could also be formulated to include different sets of

range, that is, people who are VERY SHORT or of MEDIUM height. One way of approaching

this is to create a relation that defines SHORT and its relationship to the other heights. In effect,

we are defining the membership function for the fuzzy attribute SHORT.

Height Short Membership

4’00’’ 0.00

4’4’’ 0.10

4’8’’ 0.50

5’0’’ 1.00

5’6’’ 0.50

5’8’’ 0.10

6’0’’ 0.00

The query would then receive names from the list based on the threshold. For instance, if we set

our threshold for SHORT to be 0.50 or greater, then the query would return both Bill and Meri.

A querying language called SQLf [3] has been developed to support a wide range of

fuzzy queries (i.e., fuzzy predicates are introduced into the language wherever possible) while

also adhering to the conventions used in SQL. The basic principle of SQLf is the introduction of

fuzziness into the SELECT-FROM-WHERE block of SQL. Fuzziness is introduced at two levels

within the WHERE condition, both in the predicates themselves and in the way they are

combined (in the “connectors like and, or, etc”). To illustrate, consider these relations:

Page 7: MemFunc.doc

Employee (Emp#, E-name, Salary, Job, Age, City, Dept#) and

Department (Dept#, D-name, Manager, Budget, Location)

The query “Find the best 5 employees from Chicago who are well-paid and who are working in a

high budget department” may be expressed as:

1. SELECT E.Emp, E.Name

2. FROM Employee E,Department D

3. WHERE E.City=”Chicago” AND E.Salary=”well paid” AND D.Budget=”high”

4. AND E.Dept#=D.Dept#

In the above select statement, fuzziness is introduced in the line number 3 by the use of words

well and high.

1.2 Overview of previous work

A fuzzy relational database [1], which uses a natural language querying system to retrieve

images whose common-language descriptions are defined by the consensus of a particular user

community, was previously developed.

The architecture of this relational database system required two layers to process fuzzy

queries. The first layer was a RDBMS architecture and the second layer was a user interface

layer of stored procedures in SQL Server to process the fuzzy queries. To query the database,

SQLf was used. The syntax to query the database was

SELECT (attribute list)

FROM (relation List)

WHERE (fuzzy conditions)

Fuzzy conditions are conditions which use fuzzy predicates such as EYE_COLOR =

SLIGHTLY BLUE. For each image, each of the possible values of a fuzzy attribute and its

Page 8: MemFunc.doc

corresponding membership weights were listed in a tuple as shown in Table 1. The features used

in the implementation were “eye color” and “face width”. For eye color, possible values were

green, blue and brown. For face width, values were broad, average and narrow. A list of fuzzy

modifiers and their synonyms was developed. The modifiers selected (to be used with either

attribute) were “very”, “medium” and “slightly”. Each modifier was assigned a corresponding

range on the (0, 1) membership interval as shown in Table 2. Thus, using the two tables, a query

requesting people with “light blue eyes” would return all of the images with EYE_COLOR =

BLUE and a membership value between 0.0 and 0.29. To illustrate, an image of a person with

eyes that are predominantly green with just a hint of blue and no trace of brown could be

represented in the database as shown in Table 1.

IMAGE_ID EYE_COLOR WEIGHT (µ)1 GREEN 0.81 BLUE 0.31 BROWN 0.0

Table 1: Using Membership Values (Weights) for Each Attribute

Modifier Range_From Range_To Midpoint“Very” 0.75 1.0 0.87“Medium” 0.30 0.74 .52“Slightly” 0.0 0.29 .20

Table 2: Modifier Ranges and Midpoints

Random values between [0, 1] were assigned as weights or membership values to each

attribute of every image when the program was initialized for each particular user community.

Each modifier had a threshold value that was at the midpoint of the modifier’s range. Threshold

value was designed to steady each attribute’s membership value within the modifier ranges so it

accurately represented each community’s consensus. The users, after viewing the result of their

Page 9: MemFunc.doc

query, provided the feedback as to whether the image met their criteria or they believed the

image would be better defined using a stronger or a weaker modifier. According to the user’s

response, the weight of the attribute was increased or decreased by 0.01. For example, after

viewing the result of query EYE_COLOR = VERY BLUE, if the user decided that the image

should be defined by a stronger modifier then the weight was adjusted towards the threshold for

very blue but if the user decided that the image should be defined by a weaker modifier then the

weight was decreased by 0.01. Thus, by adjusting the membership weight so that it was as deep

in the range as possible (i.e., at the midpoint), the community opinion was strengthened with

concurring feedback. This method of constructing membership value from the subjective

information is denoted as the Random Method.

The Fuzzy Relational Database was designed to have a natural query language interface

where a user would enter a query such as, “List names of the persons with very brown eyes”. The

natural query language interface parsed the user query into the actual query and the

modifier/attribute pair. This data was stored into separate data files, which the fuzzy relational

database took as input. It then created a fuzzy query, queried the database and produced the

result. After getting user feedback, the membership weights were adjusted. This process went on

until a community consensus was reached.

2. Machine Learning Methods to Adjust Weights

The field of machine learning is concerned with the question of how to construct

computer programs that automatically improve with experience. Machine learning is said to

occur in a program that can modify some aspect of itself, often referred to as its state, so that on

a subsequent execution with the same input, a different (hopefully better) output is produced.

Page 10: MemFunc.doc

Machine Learning is defined as, “A computer program is said to learn from Experience E

with respect to some class of tasks and performance measure P, if its performance at tasks in T,

as measured by P, improves with experience E.”[4]

Learning systems learn through use of some sort of feedback or evolution or reaction to

its response of experience E. Broadly speaking machine learning can be divided into two types

Supervised Learning: Supervised learning is where the learning algorithm is provided

with a set of inputs for the algorithm along with the corresponding correct outputs, and

learning involves the algorithm comparing its current actual output with the correct or

target outputs, so that it knows what its error is, and modify things accordingly. For

example, supervised learning is used in back propagation algorithm to train neural

networks.

Unsupervised learning: Unsupervised learning is where the system is not told the "right

answer". It is not trained on pairs consisting of an input and the desired output.

Unsupervised clustering algorithms can be used to train the system.

The purpose of the current fuzzy database implementation is to retrieve images by using

fuzzy queries whose common-language descriptions are defined by the consensus of a particular

user community. In everyday life, these language descriptions are subjective. A person may be

described as having dark brown hair and a narrow face by one user and other user can describe

that person differently. Therefore the terms like “dark brown” and “narrow” are not objective

definitions but rather reflect a person’s (or a group’s) definition of those terms. These definitions

depend on factors like culture and experience, and may change over time. Although it is difficult

Page 11: MemFunc.doc

to design a system which satisfies each user’s perception of facial definitions, a consensus can be

reached so that it satisfies most users of that community. Since learning is based on feedback

provided by the user community and the system does not know the right answer, it is using

unsupervised learning.

According to the definition of machine learning, the system can defined as

• Task T: Retrieval of images according to the criteria defined

• Performance Measure P: Percent of community satisfaction

• Training Experience E: User feedback

3. Methods of Constructing Membership Function

A membership function (MF) is a curve that defines how each point in the input space is

mapped to a membership value (or degree of membership) between 0 and 1. The input space is

sometimes referred to as the universe of discourse, a fancy name for a simple concept.

Page 12: MemFunc.doc

Summary of Membership Functions

• Fuzzy sets describe vague concepts (fast runner, hot weather, weekend days).

• A fuzzy set admits the possibility of partial membership in it. (Friday is sort of a weekend

day, the weather is rather hot).

• The degree an object belongs to a fuzzy set is denoted by a membership value between 0

and 1. (Friday is a weekend day to the degree 0.8).

• A membership function associated with a given fuzzy set maps an input value to its

appropriate membership value.

3.1 The Fuzzy Linguistic Approach to Fuzzy Set

The linguistic approach is Zadeh’s original idea [2]. It is based on two main concepts: the

linguistic variable and the linguistic term. A linguistic variable represents a concept that is

measurable in some way, either objectively or subjectively, like temperature or will. Linguistic

variables are characteristics of an object or situation. Linguistic terms rate the characteristic

denoted by one linguistic variable. A linguistic term is a fuzzy set, and the linguistic variable

defines its domain.

Every adequate representation of fuzzy sets involves the basic understanding of five

related conceptual symbols:

• the set of elements θєΘ, as in “image” from “group of images”

• the linguistic variable V, that is a label for one of the attributes of the elements

θєΘ, as in “eye color” of “image”;

• the linguistic term A, which is an adjective or adverb describing the linguistic

variable, which is a subjective measure of V, as in “blue” describing “eye color”;

Page 13: MemFunc.doc

• a referential set X С R, that is a measurable numerical interval, for the particular

attribute V, as in “[0,100] blue” for “eye color”;

• a subjective numeric attribution µA(θ), of the membership value, i.e., the

membership degree of the element θ, labeled by the linguistic variable V as

described by A.

3.2 Fuzzification

The first step in every fuzzy system consists of converting the inputs from the traditional

crisp universe to the fuzzy universe. This step is known as fuzzification or fuzzy encoding, and

identifies that there is an acceptance of uncertainty assigned to the input value. Every input value

is associated with a linguistic variable. For each linguistic variable, it should be assigned a set of

linguistic terms that subjectively describe the variable. Most of the time, linguistic terms are

words that describe the magnitude of the linguistic variable, as “hot” and “large”, or how far they

are from a goal value, as in “exact” or “far”. Each linguistic term is a fuzzy set and has its own

membership function. It is expected that for a linguistic variable to be useful, the union of the

support of the linguistic terms cover its entire domain. It is also expected that there some

intersection between the support of linguistic terms that describe similar concepts. So, when

talking about temperature, for instance, one would expect to see some values that will be, at the

same time, described as “cold” and “freezing”. Usually, adjacent linguistic terms have 10 to 50%

superposition. Given all the fuzzy sets which correspond to each linguistic variable, fuzzification

means to determine the membership value of each input value in each fuzzy set.

3.3 Membership Function Determination

Page 14: MemFunc.doc

Mainly, there are six methods used in experiments with the aim of constructing

membership functions [14]:

Polling: do you agree that John is tall? (Yes/No)

Direct rating (point estimation): classify John according to his tallness. In general, the

question is: “How F is a?”

Reverse Rating: identify the person who is tall to the degree 0.6? In general,

identify a who is F to the degree µF (a).

Interval Estimation (set valued statistics): give an interval in which you think the height of

John lies.

Membership function exemplification: What is the degree of belonging of John to the set

of tall people? In general, “To what degree a is F?”

Pairwise comparison: which person John or Joe, is taller (and by how much?)

1: Polling

In polling one subscribes to the point of view that fuzziness arises from interpersonal

disagreements. The question “Do you agree that a is F?” is asked to different individuals. The

answers are polled and an average is taken to construct the membership function. Polling is also

one of the natural ways of eliciting membership functions for the likelihood interpretation.

2: Direct Rating

Direct rating seems to be the most straightforward way to come up with a membership

function. This approach subscribes to the point of view that fuzziness arises from individual

subjective vagueness. The subject is required to classify a with respect to F over and over again

in time. The experiment has to be carefully designed so that it will be hard for the subject to

Page 15: MemFunc.doc

remember past answers. The same question is asked to the same subject over and over again, and

the membership is constructed using the assumption of probabilistic errors and by estimating a

few key parameters as is usual for this type of construction. Chameau & Santamarina (1987a)

use several subjects and aggregate their answers as opposed to asking a single subject same

questions over and over.

3: Reverse Rating

In this method, the subject is given a membership degree and then asked to identify the

object for which that degree corresponds to the fuzzy term in question. This method can be used

for individuals by repeating the same question for the same membership function as well as for a

group of individuals. Once the subject’s (or subjects’) responses are recorded, the conditional

distributions can be taken to be normally distributed and the unknown parameters (mean and

variance) can be estimated as usual. This method also requires evaluations to be made on at least

interval scales to determine membership function.

4: Interval Estimation

The subject is asked to give an interval that describes the Fness of a. Let Ii be the set-

valued observation (the interval) and mi the frequency with which Ii is observed. Then R = (Ii;

mi) defines a random set. It means that mi population is defining the interval in which the fuzzy

term lies. The rest of the population defines the different interval for the Fness of a.

5: Membership Exemplification

The subject is asked to write the degree which is appropriate for “large”, “very

large”, “small” on scale of 0 to 100. The same question is asked to the group of individuals. The

results are analyzed to determine membership function.

Page 16: MemFunc.doc

6: Pairwise Comparison

The subject is asked a question “which is a better example of a bird: an eagle or a

pelican?”, and based on answer (say, an eagle is chosen) to that question, another question is

asked: “How much more of a bird is an eagle than pelican?” Weights are then derived from the

principal eigenvector of the square reciprocal matrix of pairwise comparison between all

contributing attributes.

In all of the elicitation methods, Chameau & Santamarina [15] obtain the membership

functions based on averaging or aggregation of the responses from several assessors. In that

sense they do not subscribe to the individualistic interpretation of fuzziness. Chameau &

Santamarina justify this approach by assuming that fuzziness is a property of the phenomenon

rather than a property attributed by the observer. All of the above described approaches are

called manual methods of determining membership function because expert/experts are required

to obtain membership function. All the manual approaches suffer from the deficiency that they

rely on very subjective interpretation of words, the foibles of human experts and generally all the

knowledge acquisition problems that are well documented [6] with knowledge based systems.

4. Project Description

This research aims to determine the best way of setting the membership values using

feedback from the community for the fuzzy relational database. The purpose of the fuzzy

database implementation is to retrieve images by using fuzzy queries whose common-language

Page 17: MemFunc.doc

descriptions are defined by the consensus of a particular user community. The fuzzy set, which is

presentation of fuzzy attribute values of the images, is determined through membership function.

How best to determine the membership function is the first question to answer? It is

proposed to construct membership values by the Direct Rating method. This approach subscribes

to the point of view that fuzziness arises from individual subjective vagueness. This method of

constructing the membership function will then be compared with the present prototype which

uses the random method as explained in section 1.2 to determine which method gives the most

user satisfaction with minimum feedback from the community.

4.1. Testing

The previous implementation was modified to alter the method of assigning the

membership value, which was based on direct rating method, for the blue eye color attribute of

each image. User feedback for both the prototypes was taken in two sessions, which were

training and testing. The user interface of both the prototypes was altered to make it user

friendly. The source code with changes can be referenced in Appendix B.

In the direct rating method, random weights were not assigned to the blue eye color

attribute of the images as was done in previous prototype [1]. In the training session, the question

put to the community was “How blue are the eyes? and they responded using a simple indicator

on a sliding scale. The left most bar on the sliding scale represented that the eyes were not blue

whereas the right most bar on the sliding scale represented that the eye were 100% blue. The

training session was comprised of 21 people. The values given for blue eye color attribute were

recorded into the database as shown in Figure 1.

Page 18: MemFunc.doc

Image 1 Scores 0-29 30-74 75-1000 1 0 025 1 0 033 0 1 039 0 1 044 0 1 046 0 1 052 0 1 053 0 1 054 0 1 062 0 1 065 0 1 069 0 1 070 0 1 071 0 1 074 0 1 075 0 0 186 0 0 193 0 0 199 0 0 1100 0 0 1100 0 0 1

2 13 6

Frequency Distribution of Image ID 1

0

2

4

6

8

10

12

14

0-29 30-74 75-100

Frequency Range

Freq

uenc

y

Figure 1: Scores and Distribution for Image 1

The first column in Figure 1 represents the community’s view of the degree to which

image 1 had blue eyes. Frequency distribution method was chosen to summarize the community

feedback for each attribute in order to achieve maximum user satisfaction. A frequency

distribution table was created that grouped scores into non overlapping intervals called frequency

ranges. The frequency ranges were chosen based on range values of the very (75-100), medium

(30-74), slightly (0 -29) modifiers. The number of scores that fell into each frequency range was

calculated. The counts, or frequencies, of scores were then listed in their respective frequency

ranges. The base of the rectangles in the histogram corresponds to the frequency ranges, and

Page 19: MemFunc.doc

height of each rectangle equals the number of scores in that range. The frequency histogram for

each of the 40 images can be referenced in Appendix C. Based on Table 2; each image acquired

the threshold membership value for the maximum frequency range. For example, 13 people out

of 21 chose the medium blue eye color for the image 1, while 6 people out of 21 said that the

image had very blue eyes. Therefore, the membership value of 0.52 was assigned to the blue eye

color attribute of the image id 1. Weights were similarly assigned for each of the 40 images as

shown in Figure 2.

In the random method, random weights were assigned initially to the blue eye color

attribute of the images. The training session which comprised of 21 people was conducted to

learn membership weights. Based on the community feedback, membership weight of the blue

eye color attribute of each image was adjusted as explained in section 1.2.

Page 20: MemFunc.doc

Figure 2: Membership Weights for Direct Rating Method

A testing session was conducted to compare both methods of eliciting membership values

and to determine which method gives the better community satisfaction. In the testing session,

Page 21: MemFunc.doc

the fuzzy relational database was queried for “slightly”, “medium” and “very” blue eye color of

the images based on the membership value assigned by the random method and the direct rating

method. The community was asked whether, they were satisfied with the result or not. The

percentage of user satisfaction was calculated. The percentage of user satisfaction of random

method and direct rating method can be referenced in Appendix C. The line graph in figure 3

represents the comparison of user satisfaction for 40 images. For example, for image id 1, user

satisfaction was 89% for the direct rating method and 67% for the random method.

% of User Satisfaction Comparison

0

20

40

60

80

100

120

1 4 7 10 13 16 19 22 25 28 31 34 37 40

Image ID

% U

ser

Sat

isfa

ctio

n

RandomMethodDirect RatingMethod

Figure 3: Comparison of Percentage of user satisfaction for all images

4.2 Results

The proposed direct rating method was the better method to determine membership

function values, compared to the random method. The reasons are:

Page 22: MemFunc.doc

• The direct rating method is more efficient because it reaches consensus with fewer

iterations. For example, the random method can assign 1.0 membership value initially to

an image whose eyes are not blue. It would take at least 100 feedbacks to reach a weight

of 0.0, provided each user’s perception is the same.

• It is based on maximum vote. The threshold value is assigned based on the maximum

value of frequency distribution table.

• It achieved a higher user satisfaction in 80% cases compared to random method.

• It is efficient even for smaller communities. For random method to be efficient in all

cases, the community should comprise of at least 100 people. The extreme case for

random method will be when the random method assigns 1.0 membership value initially

to an image whose eyes are not blue. It would take at least 100 feedbacks to assign 0.0

weights, provided each user’s perception is same.

However, there were many factors that affected the results.

• The images were described by the community, not the database designers. Thus, it was

expected that each user could describe the same images differently. Therefore a term like

“very blue eye” is not objective but rather reflects a person’s definition of those terms.

These definitions depend on factors like culture and experience, and may change over

time.

• For those images that got less than 25% user satisfaction, the pictures were not very clear.

It was very hard to make out the eye color. It would have been better if the focus of the

image was more on eye. This was true for both methods. But in this real world, perfect

pictures can not be guaranteed in such a system.

Page 23: MemFunc.doc

• There were some images whose user satisfaction was between 35% and 70% for the

direct rating method because the frequency distribution of the attribute for two ranges

was very close. Although, the maximum user’s satisfaction range was picked, but over all

satisfaction was low. For example see Figure 4. Nine users out of 21 said that the eyes

were medium blue, and 10 out of 21 said that the eyes were slightly blue eye. The

membership weight of 0.2 was assigned to the image to reach maximum satisfaction but

testing revealed 44% of user satisfaction.

Image 33 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 014 1 0 016 1 0 020 1 0 025 1 0 030 0 1 033 0 1 042 0 1 050 0 1 056 0 1 056 0 1 067 0 1 069 0 1 073 0 1 090 0 0 195 0 0 1

10 9 2

Frequency Distribution of Image ID 33

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Figure 4

It is suggested that frequency distribution should be recalculated by removing 0 score

value of the attribute. For example in case of Figure 4, after removing 0 score, 4 out of 15

users said that the eyes were slightly blue eye, and 9 users out of 15 said that the eyes

Page 24: MemFunc.doc

were medium blue. The membership weight of 0.52 could be assigned to the image 33.

This requires further testing.

• The community which trained the prototype and the tested the prototype was not same.

21 users trained the both prototypes. 27 users tested the direct rating method and 15 users

tested the random method. The varied community may be the one reason for not reaching

community’s consensus more than 80% for all images. There may be other reasons such

as communities may never agree that often. This requires further testing.

• The community did not define the range of modifiers. It was defined by the database

designer. One user can describe range between 25 and 35 as slightly and other user can

describe the same range as medium. One strategy could be to designate certain user as

“expert” whose opinions would be weighted more heavily than the rest of the group’s.

The expert would define the range of modifiers and educate the rest of community about

the range of modifiers. Other strategy could be learning the range of modifiers from the

community feedback. This requires further investigation.

• The slightly modifier includes those images that have no blue eye color. The results

would have improved by excluding images with no blue eye color. For example in Figure

4, only six people would have described the image as slightly, if 0 score is ignored.

It is believed that if these factors were taken into account the direct rating method would

reach higher satisfaction. But this requires more study.

Page 25: MemFunc.doc

4.3 Obstacles

There were many obstacles that had to be overcome to conduct this research. The main

obstacle was learning and installing Microsoft .Net and SQL Server. Installation of the previous

prototype on the local machine caused lots of problems because of inadequate documentation.

Instructions to install this application locally can be referenced in Appendix D. Problems like

changes in the user interface to use a slide bar, making the user interface friendly to conduct

experiments, finding a way to display all images were other challenges that took time.

Page 26: MemFunc.doc

5. Future Work

The research raised some questions, which can be explored in future fuzzy relational

database research.

One suggested area is in using unsupervised machine learning techniques such as Least

Mean Square algorithm or clustering techniques to adjust weights in order to reach maximum

satisfaction. Different strategies can be used to train the system. One strategy could be to

designate certain users as “experts” by community whose opinions would be weighted more

heavily than the rest of the group’s. Rather than using random values, these experts would

initially be shown the images and their descriptions would establish the initial membership

values; the remaining users would then modify the weights from that point forward. Other

strategy could be start learning by initializing weights with random values and learn until certain

percentage of satisfaction reached, then stop learning and again start learning after certain period

like after a month or year or after the level of dissatisfaction reaches a particular percentage.

Another area of future interest could be improvements in user interface. Instead of

showing whole image, the focus can be more on attribute in study. For example, while training

images for eye color, if focus would have been on eyes then results may have been better. User

interface should be improved to make it more users friendly.

Another area of interest would be defining the range of modifiers. One strategy could be

to designate certain user as “expert” whose opinions would be weighted more heavily than the

rest of the group’s. The expert would define the range of modifiers and educate the rest of

community about the range of modifiers. Other strategy could be learning the range of modifiers

from the community feedback. Another area of future interest would be to find the best method

to handle unclear pictures.

Page 27: MemFunc.doc

References

[1] Joy,Karen and Dattatri, Smita ,” Implementing a Fuzzy Relational Database and Querying

System With Community Defined Membership Values “, VCU Directed Research Report,

November 2004.

[2] Zadeh, L. A. (1965). “Fuzzy Sets.” Information and Control, 8, 338-353.

[3] Bosc, P. & Pivert, O. (1995). ”SQLf: A Relational Database Language for Fuzzy Querying.”

IEEE Transactions on Fuzzy Systems, 3, 1-17.

[4] Mitchell, Tom M. “Introduction to Machine Learning” in Machine Learning (7th ed.),

McGraw Hill Publishers, 2-5.

[5] Turksen, I.B., Measurement of membership functions and their acquisition, Fuzzy Sets and

Systems, 40:5--38, 1991.

[6] Motoda, H., Mizoguchi, R., Boose, J. H., and Gaines, B. R., Knowledge Acquisition Tools,

Methods, and Mediating Representations, Proceedings of the First Japanese Knowledge

Acquisition for Knowledge-Based Systems Workshop: JKAW-90, Ohmsha, Japan.

[7] Norwich, A.M. & Turksen, I.B., The construction of membership functions, Fuzzy Sets and

Possibility Theory: Recent Developments.

[8] Watanabe, N., Statistical Methods for Estimating Membership Functions, Japanese Journal of

Fuzzy Theory and Systems, 5(4), 1979.

[9] John, R. I., Fuzzy Inference Systems: Problems and Some Solutions, De Montfort University

Computing Science Research, http://www.cse.dmu.ac.uk/%7Erij/newrep/newrep.html

[10] Eminov, Mubariz, Querying a Database by Fuzzification of Attribute Values.

[11] Wang, Li-Juan & Wang, Xi-Zhao & Ha, Ming-Hu & Yin-Shan, Mining the Weights of

Similarity Measure Through Learning.

Page 28: MemFunc.doc

[12] Tashiro, H. & Ohki, N. & Yokoyama, T. & Matsushita, Y., Managing Subjective

Information in Fuzzy Database Systems, 156 – 161.

[13] Baklarz, George, Using Neural Nets to Optimize Retrieval in a Fuzzy Relational Database,

191 – 200.

[14] Bilgic, Taner & Turksen, I.B, Measurement of membership functions: Theoretical and

Empirical work, 17 – 21.

[15] Chameau, J. L. & Santamarina, J. C. (1987a), Membership Part I: Comparing Methods of

Measurement, 287-301.

Page 29: MemFunc.doc

Appendix A

Stored Procedures

A. Fetch_All_Images

/* Database Research Spring 2005 Shweta Sanghi Fetch_All_Images, stored procedure, fetches all images from the database for training */

CREATE PROCEDURE [Fetch_All_Images]

AS

SET ANSI_NULLS ON

exec('select * from Person P')

GO

B. Fetch_Data

/* Database Research Spring 2005 Shweta Sanghi Fetch_Data, stored procedure, is used to fetch the data from the database based on old method of assigning weights. It interprets the fuzzy modifiers and translates them into SQL Queries for our database */

CREATE PROCEDURE [Fetch_Data] @query as varchar(10),@s1 as varchar(50),@s2 as varchar(50)

AS

SET ANSI_NULLS ON declare @f_query as varchar(500),@high as float,@low as floatprint @high

if @s2 = 'Blue' or @s2='Green' or @s2='Brown' begin

Page 30: MemFunc.doc

select @high =high from Range where modifier=@s1select @low= low from Range where modifier=@s1

print @s2exec('select * from Person P,Color C whereP.ID=C.ID and C.weight <= '+@high+' and C.weight >= '+@low+' and

C.Color='+'"'+@s2+'"') end if @s2 = 'Broad' or @s2 = 'Average' or @s2='Narrow' begin

select @high = high from Range where modifier=@s1select @low =low from Range where modifier=@s1exec('select * from Person P,Face F where

P.ID=F.ID and F.weight >= '+@low+' and F.weight <= '+@high+' and F.Face='+'"'+@s2+'"')

end

GO

C. Fetch_Direct_Data

/* Database Research Spring 2005 Shweta Sanghi Fetch_Direct_Data, stored procedure, is used to fetch the data from the database based on direct rating method of assigning weights. It interprets the fuzzy modifiers and translates them into SQL Queries for our database */

CREATE PROCEDURE [Fetch_Direct_Data] @query as varchar(10),@s1 as varchar(50),@s2 as varchar(50)

AS

SET ANSI_NULLS ON declare @f_query as varchar(500),@high as float,@low as floatprint @high

if @s2 = 'Blue' or @s2='Green' or @s2='Brown'

Page 31: MemFunc.doc

beginselect @high =high from Range where modifier=@s1select @low= low from Range where modifier=@s1

print @s2exec('select * from Person P,ColorDirect C whereP.ID=C.ID and C.weight <= '+@high+' and C.weight >= '+@low+' and

C.Color='+'"'+@s2+'"') end if @s2 = 'Broad' or @s2 = 'Average' or @s2='Narrow' begin

select @high = high from Range where modifier=@s1select @low =low from Range where modifier=@s1exec('select * from Person P,Face F whereP.ID=F.ID and F.weight >= '+@low+' and F.weight <= '+@high+' and

F.Face='+'"'+@s2+'"') endGO

D. initialize_weights

/* Database Research Spring 2005 Karen Joy and Smita Dattatri Updated by Shweta Sanghi This procedure is used to initialize the weights associated with the “Eye Color” and the “Face Width “ attributes. This procedures assigns a random weight to each of the entries in the “Color” and the “ Face” table. We have used a cursor that loops through each record in the “Face” and the “Color” table and assigns a random value to the corresponding weights in each row. This procedure is not invoked via the application .It is executed directly on the database to initialize the weights.*/

CREATE PROCEDURE [initialize_weights]as

declare @id as int,@color as varchar(20),@face as varchar(20)DECLARE color_weight CURSORforselect ID,color from color OPEN color_weight

FETCH NEXT FROM color_weightinto @ID,@color

Page 32: MemFunc.doc

WHILE @@FETCH_STATUS = 0BEGIN

print 'ID' print @id

print 'color'print @color

update color set weight=rand() where ID=@id and color=@color

FETCH NEXT FROM color_weightinto @ID,@color

END

CLOSE color_weightDEALLOCATE color_weight

DECLARE face_weight CURSORforselect ID,face from face OPEN face_weight

FETCH NEXT FROM face_weightinto @ID,@face

WHILE @@FETCH_STATUS = 0BEGIN

print 'ID+Face' print @id

print 'Face'print @face

update Face set weight=rand() where ID=@id and Face=@faceFETCH NEXT FROM face_weightinto @ID,@face

END

CLOSE face_weightDEALLOCATE face_weight

GO

Page 33: MemFunc.doc

E. Insert_Test_Data

/* Database Research Spring 2005 Shweta Sanghi Insert_Test_Data, stored procedure, is used to insert the user’s satisfaction information for direct rating method into Test table*/

CREATE PROCEDURE .[Insert_Test_Data] @ID as int,@ValueBlue as int,@TypeBlue as varchar(50)AS

SET ANSI_NULLS ON

if @TypeBlue = 'very' begin

insert into Test (ID,VeryBlue) values(@ID,@ValueBlue) end else begin

if @TypeBlue = 'medium' begin

insert into Test (ID,MediumBlue) values(@ID,@ValueBlue)end

else begin

if @TypeBlue = 'less' begin

insert into Test (ID,LessBlue) values(@ID,@ValueBlue)end

end end

GO

Page 34: MemFunc.doc

F. Insert_TestOld_Data

/* Database Research Spring 2005 Shweta Sanghi Insert_TestOld_Data, stored procedure, is used to insert the user’s satisfaction information for previous prototype method into TestOld table*/

CREATE PROCEDURE .[Insert_TestOld_Data] @ID as int,@ValueBlue as int,@TypeBlue as varchar(50)AS

SET ANSI_NULLS ON

if @TypeBlue = 'very' begin

insert into TestOld (ID,VeryBlue) values(@ID,@ValueBlue) end else begin

if @TypeBlue = 'medium' begin

insert into TestOld (ID,MediumBlue) values(@ID,@ValueBlue)end

else begin

if @TypeBlue = 'less' begin

insert into TestOld (ID,LessBlue) values(@ID,@ValueBlue)end

end end

GO

Page 35: MemFunc.doc

G. Insert_Train_Data

/* Database Research Spring 2005 Shweta Sanghi Insert_Train_Data, stored procedure, is used to insert the user’s view for blue eye color of image.*/

CREATE PROCEDURE .[Insert_Train_Data] @ID as int,@TrainBlue as int

AS

SET ANSI_NULLS ON

insert into Train (ID,TrainBlue) values(@ID,@TrainBlue)GO

H. Update_Data

/* Database Research Spring 2005 Karen Joy and Smita Dattatri Updated by Shweta Sanghi This procedure is used to fetch the data from the database. It interprets the fuzzy modifiers and translates them into SQL Queries for our database.*/

CREATE PROCEDURE [Update_Data] @ID as int,@color as varchar(50),@more_less as varchar(50),@modifier as varchar(50)

AS

SET ANSI_NULLS ON declare @threshold as float,@existing_weight as float,@new_weight as float if @color = 'Blue' or @color='Green' or @color='Brown' begin

select @threshold =threshold from Range where modifier=@modifierselect @existing_weight=Weight from Color where ID=@ID and Color=@colorset @new_weight=@existing_weight

Page 36: MemFunc.doc

if @more_less = 'meets'begin

if @existing_weight < @thresholdbegin

set @new_weight = @existing_weight + .01endif @existing_weight > @thresholdbegin

set @new_weight = @existing_weight - .01end

end

elsebegin

if @more_less = 'more'begin

if @modifier = 'very'begin

if @existing_weight > @thresholdbegin

set @new_weight = @existing_weight - .01endif @existing_weight < @thresholdbegin

set @new_weight = @existing_weight + .01end

endelsebegin

set @new_weight = @existing_weight + .01end

endelsebegin

if @modifier='slightly'begin

if @existing_weight > @thresholdbegin

set @new_weight = @existing_weight - .01endif @existing_weight < @thresholdbegin

set @new_weight = @existing_weight + .01end

endelse

Page 37: MemFunc.doc

beginset @new_weight = @existing_weight - .01

endend

endupdate Color set weight=@new_weight where ID=@ID and color=@color

endif @color = 'Broad' or @color = 'Average' or @color='Narrow' begin

select @threshold =threshold from Range where modifier=@modifierselect @existing_weight=Weight from Face where ID=@ID and Face=@colorset @new_weight=@existing_weight

if @more_less = 'meets'begin

if @existing_weight < @thresholdbegin

set @new_weight = @existing_weight + .01endif @existing_weight > @thresholdbegin

set @new_weight = @existing_weight - .01end

end

elsebegin

if @more_less = 'more'begin

if @modifier = 'very'begin

if @existing_weight > @thresholdbegin

set @new_weight = @existing_weight - .01endif @existing_weight < @thresholdbegin

set @new_weight = @existing_weight + .01end

endelsebegin

set @new_weight = @existing_weight + .01

Page 38: MemFunc.doc

endendelsebegin

if @modifier='slightly'begin

if @existing_weight > @thresholdbegin

set @new_weight = @existing_weight - .01endif @existing_weight < @thresholdbegin

set @new_weight = @existing_weight + .01end

endelsebegin

set @new_weight = @existing_weight - .01end

endend

update Face set weight=@new_weight where ID=@ID and Face=@color

end

GO

Page 39: MemFunc.doc

Appendix B

Source Code

Source Code for Direct Rating Method

'Database Research Spring 2005'Shweta'This form takes user id as input and invokes the stored procedure "Fetch_All_Images" 'which queries the database to retrieve all images with slide bar for user input. 'If the user presses the update button then user’s input is stored into the database 'by the stored procedure called “Insert_Train_Data”.

Imports System.IOImports System.Data.SqlClient

Public Class learn Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New() MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents Button3 As System.Windows.Forms.Button

Page 40: MemFunc.doc

Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button3 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.Panel1 = New System.Windows.Forms.Panel Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button3 ' Me.Button3.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button3.Location = New System.Drawing.Point(560, 640) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(88, 23) Me.Button3.TabIndex = 0 Me.Button3.Text = " Cancel" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(280, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(616, 23) Me.Label1.TabIndex = 1 Me.Label1.Text = "Label1" ' 'Panel1 ' Me.Panel1.Location = New System.Drawing.Point(0, 32) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(864, 600) Me.Panel1.TabIndex = 2 ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(176, 640) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(104, 23) Me.Button1.TabIndex = 3 Me.Button1.Text = "More" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(352, 640)

Page 41: MemFunc.doc

Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(120, 23) Me.Button2.TabIndex = 4 Me.Button2.Text = "Update" ' 'learn ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(872, 669) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Panel1) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Button3) Me.Name = "learn" Me.Text = "Training Images " Me.ResumeLayout(False)

End Sub

#End Region

'user defined variables Dim User As New Integer 'variable storing user id Dim ds As New DataSet 'varibale storing dataset which is the result of the query Dim al As New ArrayList 'varibale storing image set which has image and slide bar Dim nextPix As Integer 'variable indicating the first picture to be displayed on a page Dim remainingPix As Integer 'variable indicating the remaining pictures to be displayed on a page

'Connection String used to connect to the database. 'vikas=Name Of the Computer 'DBResearch=Name of the database Dim con As New System.Data.SqlClient.SqlConnection("data source=vikas;initial catalog=DBResearch;user id=dbresearch;password=dbresearch") 'Procedure takes user id from main form and assigns to variable called User 'Public Sub initialize(ByVal s1 As Integer) ' User = s1 'End Sub*/

'Event handling for cancel button. It closes the database connection and exit the project Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click con.Close() Me.Dispose() Me.Close() End End Sub ' This function is invoked when the form is loaded.The stored procedure "Fetch_All_Images" is

Page 42: MemFunc.doc

'invoked. This stored procedure executes the query and returns the result set

Private Sub learn_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim I As Integer Dim Count As Integer

'Making connection to database and executes the stored procedure called "Fetch_All_Images" 'and put the dataset in da variable Dim cmd As New System.Data.SqlClient.SqlCommand("Fetch_All_Images", con) cmd.CommandType = CommandType.StoredProcedure

Try Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd) da.Fill(ds) Catch ex As Exception MessageBox.Show(ex.ToString) End Try

'displays the number of rows returned as a result of query (use for debugging) 'MessageBox.Show(ds.Tables(0).Rows().Count)

'This block executes the each dataset row, creates image set ' and displays on the form If (ds.Tables(0).Rows().Count) > 0 Then Count = ds.Tables(0).Compute("COUNT(ID)", "")

'The following block of code creates a new object of ImageSet for each 'record in the which result set which contains the image and the slide bar 'associated with it. It also reads the image in binary format from the database 'and displays it appropriately.

For I = 0 To Count - 1 Dim S As New ImageSet Dim bits As Byte() = CType(ds.Tables(0).Rows(I).Item(2), Byte()) Dim memorybits As New MemoryStream(bits) Dim bitmap As New Bitmap(memorybits)

S.picture.Image = bitmap al.Add(S) al(I).ID = ds.Tables(0).Rows(I).Item(0) Next I

'variable indicating the first picture to be displayed on a page nextPix = 0 'variable indicating the remaining pictures to be displayed remainingPix = al.Count

Page 43: MemFunc.doc

'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. placeComponents(nextPix)

'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled updateButtons()

'label on the Panel. Label1.Text() = "Please Answer the following question."

Else MessageBox.Show("No images match your criteria") End If End Sub

'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. Private Sub placeComponents(ByVal Position1 As Integer) Dim X As Integer, Y As Integer Y = 8 Dim I As Integer

'limit the display to 6 images Dim lastPix As Integer

'determing the last picture for the current page If remainingPix <= 6 Then lastPix = Position1 + remainingPix - 1 Else : lastPix = Position1 + 5 End If

For I = Position1 To lastPix Dim G As New GroupBox G.Location() = New Point(8 + X, Y) G.Size() = New Size(268, 295) 'was (288,350)

al(I).picture.Location = New Point(50, 24) al(I).picture.size = New Size(200, 200) 'was (224,120)

al(I).label_response.location = New Point(50, 230) 'was (32, 250) al(I).label_response.size = New Size(176, 24)

al(I).user_response.size = New Size(200, 24) al(I).user_response.location = New Point(50, 260) 'was (32, 275)

G.Controls.Add(al(I).picture) G.Controls.Add(al(I).user_response) G.Controls.Add(al(I).label_response) Panel1.Controls.Add(G)

'Allows to display multiple rows of records. X = 300 + X If ((I Mod 6) = 2) Then Y = 295 + 5 + Y

Page 44: MemFunc.doc

X = 0 End If Next

'update the number of picutes left to be displayed If remainingPix > 6 Then remainingPix = remainingPix - 6 Else remainingPix = 0 End If

'update first picture on next page nextPix = nextPix + 6 End Sub

'set up buttons depending on number of images in query result 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled Private Sub updateButtons() If al.Count <= 6 Or remainingPix = 0 Then Me.Button1.Enabled = False Me.Button2.Enabled = True Else Me.Button1.Enabled = True Me.Button2.Enabled = False End If End Sub

'---------------------------------------------------------------- 'The class ImagesSet is a user defined class which has the image 'and the slide bar as its components.

Public Class ImageSet Public picture As PictureBox Public user_response As HScrollBar Public label_response As Label Public ID As Integer

Public Sub New() picture = New PictureBox user_response = New HScrollBar label_response = New Label label_response.Text = "How blue are the eyes?" label_response.Font = New System.Drawing.Font("Verdana", 8, FontStyle.Bold) user_response.Minimum = 0 user_response.Maximum = 109

ID = 0

End Sub

End Class 'Event Handling for More Button. It clears the panel, 'builds and displays next page

Page 45: MemFunc.doc

'set up buttons depending on number of images in query result Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'clear existing pictures Panel1.Controls.Clear()

'build and display next page placeComponents(nextPix) Panel1.Show()

'set up buttons depending on number of images in query result updateButtons() End Sub 'Event Handling for update button. It evokes the stored produce called "Insert_Train_Data" 'to insert into database the users's response Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim I As Integer ' Dim UserId As Integer Dim TrainBlue As Integer ' UserId = User

'con.Open() 'This block of code records the value of slide bar movement by the user in 'order to update the corresponding rows in the database.For each person the 'stored procedure Update_Data is invoked. For I = 0 To al.Count - 1

TrainBlue = al(I).User_Response.value

Dim daptr = New SqlDataAdapter daptr.SelectCommand = New SqlCommand daptr.SelectCommand.CommandType = CommandType.StoredProcedure daptr.SelectCommand.CommandText = "dbo.Insert_Train_Data" daptr.SelectCommand.Connection = con 'daptr.SelectCommand.Parameters.Add("@UserID", UserId) daptr.SelectCommand.Parameters.Add("@ID", al(I).ID) daptr.SelectCommand.Parameters.Add("@TrainBlue", TrainBlue) con.Open() Try daptr.SelectCommand.ExecuteNonQuery() Catch ex As Exception MessageBox.Show("Failed to execute query") End Try con.Close()

Next Dim MessageLearn As MessageLearn MessageLearn = New MessageLearn Me.Dispose() MessageLearn.Show() End SubEnd Class'Database Research Spring 2005

Page 46: MemFunc.doc

'Shweta Sanghi'Main form is the start up form of the project. This forms asks the user whether he wants to provide 'training samples needed to elicit membership function or wants to provide feedback. 'If he wants to train then the learn form is evoked otherwise query form is evoked'Also it passes used id which is input by the user to learn form or query form

Public Class main Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New() MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label2 = New System.Windows.Forms.Label Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout()

Page 47: MemFunc.doc

' 'RadioButton1 ' Me.RadioButton1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.RadioButton1.Location = New System.Drawing.Point(264, 160) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.TabIndex = 2 Me.RadioButton1.Text = "Train " Me.RadioButton1.TextAlign = System.Drawing.ContentAlignment.TopCenter ' 'RadioButton2 ' Me.RadioButton2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.RadioButton2.Location = New System.Drawing.Point(264, 224) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.TabIndex = 3 Me.RadioButton2.Text = "Test" Me.RadioButton2.TextAlign = System.Drawing.ContentAlignment.TopCenter ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(104, 320) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(160, 32) Me.Button1.TabIndex = 4 Me.Button1.Text = "Ok" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(456, 320) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(144, 32) Me.Button2.TabIndex = 5 Me.Button2.Text = "Cancel" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(136, 96) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(384, 23) Me.Label2.TabIndex = 5 Me.Label2.Text = "Choose operation that you would like to do" ' 'Label1

Page 48: MemFunc.doc

' Me.Label1.Font = New System.Drawing.Font("Verdana", 14.0!, System.Drawing.FontStyle.Bold) Me.Label1.Location = New System.Drawing.Point(24, 16) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(656, 32) Me.Label1.TabIndex = 0 Me.Label1.Text = "Welcome to Fuzzy Relational Database for Images Retrieval" Me.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter ' 'main ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(704, 373) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.RadioButton2) Me.Controls.Add(Me.RadioButton1) Me.Controls.Add(Me.Label1) Me.Name = "main" Me.Text = "Fuzzy Relational Database" Me.ResumeLayout(False)

End Sub

#End Region

'Event handling procedure for cancel button to exit from the project

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Dispose() Me.Close() End End Sub 'Event handling procedure for ok button. According to the user’s response, 'either query form is evoked or learn form is evoked having user id as input Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If (RadioButton1.Checked() = True) Then Dim f As learn f = New learn Me.Hide() f.Show() ElseIf (RadioButton2.Checked() = True) Then Dim f As TestslightlyBlue f = New TestslightlyBlue f.initialize() Me.Hide() f.Show() Else MessageBox.Show("Please choose operation or press cancel button.") End If

Page 49: MemFunc.doc

End Sub

End ClassDatabase Research Spring 2005'Shweta Sanghi'This form informs the user that the update opearation was successful and asks the user' whether he/she would like to run another train.Public Class MessageLearn Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New() MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Page 50: MemFunc.doc

Me.Label1.Location = New System.Drawing.Point(88, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(312, 24) Me.Label1.TabIndex = 0 Me.Label1.Text = "Thanks for your help in research" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(128, 64) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(216, 24) Me.Label2.TabIndex = 1 Me.Label2.Text = "Please Press Next Button" ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(112, 112) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 32) Me.Button1.TabIndex = 2 Me.Button1.Text = "Next" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(288, 112) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(80, 32) Me.Button2.TabIndex = 3 Me.Button2.Text = "End" ' 'MessageLearn ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(488, 173) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Location = New System.Drawing.Point(5000, 7000) Me.Name = "MessageLearn" Me.Text = "Message" Me.ResumeLayout(False)

End Sub

#End Region

'Event handling for yes button. It displays the learn form

Page 51: MemFunc.doc

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f As learn f = New learn f.Show() Me.Dispose() End Sub 'Event handling for No button to exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Dispose() Me.Close() End End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

End SubEnd Class

'Database Research Spring 2005'Shweta Sanghi'This form informs the user that the update opearation was successful and asks the user' whether he/she would like to run another test.Public Class MessageTest Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New() MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

Page 52: MemFunc.doc

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(88, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(312, 24) Me.Label1.TabIndex = 0 Me.Label1.Text = "Thanks for your help in research" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(120, 72) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(216, 24) Me.Label2.TabIndex = 1 Me.Label2.Text = "Please Press Next Button" ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(112, 112) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 32) Me.Button1.TabIndex = 2 Me.Button1.Text = "Next" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(288, 112) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(80, 32) Me.Button2.TabIndex = 3

Page 53: MemFunc.doc

Me.Button2.Text = "End" ' 'MessageTest ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(488, 173) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Location = New System.Drawing.Point(5000, 7000) Me.Name = "MessageTest" Me.Text = "Message" Me.ResumeLayout(False)

End Sub

#End Region

'Event handling for yes button. It displays the Form1 form for testing Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f As TestslightlyBlue f = New TestslightlyBlue f.initialize() f.Show() Me.Dispose() End Sub 'Event handling for No button to exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Dispose() Me.Close() End End Sub

End Class

‘Database Research Summer 2004'Karen Joy and Smita Dattatri'Database Research Spring 2005'Updated by Shweta Sanghi'This form reads the file which contains the Fuzzy Query and displays that on the screen 'giving the user a chance to change the query.The user can then click on the "Submit" button which submits the 'fuzzy query to the intermediate layer(stored procedures)in order to be processed.Imports System.ioPublic Class QueryForm Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

Page 54: MemFunc.doc

MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TextBox1.Location = New System.Drawing.Point(40, 40) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both Me.TextBox1.Size = New System.Drawing.Size(512, 50) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "TextBox1" ' 'TextBox2 ' Me.TextBox2.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TextBox2.Location = New System.Drawing.Point(40, 136) Me.TextBox2.Multiline = True

Page 55: MemFunc.doc

Me.TextBox2.Name = "TextBox2" Me.TextBox2.ScrollBars = System.Windows.Forms.ScrollBars.Both Me.TextBox2.Size = New System.Drawing.Size(512, 50) Me.TextBox2.TabIndex = 1 Me.TextBox2.Text = "TextBox2" ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(104, 256) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(136, 40) Me.Button1.TabIndex = 1 Me.Button1.Text = "Submit Query" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(304, 256) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(136, 40) Me.Button2.TabIndex = 3 Me.Button2.Text = "Cancel" ' 'QueryForm ' Me.AcceptButton = Me.Button1 Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.SystemColors.Control Me.ClientSize = New System.Drawing.Size(592, 366) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.TextBox1) Me.Name = "QueryForm" Me.Text = "Query" Me.ResumeLayout(False)

End Sub

#End Region

'user defined variables Dim User As Integer 'variable storing user id Dim modifier As String 'varibale storing values such as slightly, medium, very Dim color_face As String 'variable storing values such as Blue, Brown, Green, blue, green, brown, broad, narrow Dim strarry(20) As String 'This function is invoked when the form is loaded. 'It reads the input file called input.txt which contains the Fuzzy Query 'It also reads the input file called input1.txt to read the modifiers

Page 56: MemFunc.doc

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Reads the file which contains the Fuzzy Query Dim myfileStream As New IO.FileStream("C:\input.txt", IO.FileMode.Open, IO.FileAccess.Read) Dim myreader As New IO.StreamReader(myfileStream)

Try TextBox1.Clear() Dim line2 As New String("") Do line2 = line2 + myreader.ReadLine + vbCrLf

Loop Until myreader.Peek = -1 TextBox1.AppendText(line2) Catch ex As Exception TextBox1.AppendText("File is empty") Finally myreader.Close() End Try Dim myfileStream1 As New IO.FileStream("C:\input1.txt", IO.FileMode.Open, IO.FileAccess.Read) Dim myreader1 As New IO.StreamReader(myfileStream1) Try TextBox2.Clear() Dim line1 As New String("") Dim i As Integer i = 0 Do 'line1 = line1 + myreader1.ReadLine + vbCrLf strarry(i) = New String(myreader1.ReadLine()) i = i + 1 Loop Until myreader1.Peek = -1 TextBox2.AppendText(strarry(0) + vbCrLf + strarry(1)) Catch ex As Exception ' TextBox2.AppendText("File is empty") TextBox2.AppendText(ex.ToString) Finally myreader1.Close() End Try End Sub 'Procedure takes input from main form and assigns user id to variable called User 'Public Sub initialize(ByVal us1 As Integer) ' User = us1 'End Sub 'Event handling for Submit button. It evokes and initializes the Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f As TestVeryBlue f = New TestVeryBlue Dim s1 As String = TextBox2.Lines(0) Dim s2 As String = TextBox2.Lines(1) 'f.initialize(TextBox1.Text, s1, s2) Me.Hide() f.Show() End Sub

Page 57: MemFunc.doc

'Event handling procedure for cancel button to exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Dispose() Me.Close() End

End SubEnd Class

‘Database Research Summer 2004'Karen Joy and Smita Dattatri'Database Research Spring 2005'Updated by Shweta Sanghi'This form invokes the stored procedure "Fetch Data" which interprets the Fuzzy query and 'returns the set of rows to be displayed on the User Interface.This form also invokes a 'stored procedure called "Insert_Test_data" which updates the database depending on the feedback 'given by the user.

Imports System.IOImports System.Data.SqlClient

Public Class TestMediumBlue Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New() MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

Page 58: MemFunc.doc

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Panel2 As System.Windows.Forms.Panel <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel Me.Button3 = New System.Windows.Forms.Button Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.Panel2 = New System.Windows.Forms.Panel Me.Panel1.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' Me.Panel1.Controls.Add(Me.Button3) Me.Panel1.Controls.Add(Me.Button1) Me.Panel1.Controls.Add(Me.Button2) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom Me.Panel1.Location = New System.Drawing.Point(0, 637) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(872, 32) Me.Panel1.TabIndex = 2 ' 'Button3 ' Me.Button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button3.Location = New System.Drawing.Point(216, 0) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(104, 24) Me.Button3.TabIndex = 4 Me.Button3.Text = "More" ' 'Button1 ' Me.Button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button1.BackColor = System.Drawing.Color.LightGray Me.Button1.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(384, 0) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(104, 24) Me.Button1.TabIndex = 1 Me.Button1.Text = "Update" ' 'Button2 ' Me.Button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button2.BackColor = System.Drawing.Color.LightGray

Page 59: MemFunc.doc

Me.Button2.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(552, 0) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(104, 24) Me.Button2.TabIndex = 3 Me.Button2.Text = "Cancel" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(280, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(552, 24) Me.Label1.TabIndex = 4 Me.Label1.Text = "Label1" ' 'Panel2 ' Me.Panel2.Location = New System.Drawing.Point(0, 32) Me.Panel2.Name = "Panel2" Me.Panel2.Size = New System.Drawing.Size(864, 600) Me.Panel2.TabIndex = 5 ' 'TestMediumBlue ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(872, 669) Me.Controls.Add(Me.Panel2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Panel1) Me.Name = "TestMediumBlue" Me.Text = "Testing Direct Method" Me.WindowState = System.Windows.Forms.FormWindowState.Maximized Me.Panel1.ResumeLayout(False) Me.ResumeLayout(False)

End Sub

#End Region

'user defined variables Dim User As Integer 'variable storing user id Dim Query As String 'variable storing the query Dim modifier As String 'varibale storing values such as slightly, medium, very Dim color_face As String 'variable storing values such as Blue, Brown, Green, blue, green, brown, broad, narrow Dim ds As New DataSet 'varibale storing dataset which is the result of the query Dim al As New ArrayList 'varibale storing image set which has image and check boxes Dim nextPix As Integer 'variable indicating the first picture to be displayed on a page

Page 60: MemFunc.doc

Dim remainingPix As Integer 'variable indicating the remaining pictures to be displayed on a page

'Connection String used to connect to the database. 'vikas=Name Of the Computer 'DBResearch=Name of the database

Dim con As New System.Data.SqlClient.SqlConnection("data source=vikas;initial catalog=DBResearch;user id=dbresearch;password=dbresearch")

'Event handling procedure for the 'Update' button . It evokes the stored produce called "Insert_Test_Data" 'to insert into database the users's response

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim I As Integer ' Dim UserId As Integer Dim TestBlue As Integer 'UserId = User

'con.Open() 'This block of code checks which check boxes were clicked by the user and for which 'person in order to update the corresponding rows in the database.For each person the 'stored procedure Insert_Test_Data is invoked. For I = 0 To al.Count - 1

If (al(I).meets_criteria.Checked() = True) Then TestBlue = 0 ElseIf (al(I).no_criteria_meet.Checked() = True) Then TestBlue = 1 End If

Dim daptr = New SqlDataAdapter daptr.SelectCommand = New SqlCommand daptr.SelectCommand.CommandType = CommandType.StoredProcedure daptr.SelectCommand.CommandText = "dbo.Insert_Test_Data" daptr.SelectCommand.Connection = con 'daptr.SelectCommand.Parameters.Add("@UserID", UserId) daptr.SelectCommand.Parameters.Add("@ID", al(I).ID) daptr.SelectCommand.Parameters.Add("@ValueBlue", TestBlue) daptr.SelectCommand.Parameters.Add("@TypeBlue", "medium") con.Open() Try daptr.SelectCommand.ExecuteNonQuery() Catch ex As Exception MessageBox.Show("Failed to execute query") End Try

con.Close()

Next Dim TestVeryBlue As TestVeryBlue

Page 61: MemFunc.doc

TestVeryBlue = New TestVeryBlue TestVeryBlue.initialize() Me.Dispose() TestVeryBlue.Show()

End Sub

'This function is invoked when the form is loaded.The stored procedure "Fetch_Data" is 'invoked and the fuzzy modifiers are passed as parameters to this stored procedure. 'This stored procedure interprets the fuzzy modifiers and returns the result set that 'matches the criteria.

Private Sub TestMediumBlue_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim I As Integer Dim Count As Integer

'Making connection to database and executes the stored procedure called "Fetch_Data" 'and put the dataset in da variable Dim cmd As New System.Data.SqlClient.SqlCommand("Fetch_Direct_Data", con)

cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add(New SqlParameter("@query", SqlDbType.VarChar, 100)) cmd.Parameters("@query").Value = Query cmd.Parameters.Add(New SqlParameter("@s1", SqlDbType.VarChar, 100)) cmd.Parameters("@s1").Value = modifier cmd.Parameters.Add(New SqlParameter("@s2", SqlDbType.VarChar, 100)) cmd.Parameters("@s2").Value = color_face Try Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd) da.Fill(ds) Catch ex As Exception MessageBox.Show(ex.ToString) End Try

'displays the number of rows returned as a result of query (use for debugging) 'MessageBox.Show(ds.Tables(0).Rows().Count)

'This block executes the each dataset row, creates image set ' and displays on the form If (ds.Tables(0).Rows().Count) > 0 Then Count = ds.Tables(0).Compute("COUNT(ID)", "")

'The following block of code creates a new object of ImageSet for each 'record in the which result set which contains the image and the Check Boxes 'associated with it. It also reads the image in binary format from the database

Page 62: MemFunc.doc

'and displays it appropriately.

For I = 0 To Count - 1 Dim S As New ImageSet(color_face) Dim bits As Byte() = CType(ds.Tables(0).Rows(I).Item(2), Byte()) Dim memorybits As New MemoryStream(bits) Dim bitmap As New Bitmap(memorybits)

S.picture.Image = bitmap al.Add(S) al(I).ID = ds.Tables(0).Rows(I).Item(0) Next I

'variable indicating the first picture to be displayed on a page nextPix = 0 'variable indicating the remaining pictures to be displayed remainingPix = al.Count

'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. placeComponents(nextPix)

'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled updateButtons()

'Changes the labels on the Panel depending on the query. If color_face = "Green" Or color_face = "Blue" Or color_face = "Brown" Or color_face = "green" Or color_face = "blue" Or color_face = "brown" Then Label1.Text() = "People with " + modifier + " " + color_face + " Eyes" Else Label1.Text() = "People With " + modifier + " " + color_face + " Faces" End If Else MessageBox.Show("No images match your criteria") End If End Sub

'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. Private Sub placeComponents(ByVal Position1 As Integer)

Dim X As Integer, Y As Integer Y = 8 Dim I As Integer

'limit the display to 6 images Dim lastPix As Integer

'determing the last picture for the current page

Page 63: MemFunc.doc

If remainingPix <= 6 Then lastPix = Position1 + remainingPix - 1 Else : lastPix = Position1 + 5 End If

For I = Position1 To lastPix Dim G As New GroupBox G.Location() = New Point(8 + X, Y) G.Size() = New Size(268, 295) 'was (288,350)

al(I).picture.Location = New Point(50, 24) al(I).picture.size = New Size(200, 200) 'was (224,120)

al(I).meets_criteria.location = New Point(32, 225) 'was (32, 250) al(I).meets_criteria.size = New Size(176, 24)

al(I).no_criteria_meet.size = New Size(176, 24) al(I).no_criteria_meet.location = New Point(32, 250) 'was (32, 275)

G.Controls.Add(al(I).picture) G.Controls.Add(al(I).meets_criteria) G.Controls.Add(al(I).no_criteria_meet) Panel2.Controls.Add(G)

'Allows to display multiple rows of records. X = 300 + X If ((I Mod 6) = 2) Then Y = 295 + 5 + Y X = 0 End If Next

'update the number of picutes left to be displayed If remainingPix > 6 Then remainingPix = remainingPix - 6 Else remainingPix = 0 End If

'update first picture on next page nextPix = nextPix + 6 End Sub

'set up buttons depending on number of images in query result 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled Private Sub updateButtons() If al.Count <= 6 Or remainingPix = 0 Then Me.Button3.Enabled = False Me.Button1.Enabled = True Else Me.Button3.Enabled = True Me.Button1.Enabled = False End If

Page 64: MemFunc.doc

End Sub

'Procedure takes input from query form and assigns them to variables Public Sub initialize() Query = "select * from person where color.color = 'blue';" modifier = "Medium" color_face = "Blue" End Sub

'Event handling for 'Cancel' button. It closes the database connection and exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click con.Close() Me.Dispose() Me.Close() End End Sub

'Event handling for 'More' button 'It clears the panel, builds and displays next page 'set up buttons depending on number of images in query result Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'clear existing pictures Panel2.Controls.Clear()

'build and display next page placeComponents(nextPix) Panel2.Show()

'set up buttons depending on number of images in query result updateButtons() End Sub

'---------------------------------------------------------------- 'The class ImagesSet is a user defined class which has the image 'and the check boxes as its components.

Public Class ImageSet Public picture As PictureBox Public meets_criteria As RadioButton Public no_criteria_meet As RadioButton Public ID As Integer

Public Sub New(ByVal color_face As String) picture = New PictureBox meets_criteria = New RadioButton no_criteria_meet = New RadioButton meets_criteria.Text = "Satisfied with result" meets_criteria.Checked = True 'Changes the labels on the Check Boxes depending on the query. no_criteria_meet.Text = "Not satisfied with result" ID = 0

Page 65: MemFunc.doc

End Sub

End ClassEnd Class

'Database Research Summer 2004'Karen Joy and Smita Dattatri'Database Research Spring 2005'Updated by Shweta Sanghi'This form invokes the stored procedure "Fetch Data" which interprets the Fuzzy query and 'returns the set of rows to be displayed on the User Interface.This form also invokes a 'stored procedure called "Insert_Test_data" which updates the database depending on the feedback 'given by the user.

Imports System.IOImports System.Data.SqlClient

Public Class TestslightlyBlue Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New() MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Panel1 As System.Windows.Forms.Panel

Page 66: MemFunc.doc

Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Panel2 As System.Windows.Forms.Panel <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel Me.Button3 = New System.Windows.Forms.Button Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.Panel2 = New System.Windows.Forms.Panel Me.Panel1.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' Me.Panel1.Controls.Add(Me.Button3) Me.Panel1.Controls.Add(Me.Button1) Me.Panel1.Controls.Add(Me.Button2) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom Me.Panel1.Location = New System.Drawing.Point(0, 637) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(872, 32) Me.Panel1.TabIndex = 2 ' 'Button3 ' Me.Button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button3.Location = New System.Drawing.Point(216, 0) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(104, 24) Me.Button3.TabIndex = 4 Me.Button3.Text = "More" ' 'Button1 ' Me.Button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button1.BackColor = System.Drawing.Color.LightGray Me.Button1.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(384, 0) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(104, 24) Me.Button1.TabIndex = 1 Me.Button1.Text = "Update" ' 'Button2 ' Me.Button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button2.BackColor = System.Drawing.Color.LightGray Me.Button2.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(552, 0)

Page 67: MemFunc.doc

Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(104, 24) Me.Button2.TabIndex = 3 Me.Button2.Text = "Cancel" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(280, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(552, 24) Me.Label1.TabIndex = 4 Me.Label1.Text = "Label1" ' 'Panel2 ' Me.Panel2.Location = New System.Drawing.Point(0, 32) Me.Panel2.Name = "Panel2" Me.Panel2.Size = New System.Drawing.Size(864, 600) Me.Panel2.TabIndex = 5 ' 'TestslightlyBlue ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(872, 669) Me.Controls.Add(Me.Panel2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Panel1) Me.Name = "TestslightlyBlue" Me.Text = "Testing Direct Method" Me.WindowState = System.Windows.Forms.FormWindowState.Maximized Me.Panel1.ResumeLayout(False) Me.ResumeLayout(False)

End Sub

#End Region

'user defined variables Dim User As Integer 'variable storing user id Dim Query As String 'variable storing the query Dim modifier As String 'varibale storing values such as slightly, medium, very Dim color_face As String 'variable storing values such as Blue, Brown, Green, blue, green, brown, broad, narrow Dim ds As New DataSet 'varibale storing dataset which is the result of the query Dim al As New ArrayList 'varibale storing image set which has image and check boxes Dim nextPix As Integer 'variable indicating the first picture to be displayed on a page Dim remainingPix As Integer 'variable indicating the remaining pictures to be displayed on a page

'Connection String used to connect to the database.

Page 68: MemFunc.doc

'vikas=Name Of the Computer 'DBResearch=Name of the database

Dim con As New System.Data.SqlClient.SqlConnection("data source=vikas;initial catalog=DBResearch;user id=dbresearch;password=dbresearch")

'Event handling procedure for the 'Update' button . It evokes the stored produce called "Insert_Test_Data" 'to insert into database the users's response

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim I As Integer ' Dim UserId As Integer Dim TestBlue As Integer 'UserId = User

'con.Open() 'This block of code checks which check boxes were clicked by the user and for which 'person in order to update the corresponding rows in the database.For each person the 'stored procedure Insert_Test_Data is invoked. For I = 0 To al.Count - 1

If (al(I).meets_criteria.Checked() = True) Then TestBlue = 0 ElseIf (al(I).no_criteria_meet.Checked() = True) Then TestBlue = 1 End If

Dim daptr = New SqlDataAdapter daptr.SelectCommand = New SqlCommand daptr.SelectCommand.CommandType = CommandType.StoredProcedure daptr.SelectCommand.CommandText = "dbo.Insert_Test_Data" daptr.SelectCommand.Connection = con 'daptr.SelectCommand.Parameters.Add("@UserID", UserId) daptr.SelectCommand.Parameters.Add("@ID", al(I).ID) daptr.SelectCommand.Parameters.Add("@ValueBlue", TestBlue) daptr.SelectCommand.Parameters.Add("@TypeBlue", "less") con.Open() Try daptr.SelectCommand.ExecuteNonQuery() Catch ex As Exception MessageBox.Show("Failed to execute query") End Try

con.Close()

Next Dim TestMediumBlue As TestMediumBlue TestMediumBlue = New TestMediumBlue TestMediumBlue.initialize() Me.Dispose() TestMediumBlue.Show()

Page 69: MemFunc.doc

End Sub

'This function is invoked when the form is loaded.The stored procedure "Fetch_Data" is 'invoked and the fuzzy modifiers are passed as parameters to this stored procedure. 'This stored procedure interprets the fuzzy modifiers and returns the result set that 'matches the criteria.

Private Sub TestslightlyBlue_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim I As Integer Dim Count As Integer

'Making connection to database and executes the stored procedure called "Fetch_Data" 'and put the dataset in da variable Dim cmd As New System.Data.SqlClient.SqlCommand("Fetch_Direct_Data", con)

cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add(New SqlParameter("@query", SqlDbType.VarChar, 100)) cmd.Parameters("@query").Value = Query cmd.Parameters.Add(New SqlParameter("@s1", SqlDbType.VarChar, 100)) cmd.Parameters("@s1").Value = modifier cmd.Parameters.Add(New SqlParameter("@s2", SqlDbType.VarChar, 100)) cmd.Parameters("@s2").Value = color_face Try Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd) da.Fill(ds) Catch ex As Exception MessageBox.Show(ex.ToString) End Try

'displays the number of rows returned as a result of query (use for debugging) 'MessageBox.Show(ds.Tables(0).Rows().Count)

'This block executes the each dataset row, creates image set ' and displays on the form If (ds.Tables(0).Rows().Count) > 0 Then Count = ds.Tables(0).Compute("COUNT(ID)", "")

'The following block of code creates a new object of ImageSet for each 'record in the which result set which contains the image and the Check Boxes 'associated with it. It also reads the image in binary format from the database 'and displays it appropriately.

For I = 0 To Count - 1 Dim S As New ImageSet(color_face)

Page 70: MemFunc.doc

Dim bits As Byte() = CType(ds.Tables(0).Rows(I).Item(2), Byte()) Dim memorybits As New MemoryStream(bits) Dim bitmap As New Bitmap(memorybits)

S.picture.Image = bitmap al.Add(S) al(I).ID = ds.Tables(0).Rows(I).Item(0) Next I

'variable indicating the first picture to be displayed on a page nextPix = 0 'variable indicating the remaining pictures to be displayed remainingPix = al.Count

'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. placeComponents(nextPix)

'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled updateButtons()

'Changes the labels on the Panel depending on the query. If color_face = "Green" Or color_face = "Blue" Or color_face = "Brown" Or color_face = "green" Or color_face = "blue" Or color_face = "brown" Then Label1.Text() = "People with " + modifier + " " + color_face + " Eyes" Else Label1.Text() = "People With " + modifier + " " + color_face + " Faces" End If Else MessageBox.Show("No images match your criteria") End If End Sub

'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. Private Sub placeComponents(ByVal Position1 As Integer)

Dim X As Integer, Y As Integer Y = 8 Dim I As Integer

'limit the display to 6 images Dim lastPix As Integer

'determing the last picture for the current page If remainingPix <= 6 Then lastPix = Position1 + remainingPix - 1 Else : lastPix = Position1 + 5 End If

Page 71: MemFunc.doc

For I = Position1 To lastPix Dim G As New GroupBox G.Location() = New Point(8 + X, Y) G.Size() = New Size(268, 295) 'was (288,350)

al(I).picture.Location = New Point(50, 24) al(I).picture.size = New Size(200, 200) 'was (224,120)

al(I).meets_criteria.location = New Point(32, 225) 'was (32, 250) al(I).meets_criteria.size = New Size(176, 24)

al(I).no_criteria_meet.size = New Size(176, 24) al(I).no_criteria_meet.location = New Point(32, 250) 'was (32, 275)

G.Controls.Add(al(I).picture) G.Controls.Add(al(I).meets_criteria) G.Controls.Add(al(I).no_criteria_meet) Panel2.Controls.Add(G)

'Allows to display multiple rows of records. X = 300 + X If ((I Mod 6) = 2) Then Y = 295 + 5 + Y X = 0 End If Next

'update the number of picutes left to be displayed If remainingPix > 6 Then remainingPix = remainingPix - 6 Else remainingPix = 0 End If

'update first picture on next page nextPix = nextPix + 6 End Sub

'set up buttons depending on number of images in query result 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled Private Sub updateButtons() If al.Count <= 6 Or remainingPix = 0 Then Me.Button3.Enabled = False Me.Button1.Enabled = True Else Me.Button3.Enabled = True Me.Button1.Enabled = False End If End Sub

'Procedure takes input from query form and assigns them to variables Public Sub initialize()

Page 72: MemFunc.doc

Query = "select * from person where color.color = 'blue';" modifier = "slightly" color_face = "Blue" End Sub

'Event handling for 'Cancel' button. It closes the database connection and exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click con.Close() Me.Dispose() Me.Close() End End Sub

'Event handling for 'More' button 'It clears the panel, builds and displays next page 'set up buttons depending on number of images in query result Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'clear existing pictures Panel2.Controls.Clear()

'build and display next page placeComponents(nextPix) Panel2.Show()

'set up buttons depending on number of images in query result updateButtons() End Sub

'---------------------------------------------------------------- 'The class ImagesSet is a user defined class which has the image 'and the check boxes as its components.

Public Class ImageSet Public picture As PictureBox Public meets_criteria As RadioButton Public no_criteria_meet As RadioButton Public ID As Integer

Public Sub New(ByVal color_face As String) picture = New PictureBox meets_criteria = New RadioButton no_criteria_meet = New RadioButton meets_criteria.Text = "Satisfied with result" meets_criteria.Checked = True 'Changes the labels on the Check Boxes depending on the query. no_criteria_meet.Text = "Not satisfied with result" ID = 0

End Sub

End Class

Page 73: MemFunc.doc

End Class

‘Database Research Summer 2004'Karen Joy and Smita Dattatri'Database Research Spring 2005'Updated by Shweta Sanghi'This form invokes the stored procedure "Fetch Data" which interprets the Fuzzy query and 'returns the set of rows to be displayed on the User Interface.This form also invokes a 'stored procedure called "Insert_Test_data" which updates the database depending on the feedback 'given by the user.

Imports System.IOImports System.Data.SqlClient

Public Class TestVeryBlue Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New() MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button3 As System.Windows.Forms.Button

Page 74: MemFunc.doc

Friend WithEvents Panel2 As System.Windows.Forms.Panel <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel Me.Button3 = New System.Windows.Forms.Button Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.Panel2 = New System.Windows.Forms.Panel Me.Panel1.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' Me.Panel1.Controls.Add(Me.Button3) Me.Panel1.Controls.Add(Me.Button1) Me.Panel1.Controls.Add(Me.Button2) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom Me.Panel1.Location = New System.Drawing.Point(0, 637) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(872, 32) Me.Panel1.TabIndex = 2 ' 'Button3 ' Me.Button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button3.Location = New System.Drawing.Point(216, 0) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(104, 24) Me.Button3.TabIndex = 4 Me.Button3.Text = "More" 'Button1 ' Me.Button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button1.BackColor = System.Drawing.Color.LightGray Me.Button1.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(384, 0) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(104, 24) Me.Button1.TabIndex = 1 Me.Button1.Text = "Update" ' 'Button2 ' Me.Button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button2.BackColor = System.Drawing.Color.LightGray Me.Button2.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(552, 0) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(104, 24) Me.Button2.TabIndex = 3 Me.Button2.Text = "Cancel" '

Page 75: MemFunc.doc

'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(280, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(552, 24) Me.Label1.TabIndex = 4 Me.Label1.Text = "Label1" ' 'Panel2 ' Me.Panel2.Location = New System.Drawing.Point(0, 32) Me.Panel2.Name = "Panel2" Me.Panel2.Size = New System.Drawing.Size(864, 600) Me.Panel2.TabIndex = 5 ' 'TestVeryBlue ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(872, 669) Me.Controls.Add(Me.Panel2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Panel1) Me.Name = "TestVeryBlue" Me.Text = "Testing Direct Method" Me.WindowState = System.Windows.Forms.FormWindowState.Maximized Me.Panel1.ResumeLayout(False) Me.ResumeLayout(False)

End Sub

#End Region

'user defined variables Dim User As Integer 'variable storing user id Dim Query As String 'variable storing the query Dim modifier As String 'varibale storing values such as slightly, medium, very Dim color_face As String 'variable storing values such as Blue, Brown, Green, blue, green, brown, broad, narrow Dim ds As New DataSet 'varibale storing dataset which is the result of the query Dim al As New ArrayList 'varibale storing image set which has image and check boxes Dim nextPix As Integer 'variable indicating the first picture to be displayed on a page Dim remainingPix As Integer 'variable indicating the remaining pictures to be displayed on a page

'Connection String used to connect to the database. 'vikas=Name Of the Computer 'DBResearch=Name of the database

Page 76: MemFunc.doc

Dim con As New System.Data.SqlClient.SqlConnection("data source=vikas;initial catalog=DBResearch;user id=dbresearch;password=dbresearch")

'Event handling procedure for the 'Update' button . It evokes the stored produce called "Insert_Test_Data" 'to insert into database the users's response

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim I As Integer ' Dim UserId As Integer Dim TestBlue As Integer 'UserId = User

'con.Open() 'This block of code checks which check boxes were clicked by the user and for which 'person in order to update the corresponding rows in the database.For each person the 'stored procedure Insert_Test_Data is invoked. For I = 0 To al.Count - 1

If (al(I).meets_criteria.Checked() = True) Then TestBlue = 0 ElseIf (al(I).no_criteria_meet.Checked() = True) Then TestBlue = 1 End If

Dim daptr = New SqlDataAdapter daptr.SelectCommand = New SqlCommand daptr.SelectCommand.CommandType = CommandType.StoredProcedure daptr.SelectCommand.CommandText = "dbo.Insert_Test_Data" daptr.SelectCommand.Connection = con 'daptr.SelectCommand.Parameters.Add("@UserID", UserId) daptr.SelectCommand.Parameters.Add("@ID", al(I).ID) daptr.SelectCommand.Parameters.Add("@ValueBlue", TestBlue) daptr.SelectCommand.Parameters.Add("@TypeBlue", "very") con.Open() Try daptr.SelectCommand.ExecuteNonQuery() Catch ex As Exception MessageBox.Show("Failed to execute query") End Try

con.Close()

Next Dim MessageTest As MessageTest MessageTest = New MessageTest Me.Dispose() MessageTest.Show()

End Sub

Page 77: MemFunc.doc

'This function is invoked when the form is loaded.The stored procedure "Fetch_Data" is 'invoked and the fuzzy modifiers are passed as parameters to this stored procedure. 'This stored procedure interprets the fuzzy modifiers and returns the result set that 'matches the criteria.

Private Sub TestVeryBlue_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim I As Integer Dim Count As Integer

'Making connection to database and executes the stored procedure called "Fetch_Data" 'and put the dataset in da variable Dim cmd As New System.Data.SqlClient.SqlCommand("Fetch_Direct_Data", con)

cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add(New SqlParameter("@query", SqlDbType.VarChar, 100)) cmd.Parameters("@query").Value = Query cmd.Parameters.Add(New SqlParameter("@s1", SqlDbType.VarChar, 100)) cmd.Parameters("@s1").Value = modifier cmd.Parameters.Add(New SqlParameter("@s2", SqlDbType.VarChar, 100)) cmd.Parameters("@s2").Value = color_face Try Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd) da.Fill(ds) Catch ex As Exception MessageBox.Show(ex.ToString) End Try

'displays the number of rows returned as a result of query (use for debugging) 'MessageBox.Show(ds.Tables(0).Rows().Count)

'This block executes the each dataset row, creates image set ' and displays on the form If (ds.Tables(0).Rows().Count) > 0 Then Count = ds.Tables(0).Compute("COUNT(ID)", "")

'The following block of code creates a new object of ImageSet for each 'record in the which result set which contains the image and the Check Boxes 'associated with it. It also reads the image in binary format from the database 'and displays it appropriately.

For I = 0 To Count - 1 Dim S As New ImageSet(color_face) Dim bits As Byte() = CType(ds.Tables(0).Rows(I).Item(2), Byte()) Dim memorybits As New MemoryStream(bits) Dim bitmap As New Bitmap(memorybits)

Page 78: MemFunc.doc

S.picture.Image = bitmap al.Add(S) al(I).ID = ds.Tables(0).Rows(I).Item(0) Next I

'variable indicating the first picture to be displayed on a page nextPix = 0 'variable indicating the remaining pictures to be displayed remainingPix = al.Count

'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. placeComponents(nextPix)

'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled updateButtons()

'Changes the labels on the Panel depending on the query. If color_face = "Green" Or color_face = "Blue" Or color_face = "Brown" Or color_face = "green" Or color_face = "blue" Or color_face = "brown" Then Label1.Text() = "People with " + modifier + " " + color_face + " Eyes" Else Label1.Text() = "People With " + modifier + " " + color_face + " Faces" End If Else MessageBox.Show("No images match your criteria") End If End Sub

'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. Private Sub placeComponents(ByVal Position1 As Integer)

Dim X As Integer, Y As Integer Y = 8 Dim I As Integer

'limit the display to 6 images Dim lastPix As Integer

'determing the last picture for the current page If remainingPix <= 6 Then lastPix = Position1 + remainingPix - 1 Else : lastPix = Position1 + 5 End If

For I = Position1 To lastPix Dim G As New GroupBox G.Location() = New Point(8 + X, Y) G.Size() = New Size(268, 295) 'was (288,350)

Page 79: MemFunc.doc

al(I).picture.Location = New Point(50, 24) al(I).picture.size = New Size(200, 200) 'was (224,120)

al(I).meets_criteria.location = New Point(32, 225) 'was (32, 250) al(I).meets_criteria.size = New Size(176, 24)

al(I).no_criteria_meet.size = New Size(176, 24) al(I).no_criteria_meet.location = New Point(32, 250) 'was (32, 275)

G.Controls.Add(al(I).picture) G.Controls.Add(al(I).meets_criteria) G.Controls.Add(al(I).no_criteria_meet) Panel2.Controls.Add(G)

'Allows to display multiple rows of records. X = 300 + X If ((I Mod 6) = 2) Then Y = 295 + 5 + Y X = 0 End If Next

'update the number of picutes left to be displayed If remainingPix > 6 Then remainingPix = remainingPix - 6 Else remainingPix = 0 End If

'update first picture on next page nextPix = nextPix + 6 End Sub

'set up buttons depending on number of images in query result 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled Private Sub updateButtons() If al.Count <= 6 Or remainingPix = 0 Then Me.Button3.Enabled = False Me.Button1.Enabled = True Else Me.Button3.Enabled = True Me.Button1.Enabled = False End If End Sub 'Procedure takes input from query form and assigns them to variables Public Sub initialize() Query = "select * from person where color.color = 'blue';" modifier = "very" color_face = "Blue" End Sub

Page 80: MemFunc.doc

'Event handling for 'Cancel' button. It closes the database connection and exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click con.Close() Me.Dispose() Me.Close() End End Sub

'Event handling for 'More' button 'It clears the panel, builds and displays next page 'set up buttons depending on number of images in query result Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'clear existing pictures Panel2.Controls.Clear()

'build and display next page placeComponents(nextPix) Panel2.Show()

'set up buttons depending on number of images in query result updateButtons() End Sub

'---------------------------------------------------------------- 'The class ImagesSet is a user defined class which has the image 'and the check boxes as its components.

Public Class ImageSet Public picture As PictureBox Public meets_criteria As RadioButton Public no_criteria_meet As RadioButton Public ID As Integer

Public Sub New(ByVal color_face As String) picture = New PictureBox meets_criteria = New RadioButton no_criteria_meet = New RadioButton meets_criteria.Text = "Satisfied with result" meets_criteria.Checked = True 'Changes the labels on the Check Boxes depending on the query. no_criteria_meet.Text = "Not satisfied with result" ID = 0 End Sub End ClassEnd Class

Appendix C

Statistical Method to Construct Membership Weight for Images

For each image, following is shown• Table of Scores representing user’s view on blue eye color

Page 81: MemFunc.doc

• Frequency Distribution table for image• Graph based on frequency distribution

Image 1 Scores 0-29 30-74 75-1000 1 0 025 1 0 033 0 1 039 0 1 044 0 1 046 0 1 052 0 1 053 0 1 054 0 1 062 0 1 065 0 1 069 0 1 070 0 1 071 0 1 074 0 1 075 0 0 186 0 0 193 0 0 199 0 0 1100 0 0 1100 0 0 1

2 13 6

Frequency Distribution of Image ID 1

0

2

4

6

8

10

12

14

0-29 30-74 75-100

Frequency Range

Fre

qu

enc

y

Page 82: MemFunc.doc

Image 2 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 03 1 0 06 1 0 014 1 0 021 1 0 024 1 0 025 1 0 044 0 1 046 0 1 050 0 1 052 0 1 053 0 1 059 0 1 064 0 1 069 0 1 070 0 1 079 0 0 197 0 0 1

10 9 2

Frequency Distribution of Image ID 2

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Image 3 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 02 1 0 03 1 0 07 1 0 012 1 0 012 1 0 018 1 0 020 1 0 021 1 0 027 1 0 034 0 1 047 0 1 050 0 1 055 0 1 063 0 1 080 0 0 1

15 5 1

Frequency Distribution of Image ID 3

0

2

4

6

8

10

12

14

16

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Page 83: MemFunc.doc

Image 4 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 07 1 0 010 1 0 011 1 0 017 1 0 020 1 0 023 1 0 042 0 1 052 0 1 058 0 1 069 0 1 0

17 4 0

Frequency Distribution of Image ID 4

0

2

4

6

8

10

12

14

16

18

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Image 5 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 02 1 0 05 1 0 05 1 0 06 1 0 027 1 0 029 1 0 055 0 1 0

20 1 0

Frequency Distribution of Image ID 5

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Page 84: MemFunc.doc

Image 6 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 05 1 0 07 1 0 013 1 0 027 1 0 072 0 1 0

20 1 0

Frequency Distribution of Image ID 6

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Image 7 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 05 1 0 07 1 0 010 1 0 010 1 0 012 1 0 012 1 0 014 1 0 015 1 0 017 1 0 045 0 1 073 0 1 093 0 0 1

18 2 1

Frequency Distribution of Image ID 7

0

2

4

6

8

10

12

14

16

18

20

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Page 85: MemFunc.doc

Image 8 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 06 1 0 010 1 0 031 0 1 036 0 1 0

19 2 0

Frequency Distribution of Image ID 8

0

2

4

6

8

10

12

14

16

18

20

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Image 9 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 06 1 0 09 1 0 010 1 0 012 1 0 020 1 0 033 0 1 034 0 1 035 0 1 037 0 1 039 0 1 040 0 1 046 0 1 060 0 1 065 0 1 078 0 0 183 0 0 1

10 9 2

Frequency Distribution of Image ID 9

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Page 86: MemFunc.doc

Image 10 Scores 0-29 30-74 75-10016 1 0 038 0 1 042 0 1 049 0 1 061 0 1 065 0 1 071 0 1 071 0 1 072 0 1 082 0 0 184 0 0 186 0 0 188 0 0 194 0 0 195 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1

1 8 12

Frequency Distribution of Image ID 10

0

2

4

6

8

10

12

14

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Image 11 Scores 0-29 30-74 75-10065 0 1 076 0 0 180 0 0 183 0 0 193 0 0 193 0 0 195 0 0 195 0 0 196 0 0 198 0 0 199 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1

0 1 20

Frequency Distribution of Image ID 11

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

en

cy

Page 87: MemFunc.doc

Image 12 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 05 1 0 010 1 0 013 1 0 014 1 0 020 1 0 024 1 0 025 1 0 027 1 0 033 0 1 040 0 1 047 0 1 051 0 1 060 0 1 070 0 1 072 0 1 083 0 0 1

13 7 1

Frequency Distribution of Image ID 12

0

2

4

6

8

10

12

14

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 13 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 0

21 0 0

Frequency Distribution of Image ID 13

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 88: MemFunc.doc

Image 14 Scores 0-29 30-74 75-1000 1 0 00 1 0 01 1 0 011 1 0 012 1 0 012 1 0 016 1 0 017 1 0 025 1 0 026 1 0 031 0 1 031 0 1 046 0 1 050 0 1 050 0 1 052 0 1 061 0 1 065 0 1 071 0 1 079 0 0 186 0 0 1

10 9 2

Frequency Distribution of Image ID 14

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 15 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 01 1 0 06 1 0 020 1 0 020 1 0 020 1 0 024 1 0 027 1 0 027 1 0 030 0 1 033 0 1 038 0 1 040 0 1 042 0 1 056 0 1 0100 0 0 1

14 6 1

Frequency Distribution of Image ID 15

0

2

4

6

8

10

12

14

16

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 89: MemFunc.doc

Image 16 Scores 0-29 30-74 75-1006 1 0 025 1 0 033 0 1 048 0 1 048 0 1 050 0 1 050 0 1 050 0 1 051 0 1 054 0 1 058 0 1 058 0 1 059 0 1 059 0 1 060 0 1 061 0 1 062 0 1 082 0 0 187 0 0 191 0 0 1100 0 0 1

2 15 4

Frequency Distribution of Image ID 16

0

2

4

6

8

10

12

14

16

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 17 Scores 0-29 30-74 75-1000 1 0 010 1 0 013 1 0 018 1 0 020 1 0 022 1 0 024 1 0 025 1 0 027 1 0 030 0 1 030 0 1 031 0 1 035 0 1 040 0 1 048 0 1 052 0 1 054 0 1 064 0 1 071 0 1 082 0 0 192 0 0 1

9 10 2

Frequency Distribution of Image ID 17

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 90: MemFunc.doc

Image 18 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 08 1 0 0

21 0 0

Frequency Distribution of Image ID 18

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 19 Scores 0-29 30-74 75-1003 1 0 08 1 0 010 1 0 021 1 0 027 1 0 031 0 1 039 0 1 039 0 1 041 0 1 046 0 1 048 0 1 050 0 1 057 0 1 060 0 1 061 0 1 061 0 1 067 0 1 072 0 1 080 0 0 182 0 0 1100 0 0 1

5 13 3

Frequency Distribution of Image ID 19

0

2

4

6

8

10

12

14

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 91: MemFunc.doc

Image 20 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 05 1 0 010 1 0 010 1 0 017 1 0 017 1 0 021 1 0 022 1 0 034 0 1 039 0 1 041 0 1 047 0 1 048 0 1 050 0 1 054 0 1 058 0 1 060 0 1 093 0 0 1

11 9 1

Frequency Distribution of Image ID 20

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 21 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 03 1 0 011 1 0 0

21 0 0

Frequency Distribution of Image ID 21

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 92: MemFunc.doc

Image 22 Scores 0-29 30-74 75-1006 1 0 010 1 0 024 1 0 030 0 1 031 0 1 033 0 1 046 0 1 050 0 1 058 0 1 059 0 1 067 0 1 069 0 1 071 0 1 078 0 0 179 0 0 180 0 0 180 0 0 188 0 0 193 0 0 1100 0 0 1100 0 0 1

3 10 8

Frequency Distribution of Image ID 22

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 23 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 022 1 0 0

21 0 0

Frequency Distribution of Image ID 23

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 93: MemFunc.doc

Image 24 Scores 0-29 30-74 75-10014 1 0 027 1 0 030 0 1 034 0 1 044 0 1 065 0 1 066 0 1 067 0 1 073 0 1 075 0 0 175 0 0 176 0 0 176 0 0 177 0 0 184 0 0 186 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1

2 7 12

Frequency Distribution of Image ID 24

0

2

4

6

8

10

12

14

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 25 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 05 1 0 016 1 0 024 1 0 056 0 1 0

20 1 0

Frequency Distribution of Image ID 25

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 94: MemFunc.doc

Image 26 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 07 1 0 0

21 0 0

Frequency Distribution of Image ID 26

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 27 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 010 1 0 015 1 0 029 1 0 0

21 0 0

Frequency Distribution of Image ID 27

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 95: MemFunc.doc

Image 28 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 06 1 0 0

21 0 0

Frequency Distribution of Image ID 28

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 29 Scores 0-29 30-74 75-1009 1 0 012 1 0 014 1 0 016 1 0 022 1 0 024 1 0 030 0 1 031 0 1 034 0 1 036 0 1 041 0 1 045 0 1 054 0 1 057 0 1 057 0 1 057 0 1 057 0 1 063 0 1 065 0 1 069 0 1 071 0 1 0

6 15 0

Frequency Distribution of Image ID 29

0

2

4

6

8

10

12

14

16

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 96: MemFunc.doc

Image 30 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 06 1 0 015 1 0 052 0 1 071 0 1 0

19 2 0

Frequency Distribution of Image ID 30

0

2

4

6

8

10

12

14

16

18

20

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 31 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 016 1 0 018 1 0 027 1 0 029 1 0 046 0 1 049 0 1 050 0 1 051 0 1 063 0 1 063 0 1 066 0 1 066 0 1 069 0 1 076 0 0 180 0 0 1100 0 0 1100 0 0 1100 0 0 1

7 9 5

Frequency Distribution of Image ID 31

0

1

2

3

4

5

6

7

8

9

10

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 97: MemFunc.doc

Image 32 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 011 1 0 035 0 1 0

20 1 0

Frequency Distribution of Image ID 32

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 33 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 014 1 0 016 1 0 020 1 0 025 1 0 030 0 1 033 0 1 042 0 1 050 0 1 056 0 1 056 0 1 067 0 1 069 0 1 073 0 1 090 0 0 195 0 0 1

10 9 2

Frequency Distribution of Image ID 33

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 98: MemFunc.doc

Image 34 Scores 0-29 30-74 75-1000 1 0 00 1 0 013 1 0 023 1 0 023 1 0 025 1 0 031 0 1 037 0 1 050 0 1 050 0 1 058 0 1 087 0 0 188 0 0 194 0 0 194 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1

6 5 10

Frequency Distribution of Image ID 34

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 35 Scores 0-29 30-74 75-1000 1 0 00 1 0 032 0 1 039 0 1 040 0 1 049 0 1 050 0 1 061 0 1 062 0 1 063 0 1 087 0 0 190 0 0 195 0 0 199 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1

2 8 11

Frequency Distribution of Image ID 35

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 99: MemFunc.doc

Image 36 Scores 0-29 30-74 75-1000 1 0 030 0 1 033 0 1 039 0 1 048 0 1 050 0 1 052 0 1 059 0 1 070 0 1 076 0 0 184 0 0 186 0 0 192 0 0 192 0 0 198 0 0 198 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1

1 8 12

Frequency Distribution of Image ID 36

0

2

4

6

8

10

12

14

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 37 Scores 0-29 30-74 75-10033 0 1 046 0 1 054 0 1 059 0 1 060 0 1 062 0 1 065 0 1 069 0 1 071 0 1 073 0 1 073 0 1 084 0 0 185 0 0 188 0 0 193 0 0 198 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1

0 11 10

Frequency Distribution of Image ID 37

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 100: MemFunc.doc

Image 38 Scores 0-29 30-74 75-10039 0 1 040 0 1 053 0 1 056 0 1 064 0 1 067 0 1 067 0 1 070 0 1 073 0 1 073 0 1 082 0 0 193 0 0 194 0 0 195 0 0 199 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1100 0 0 1

0 10 11

Frequency Distribution of Image ID 38

0

2

4

6

8

10

12

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Image 39 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 06 1 0 012 1 0 0

21 0 0

Frequency Distribution of Image ID 39

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 101: MemFunc.doc

Image 40 Scores 0-29 30-74 75-1000 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 00 1 0 07 1 0 013 1 0 026 1 0 045 0 1 0

20 1 0

Frequency Distribution of Image ID 40

0

5

10

15

20

25

0-29 30-74 75-100

Frequency Range

Fre

qu

ency

Page 102: MemFunc.doc

Membership Value Construction by Membership Value Random Method Construction by Direct Rating

ID Color Weight ModifierUser's

Satisfaction % ID Color Weight ModifierUser's

Satisfaction %1 Blue 0.25 Slightly Blue 67 1 Blue 0.52 Medium Blue 892 Blue 0.22 Slightly Blue 27 2 Blue 0.2 Slightly Blue 563 Blue 0.45 Medium Blue 40 3 Blue 0.2 Slightly Blue 444 Blue 0.74 Medium Blue 40 4 Blue 0.2 Slightly Blue 375 Blue 0.2 Slightly Blue 13 5 Blue 0.2 Slightly Blue 46 Blue 0.68 Medium Blue 7 6 Blue 0.2 Slightly Blue 77 Blue 0.2 Slightly Blue 27 7 Blue 0.2 Slightly Blue 448 Blue 0.2 Slightly Blue 7 8 Blue 0.2 Slightly Blue 79 Blue 0.84 Very Blue 27 9 Blue 0.2 Slightly Blue 70

10 Blue 0.87 Very Blue 67 10 Blue 0.87 Very Blue 6711 Blue 0.61 Medium Blue 53 11 Blue 0.87 Very Blue 8112 Blue 0.2 Slightly Blue 33 12 Blue 0.2 Slightly Blue 4813 Blue 0.72 Medium Blue 0 13 Blue 0.2 Slightly Blue 414 Blue 0.2 Slightly Blue 7 14 Blue 0.2 Slightly Blue 5215 Blue 0.2 Slightly Blue 47 15 Blue 0.2 Slightly Blue 2616 Blue 0.86 Very Blue 33 16 Blue 0.52 Medium Blue 7817 Blue 0.22 Slightly Blue 13 17 Blue 0.52 Medium Blue 4118 Blue 0.2 Slightly Blue 0 18 Blue 0.2 Slightly Blue 419 Blue 0.53 Medium Blue 67 19 Blue 0.52 Medium Blue 4820 Blue 0.52 Medium Blue 53 20 Blue 0.2 Slightly Blue 5221 Blue 0.39 Medium Blue 0 21 Blue 0.2 Slightly Blue 422 Blue 0.22 Slightly Blue 80 22 Blue 0.52 Medium Blue 9323 Blue 0.51 Medium Blue 0 23 Blue 0.2 Slightly Blue 424 Blue 0.87 Very Blue 73 24 Blue 0.87 Very Blue 6325 Blue 0.52 Medium Blue 0 25 Blue 0.2 Slightly Blue 1126 Blue 0.74 Very Blue 0 26 Blue 0.2 Slightly Blue 427 Blue 0.2 Slightly Blue 0 27 Blue 0.2 Slightly Blue 1128 Blue 0.75 Very Blue 7 28 Blue 0.2 Slightly Blue 1529 Blue 0.2 Slightly Blue 44 29 Blue 0.52 Medium Blue 6730 Blue 0.2 Slightly Blue 13 30 Blue 0.2 Slightly Blue 1531 Blue 0.87 Very Blue 60 31 Blue 0.52 Medium Blue 9632 Blue 0.2 Slightly Blue 0 32 Blue 0.2 Slightly Blue 433 Blue 0.52 Medium Blue 53 33 Blue 0.2 Slightly Blue 4434 Blue 0.53 Medium Blue 73 34 Blue 0.87 Very Blue 8935 Blue 0.87 Very Blue 100 35 Blue 0.87 Very Blue 9336 Blue 0.54 Medium Blue 93 36 Blue 0.87 Very Blue 8937 Blue 0.64 Medium Blue 73 37 Blue 0.52 Medium Blue 9338 Blue 0.54 Medium Blue 53 38 Blue 0.87 Very Blue 7839 Blue 0.39 Medium Blue 0 39 Blue 0.2 Slightly Blue 440 Blue 0.2 Slightly Blue 7 40 Blue 0.2 Slightly Blue 4

Appendix D

Page 103: MemFunc.doc

Instructions to install the Fuzzy Database Research on the Local Machine

1) Install VB.NET2) Install SQL Server Note: Order does not matter3) Install the folder called Fuzzy Research

The contents of this folder are as follows:• Folder DB: Contains the VB.NET code for our application. One will have

to install VB.NET to be able to view or modify the code.• Folder TestDeploy : Contains the executable for our application.

In order to install the application go to the subfolder Debug and double click on the windows installer program "TestDeploy

• StoredProcedures.doc: Contains all the stored procedures currently being used by the application

• To install database in SQL Sever, there will be one of the following file/ files:

o DATABASE_BACKUP_SEPT162004: Contains a backup of the database.

o DBResearch.mdf and DBResearch_log.LDF 4) Create two files called input.txt and input1.txt in the directory C:\

1) Input.txt contains the sql statement to be generated by NLI. For example

select * from person where color.color = 'blue';

2) Input1.txt contains the fuzzy modifier which is also generated by NLI. It should have the format of 'fuzzy modifier' crlf 'attribute to be modified'. For Example

mediumblue

5) Depending upon type of database file present in the database, restoring the database into SQL Server will require following steps:

o Restore the database backup called DATABASE_BACKUP_SEPT162004 which is in Folder, onto SQL Server where Database name: DBResearch using the Enterprise Manager instructions titled "How to restore a backup from a backup device".

o Restore the database using DBResearch.mdf and DBResearch_log.LDF file which is in the folder in the SQL Server Enterprise. Go to the databases tab. Right click onto databases. Under All Tasks menu, choose Attach Database. Select the DBResearch.mdf file in the MDF file of database to attach text box. Press ok. Under databases tab, DBResearch database will appear

Page 104: MemFunc.doc

6) In SQL Server Enterprise Manager, click on the databases. Then go tools menu. Choose SQL Server Configuration Properties. In the security tab, choose option SQL Server and Windows Authentication

7) In SQL Server Enterprise, expand security. In login, Choose new login. In general tab, name = dbresearch, choose SQL Server authentication, password: dbresearch, choose database called DBResearch. In Data Access tab, click DBResearch and permit public and db_owner

8) Setup ODBC in Administrator Tools of the Control Panel. Use Windows Authorization.9) Change the data source indicated in Public Class Form1 on line 116 to the name of local

machine which can be found out by going to properties of my computer. Compile the project to see results.