DETERMINING MEMBERSHIP FUNCTION VALUES TO OPTIMIZE RETRIEVAL IN A FUZZY RELATIONAL DATABASE

cobblerbeggarΤεχνίτη Νοημοσύνη και Ρομποτική

15 Οκτ 2013 (πριν από 3 χρόνια και 7 μήνες)

122 εμφανίσεις




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





Table of Contents



















P
age No.

1.
I
ntroduction
……………………………………………………
…………………
……………..
..
............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 Ling
uistic Approach to Fuzzy Set
…………………………
…………………….10


3
.2. Fuzzification
………………………………………………………
........................................
1
1


3
.3. Membership function determination
……………………………………
……………………12

4
. Project

D
escription
…………………………………………………………
…...
...
........
.........................15


4
.1
.

T
esting…
..
………………………………………………………………
……………………
1
5

4.2
. R
esult
s………………………………………………………………………………………..
19


4
.3.
Obstacles
………………………………………………………………
……………………
..23

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

24





References
…………
…………………………………………………

…………………….
………
...
25



Appendix
A.

Stored Procedure
s

………………………………………………
……………………..
.
27



Appendix
B.

Source
C
ode
………………………………………………………
...
.................................
37



Appendix
C.

Statistical Method to Construct Membership Wei
ght for Images

……………………..
79




Appendix
D.

Instructions to install the Fuzzy Database Research on the Local

Machine
....................101






1


1.

Introduction

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

decidedly

supe
rior to human beings in speed and preci
seness of calculation. However,

computers
do

not always satisf
y

users’ requirements. One reason
for

this
dis
satisfaction is the lack of
vagueness or imprecision, which are remarkable characteristics of humans. Impreci
sion 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 t
erms

(e.g. young
, big
) which
are fre
quently use
d

in daily
conversation.
Although t
hese words are ambiguous or uncertain
, communit
ies can

agree

on their
meanings
.

This paper
present
s

an overview of fuzzy relational database

theory and analyzes

the
p
r
ev
ious

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

deter
min
ing

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
us
ing

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.




2

1.1

Overview of Fuzzy Relational Database

Conventional relat
ional 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 cr
e
ated to describe the linguistic variables in mo
re 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 me
m
bership func
tion is then developed for each me
m
ber in the set.

Fuzzy logic and fuzzy sets were first intr
o
duced by Lotfi A. Zadeh

[2]
. Fuzzy sets were
d
e
rived
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
me
m
bers of the set. An element
x

belonging to a set
A

is defined as
x



A,
an element that is not
a me
m
ber in
A

is noted as
x


A
. A characteristic fun
c
tion 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


In

c
risp

set
s

the

membership function take
s

a value of 1or 0. F
or fuzzy sets
,

the membe
rship
function take
s

values in the inte
r
val [0
, 1
].
The range between 0 and 1 is referred to as the
membership grade or degree of membe
r
ship [5].



3

A fuzzy set
A

is defined
as
:



Where

A
(
x
) is a membership function belonging to the interval [0,

1].

Fuz
zy set theory
has
equivalent operations to those of crisp set theory
.
It includes
f
unctions
such as

equality, union
and intersection

[1]
.

A Fuzzy Relational Database extends a normal relational database by adding fuzzy logic,
fuzzy data and membership func
tions
. 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 tabl
e.

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
o
f heights, but it
would be more convenient to define the range as a relation:

4

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 th
e 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 effec
t,
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 in
to

the SELECT
-
FROM
-
WHERE block of SQL. Fuzziness is introduced at two levels
within the W
HERE 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:

5

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

Department (Dept#, D
-
name, Mana
ger, 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 p
aid” 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 pr
e
vious work

A

fuzzy relational database

[1]
,

which uses a natural language queryi
ng system to retrieve
images whose common
-
language descriptions are defined by the consensus of a particular user
community, was
pre
v
iously developed.

The architecture of
this

relational database system required
two layers to

process fuzzy
queries
.

The fir
st
l
ayer
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
wa
s used
. The syntax to query

the

database was

SELECT (attribute list)


FROM (rel
ation List)

WHERE (fuzzy conditions)

Fuzzy conditions are
conditions which use

fuzzy predicate
s such as

E
YE_COLOR =
SLIGHTLY
BLUE.
For each image, each of the possible values of
a

fuzzy
attribute and
its
6

corresponding

membership weights

were listed in
a
tu
ple

as shown in
T
able 1
.

The features

used
in

the

implementation were

“eye color” and “face width”. For eye color, possible values were
green, blue and brown
.

F
or face width, values
we
re broad, average and narrow.
A list of fuzzy
modifiers and their synony
ms 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
r
equesting 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 br
own could be
represented in the database as shown in Table 1.


IMAGE_ID

EYE_COLOR

WEIGHT (µ)

1

GREEN

0.8

1

BLUE

0.3

1

BROWN

0.0

Table
1:

Using Membership Values (Weights) for Each Attribute


Modifier

Range_From

Range_To

Midpoint

“Very”
=
〮㜵
=
ㄮN
=
〮㠷
=
“Medium”
=
〮㌰
=
〮㜴
=
⸵K
=
“Slightly”
=
〮M
=
〮㈹
=
⸲K
=
呡扬攠

=
䵯摩晩f爠剡nge猠s湤⁍n摰潩湴s
=
7


R
andom values between [0
, 1
]
were assigned as weight
s

or membership value
s

to each
attribute of every image when the program
wa
s

initialized for each particular user c
ommunity.

Each modifier
had

a threshold value that
wa
s at the midpoint of the modifier’s range. Threshold
value
wa
s designed to steady each attribute’s membership value within the modifier ranges so it
accurately represent
ed

each community’s consensus.

The

u
sers
,

after viewing the result of their
query, provide
d

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
wa
s
increased or decreased by 0.01
. For example, after
viewing the result of query EYE_COLOR =
VERY

BLUE, if
the
user
decide
d

that

the

image
should be defined by

a

stronger modifier
the
n

the weight was adjusted towards the
threshold

for
very blue

but

i
f the user
decided that the
image should be defined by

a

weaker modifier then the
weight was
decreased

by 0.01
.

T
hus, by adjusting the membership weight so that it was as deep
in the range as possible (i.e., at the midpoint), the community opinion wa
s strengthened with
concurring feedback.

This method of constructing membership value from the subjective
information is de
noted

as

the

Random Method
.


The
F
uzzy
Relational D
atabase wa
s
designed
to have
a
natural query
language
interface
where

a

user w
ou
l
d

enter
a

query

such as, “L
ist names of
the
persons with very
b
rown eyes

.
The
n
atural query

language

interface parse
d the

user query

into the actual query and the
modifier/attribute

pair
. Th
is

data
wa
s stored
into

separate

data

files
,

which
the
fuzzy relat
ion
al
database t
ook

as input. It then create
d

a fuzzy query,

quer
ie
d

the database and produce
d

the
result. After getting user
feedback
, the membership weight
s

w
ere

adjusted. This process
went

on
until

a

community consensus
wa
s

reached.


8

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.

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 system
s

learn through use of some sort of feedback or evolution or reaction to
its response of experience E. Broadly speaking ma
chine 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 com
paring 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"
. I
t 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 datab
ase

implementation

is to retrieve images by using
fuzzy queries whose common
-
language descriptions are defined by the consensus of a particular
9

user community. In everyday life, these
language

descriptions are subjective.
A person may be
described as havi
ng dark brown hair and

a

narrow face by one user and other user can
describe
that person
different
ly
. 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. T
hese definitions
depend
on

factors like culture

and
experience
,

and may change over time. Although it is difficult
to design a system which satisfies each user’s perception of facial
definitions,

a consensus can be
reached so that it satisfies most users

o
f 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: Retri
eval of images according to the criteria defined



Performance Measure P: Percent of community satisfaction



Training Experience E: User feedback









10

3
. Method
s

of Constructing Membership Function


A
membership function

(MF) is a curve that defines how e
ach 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.

Summary of Membership Functions



Fuzzy sets de
scribe 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 member
ship 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 approac
h 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. Ling
uistic
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:

11



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”;



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 i
n 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 t
he 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 t
he
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 s
ome values that will

be, at the
12

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 memb
ership value of

each input value in each fuzzy set.


3
.
3

Membership
F
unction
D
etermination



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

[14]
:

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

Direc
t 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 (s
et valued statistics):

give an interval in which you think the height of
John lies.

M
embership function exemplification:
What is the degree of belonging of John to the set
of tall people? In general, “To what degree
a

is
F
?”

P
airwise comparison:
which
pers
on

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
differen
t

individuals. The
answers are polle
d 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.

13

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 de
signed so that it will be hard for the subject to
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

paramete
rs 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 membe
rship 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 individual
s. 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 I
i

be the set
-
valued

observation (the interval) and m
i

the frequency with which

I
i

is observed. T
hen R = (Ii;

m
i
)
defines a random set.

It means that
m
i

population is defining the interval in which the fuzzy
term lies.

The r
est of the population defines the different interval for the Fness of a.

14


5
:

Membership Exemplification

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

large”, “small”

on scale of 0 to 100
.

Th
e same question is asked to the group of individuals. The
results are analyzed to determine membership function.

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
p
elican?”

Weights are then derived from the
princip
al 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 fro
m 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 obs
erver.

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 subject
ive interpretation of words, the foibles of human experts and generally all the
knowledge acquisition problems that are well documented

[
6
]

with knowledge based systems
.



15

4
. Project Description

Th
is

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
descriptions are defined by the consensus of a partic
ular 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 member
ship 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
u
ses
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 previou
s implementation

was modified
to alter

the method of assigning
the
membership v
alue
, 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

u
ser interface of both

the

prototypes was altered to make i
t user
friendly.
The source code with changes can be referenced in Appendix B.

In the direct rating method, r
andom 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 q
uestion
put to the community was “How blue
are

the eyes
?

and

they respond
ed

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

whereas

the right most bar on the sliding scale represen
ted that
the
eye were 100% blue.
The
training session was comprised of 21
people
. The values
given

for blue eye color attribute w
ere

recorded into the database as shown
in
F
igure 1
.



Figure 1
: Scores and Distribution for Image 1


The first column in
F
igu
re 1 represents

the community’s view
of the degree to which
image 1 had

blue eye
s.
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
17

ranges.
The frequency range
s

were chosen

based on range values of the very (75
-
100), medium
(30
-
74), slightly (0
-
29) modifiers
. The number of scores that f
e
ll into each freq
uency range was
calculated. The count
s
, 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
height of each rectangle
equal
s

the
number of scor
es in that range.
The frequency
histogram
for
each of the 40
image
s can be referenced in Appendix C
.
Based on
T
able
2;

each

image acquired
the threshold membership value

for the maximum
frequency range
. For example, 13 people out
of
21

chose

the medium blu
e eye color f
or

the image

1,

while 6 people out of 21
said

th
at the
image had very blue eyes. Therefore, t
he 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.

18



Figure 2: Membership Weights for Direct Rating Method


A

testing session was conducted

to compare both methods of eliciting membership values
and
t
o
determine which method gives the better community satisfaction. In the testing session,
19

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
represent
s

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
.




Figure
3: Comparison of Percent
age of user satisfaction for all images


4
.
2

Results


The proposed d
irect
r
ating method was

the better method to
determine

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

20



The direct rating method is more efficient because it rea
ches consensus with fewer
iteration
s
. For example, the random method can assign 1.0 membership value initially to
an image whose eyes are not blue. It w
ou
l
d

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 ac
hieved

a

higher user satisfaction in
80%

cases

compared to random method
.



It is efficient even for smaller communities
. For ran
dom 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 le
ast 100 feedbacks to assign 0.0
weights, provided each user’s perception is same.

However, t
here were many factors
that affected the resu
lts
.



The images were described by the community, not the database designers. Thus, it was
expected that each user cou
ld describe the same images differently. Therefore
a
term like
“very blue eye” is not objective but rather reflect
s

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 wa
s more on eye.

This

was true for both methods
.

But
in

th
is

real
world, perf
ect
pictures ca
n not

be

guaranteed

in such a system.

21



There were some images whose user satis
faction 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 maximu
m 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 assi
gned to the image to reach maximum satisfaction but
testing revealed 44% of user satisfaction.








Figure
4


It is suggested that frequency distribution should be recalculated by removing 0 score
value of the attribute. For example

in case of
F
igure
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
22

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

requires
further

testing.



The community w
hich trained the prototype and the tested the prototype was not same.
21 users trained
the both
prototype
s
. 27 users tested the direct rating method and 15 users
tested the random method.
T
h
e

varied community

may be the one reason for not reaching

communit
y’s consensus more than 80% for all images
. There may be other reasons such
as communities may never agree that often.
This

requires fu
r
t
her

testing.



The community did not define the range of modifier
s
. It was defined by the database
designer.
One user ca
n 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 de
fine 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 s
lightly modifier includes those image
s that have no blue eye color. The results
would have improved by excluding images with no blue eye color.

For example in
F
igure
4
,
only six

people would have described

the

image as slightly, if 0 score is ignored.


It is believed that if these factors we
re taken into account the direct rating method would
reach higher satisfaction.

But this requires more study.




23


4
.
3

Obstacles


There were many obstacles that had to be overcome to conduct
this
research. The main
obstacle was
learn
ing

and install
ing

Micro
soft .Net and SQL Server. Installation of
the
previous
prototype on the local machine caused lots of problems because of inadequate documentation.
Instruction
s

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

in
th
e
user interface
to use a
slide bar, making
the
user interface friendly to conduct
experiments, find
ing

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












24

5
.

Future Work


The research

raised some questions, which can be explored i
n 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 strategie
s 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 show
n 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 improve
ments 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 def
ine 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 uncle
ar pictures.

25

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.” Info
rmation 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 (7
th

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., Fuzz
y 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
&
Wan
g
, Xi
-
Zhao & Ha, Ming
-
Hu & Yin
-
Shan
,

Mining the Weights of
Similarity Measure Through Learning.

26

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

Managing Subjective
Information in Fuzzy Database Systems, 156


161
.

[13] Baklarz, George
,

Using N
eural 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
Measuremen
t
,

287
-
301.

















27

A
ppendix

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 */


CR
EATE 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
o
f 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_que
ry as varchar(500),

@high as float,@low as float

print @high



if @s2 = 'Blue' or


@s2='Green' or


@s2='Brown'


begin

28


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


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


print @s2


exec('select * from

Person P,Color C where


P.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=@s1


select @low

=low from Range where modifier=@s1



exec('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


F
etch_
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 float

print @high



if @s2 = 'Blue' or


@s2='Green' or


@s2='Brown'

29


begin


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


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


print @s2


exec('select * from Person P,ColorDirect C where


P.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=@s1


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



exec('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


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 weig
hts 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 col
or_weight CURSOR


for

select ID,color from color


OPEN color_weight


FETCH NEXT FROM color_weight

into @ID,@color


30

WHILE @@FETCH_STATUS = 0

BEGIN


print 'ID'


print @id


print 'color'


print @color


update color


set weight=rand()


where
ID=@id and color=@color


FETCH NEXT FROM color_weight


into @ID,@color

END


CLOSE color_weight

DEALLOCATE color_weight


DECLARE face_weight CURSOR


for

select ID,face from face


OPEN face_weight


FETCH NEXT FROM face_weight

into @ID,@face


WHILE @@FETCH_ST
ATUS = 0

BEGIN


print 'ID+Face'


print @id


print 'Face'


print @face


update Face


set weight=rand()


where ID=@id and Face=@face

FETCH NEXT FROM face_weight

into @ID,@face


END


CLOSE face_weight

DEALLOCATE face_weight


GO





31


E.

Inser
t_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,@Val
ueBlue)


end



else



begin



if @TypeBlue = 'less'



begin




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



end



end


end



GO





32


F.

Insert_Test
Old
_Data


/* Database Research Spring 2005


Shweta Sanghi


Insert_TestOld_Data
, stored proce
dure, 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 = 've
ry'


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 Test
Old (ID,LessBlue) values(@ID,@ValueBlue)



end



end


end



GO





33


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 PRO
CEDURE .[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 varc
har(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 mo
difier=@modifier


select @existing_weight=Weight from Color where ID=@ID and Color=@color


set @new_weight=@existing_weight


34

if @more_less = 'meets'

begin


if @existing_weight < @threshold


begin



set @new_weight = @existing_weight + .01


end


if @existin
g_weight > @threshold


begin



set @new_weight = @existing_weight
-

.01


end

end


else

begin


if @more_less = 'more'


begin



if @modifier = 'very'



begin




if @existing_weight > @threshold




begin





set @new_weight = @existing_weight
-

.01




end




if @existing_weight < @threshold




begin





set @new_weight = @existing_weight + .01




end



end



else



begin




set @new_weight = @existing_weight + .01



end


end


else


begin



if @modifier='slightly'



begin




if @existing_weight > @threshold




begin





set @new_weight = @existing_weight
-

.01




end




if @existing_weight < @threshold




begin





set @new_weight = @existing_weight + .01




end



end



else

35



begin




set @new_weight = @existing_weight
-

.01



end


end

end


update Color set wei
ght=@new_weight where ID=@ID and color=@color


end

if @color = 'Broad' or


@color = 'Average' or


@color='Narrow'


begin


select @threshold =threshold from Range where modifier=@modifier


select @existing_weight=Weight from Face where ID=@ID and
Face=@color


set @new_weight=@existing_weight


if @more_less = 'meets'

begin


if @existing_weight < @threshold


begin



set @new_weight = @existing_weight + .01


end


if @existing_weight > @threshold


begin



set @new_weight = @existing_weight
-

.01


end

e
nd


else

begin


if @more_less = 'more'


begin



if @modifier = 'very'



begin




if @existing_weight > @threshold




begin





set @new_weight = @existing_weight
-

.01




end




if @existing_weight < @threshold




begin





set @new_weight = @existing_weig
ht + .01




end



end



else



begin




set @new_weight = @existing_weight + .01

36



end


end


else


begin



if @modifier='slightly'



begin




if @existing_weight > @threshold




begin





set @new_weight = @existing_weight
-

.01




end




if @existing_weig
ht < @threshold




begin





set @new_weight = @existing_weight + .01




end



end



else



begin




set @new_weight = @existing_weight
-

.01



end


end

end


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


end


GO





















37

Appe
ndix 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.IO

Imports

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 Des
igner


'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

Button
3
As

System.Windows.Forms.Button

38


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
.Susp
endLayout()


'


'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(56
0, 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.D
rawing.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)

39


Me
.Button2.Name = "Button2"


Me
.Button2.Size =
New

System.Draw
ing.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
.Contr
ols.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 wh
ich 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 c
onnect 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

Butt
on3_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
"Fet
ch_All_Images" is

40


'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 = Comm
andType.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 re
turned 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)


N
ext

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


41


'The following block of cod
e 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 displa
ys 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 mat
ch 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 = Posi
tion1 + 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, 2
4)



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

42


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


next
Pix = 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


E
nd

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

Pi
ctureBox


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

43


'set up buttons depending on number of images in query result


Private

Sub

Button1_Click_1(
ByVal

sender
As

System.Object,
ByV
al

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 im
ages 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.O
bject,
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 mov
ement 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



D
im

daptr =
New

SqlDataAdapter


daptr.SelectCommand =
New

SqlCommand


daptr.SelectCommand.CommandType = CommandType.StoredProcedure


daptr.SelectCommand.CommandText = "dbo.Insert_Train_Data"


daptr.SelectCommand.C
onnection = con


'daptr.SelectCommand.Parameters.Add("@UserID", UserId)


daptr.SelectCommand.Parameters.Add("@ID", al(I).ID)


daptr.SelectCommand.Parameters.Add("@TrainBlue", TrainBlue)


con.Open()


Tr
y


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

Sub

End

Class

'Database Research Spring 2005

44

'Shweta Sanghi

'Main form is the start up form of the project. This forms asks the user
whether he wants to provide

'trai
ning 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

Cla
ss

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 initia
lization 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

No
thing
)
Then


components.Dispose()


End

If


End

If


MyBase
.Dispose(disposing)


End

Sub



'Required by the Windows Form Designer


Private

components