You are on page 1of 78

CHAPTER 1

INTRODUCTION
1.1 Preliminaries

The activity of finance is the application of a set of techniques that individuals and
organizations (entities) use to manage their money, particularly the differences between
income and expenditure and the risks of their investments. Finance is one of the most
important aspects of business management. Without proper financial planning a new
enterprise is unlikely to be successful. Managing money (a liquid asset) is essential to
ensure a secure future, both for the individual and an organization.

The term 'the stock market' is a concept for the mechanism that enables the trading of
company stocks (collective shares), other securities, and derivatives. Bonds are still
traditionally traded in an informal, over-the-counter market known as the bond market.
The stocks are listed and traded on stock exchanges which are entities (a corporation or
mutual organization) specialized in the business of bringing buyers and sellers of stocks
and securities together. History has shown that the price of shares and other assets is an
important part of the dynamics of economic activity, and can influence or be an indicator
of social mood. Rising share prices, for instance, tend to be associated with increased
business investment and vice versa. Share prices also affect the wealth of households and
their consumption. Therefore, central banks tend to keep an eye on the control and
behavior of the stock market and, in general, on the smooth operation of financial system
functions.

Many years ago, worldwide, buyers and sellers were individual investors, such as
wealthy businessmen, with long family histories (and emotional ties) to particular
corporations. Over time, markets have become more "institutionalized"; buyers and
sellers are largely institutions (e.g., pension funds, insurance companies, mutual funds,
hedge funds, investor groups, and banks)

1
A specific example of corporate finance is the sale of stock by a company to institutional
investors like investment banks, who in turn generally sell it to the public. The stock
gives whoever owns it part ownership in that company. If you buy one share of XYZ Inc,
and they have 100 shares outstanding (held by investors), you are 1/100 owner of that
company. Of course, in return for the stock, the company receives cash, which it uses to
expand its business in a process called equity financing.

1.2 Problem Domain


In the advent of 21st century the purchasing power of an individual is increasing day by
day. Today every body wants to increase his profit and for doing so people invest in
mutual funds, shares and other financial entities. A common man barely knows about
how to invest his money for maximum possible benefit and long term interest .A vast
knowledge of market and industry is needed to invest in fixtures like stocks and mutual
funds.
In market there are companies (investment companies) and people (CA ‘S, Brokers)
which help or guides the investor to invest his money. But we can’t check the
authenticity and reliability as the investor has to believe what they say and tell him to do
.In addition to this there is risk involved and these people and companies also take fees
and in turn they can also mislead their customers for their personal profits (As happened
a few years back the Harshad Mehta Scam and Ketan Parikh Scam). To encounter such
problems we need a system that guides the investor where to make the investment for
maximum possible benefit.

The investor is usually interested in making maximum profit in least possible time (that is
the average state of mind).Long term planning is least sought off in the case of many
investors. Keeping the above thing in mind we have to advise the user in such a way that
he is able to decide whether he should invest in a particular stock or not and if he is
investing he must be benefited. The system is based on historical data of stock market
which extracts similar patterns from the past and gives information for the future.

2
Financial market evolutions are described by both qualitative and quantitative data with a
temporal nature. Our data mining approach has to cope with large data streams while
taking into account all these aspects. Therefore, we chose to represent financial market
situations by means of event sequences. These events are obtained from market data. For
instance, in our current application domain, the data is available as a collection of events
as “trend to rise”, “trend to decline”, or “stable market. These patterns are mined from the
sequences of events.

1.3 Project Objective


The main objective of our project is to find whether the value of the stock is going to
increase or decrease in the future and based on the above fact advising the user whether
to invest on that stock or not.

1.4 Purpose
This system will eliminate the middleware of stock brokers and financial personnel like
CAs etc .As the number of fraud cases in stock market are increasing day by day for
example the multi million scam of Harshad Mehta and Ketan Parekh where these people
took undue advantage of the loop holes in the stock market and they looted the public
money. This system will facilitate the user to take his own decisions on the investments
he wants to make based on the historical data.

3
CHAPTER 2
ANALYSIS
First of all we have to face the fundamental problem for developing software, i.e.
problem of scale to satisfy the ultimate objective of requirement phase. The requirement
phase has to ensure that as far as possible all the requirements of the software are elicited
and analyzed clearly. Requirement analysis is a software engineering task that bridges the
gap between system level requirements engineering and software design. Requirement
analysis provides the software designer with a representation of information, function and
behavior that can be translated to data, architectural, interface, and component-level
designs.

2.1 Existing System


There are quite a few systems available in the market which advises on stock investments
and they mainly use data mining techniques such as decision tree models, auto regression
techniques or neural networks.

2.2 Proposed System


Our system is based on sequential pattern mining techniques which will extract similar
market situations from the past share prices .The output will be in the form of a advice
giving the trend of the market in the coming weeks/months/year. The user just needs to
have the elementary knowledge of stock market. He/she will enter the name of the
company he wants to invest and the system will provide the advice whether he/she should
invest in that share or not.

4
2.3 Feasibility Analysis
2.3.1 Technical Feasibility:-
A study of resources availability may affect the ability to achieve an acceptable system.
The technical feasibility is frequently the most difficult area to ensure at this stage.
Besides objective, functions, and performance are somewhat hazy; anything seems
possible if the right assumptions are made. It is essential that the process of analysis and
definition be conducted in parallel with an assessment of technical feasibility.

2.3.2 Economic Feasibility:-


A system that can be developed technically and that will be used if installed must still be
a good investment for the organization. Economical feasibility
1. The cost to conduct a full system investigation.
2. The cost to hardware and software for the application being considered.
3. The benefits in the form of reduced costs or fewer costly errors.

Economical justification is generally the “Bottom line Consideration” for most systems.
Economic justification includes a broad range of concerns that include cost benefit
analysis. Cost benefit analysis delineates costs for project development and weighs them
against tangible (i.e. measurable directly) and intangible benefits of a system.
Software testing is a critical element of software quality assurance and represents the
ultimate review of specification’s design, and coding. The point was kept in mind through
out the software development activity and a conscious effort was made to test the system
as thoroughly as possible. The objective behind this was to systematically uncover
different classes of errors with a minimum amount of time and effort.

2.4 Software Requirements:


2.4.1 MySQL
We will use Mysql Enterprise 5.0 as a back end for storing the database of our financial
advisory system.
MySQL has been the database of choice for managing high-volume web sites and
embedded database applications for years, version 5.0 provides exceptional new

5
functionality that paves the way for larger adoption at the enterprise level. Advancements
in the areas of application development, transactional processing, data integrity, and
manageability put the MySQL database server on par with proprietary database vendors
whose costs are many times more.
MySQL database software delivers optimal performance, reliability, security, and uptime.
MySQL Enterprise includes following features:
1 Easy to Install and Deploy
2 Scalability and Flexibility

3 Robust Transactional Support

4 Easy to Administer

5 High Performance

6 Reliability and High Availability

7 Embeddable Library

8 Web and Data Warehouse Strengths

9 Strong Data Protection

10 Lowest Total Cost of Ownership

11 Platform Independence

12 Open Source Freedom and 24 x 7 Support

2.4.2 Apache Tomcat


Apache Tomcat is a web container, or application server developed at the Apache
Software Foundation (ASF). Tomcat implements the servlet and the Java Server Pages
(JSP) specifications from Sun Microsystems, providing an environment for Java code to
run in cooperation with a web server. It adds tools for configuration and management but

6
can also be configured by editing configuration files that are normally XML-formatted.
Tomcat includes its own internal HTTP server.
Users have free access to the source code and to the binary form of Tomcat under the
Apache License. The initial Tomcat release appeared with versions 3.0.x (previous
releases were Sun internal releases, and were not publicly released). Tomcat 6.0.13 is the
latest production quality release of the 6.0.x trunk
(the branch for the 2.5 servlet specification), 2007.Features of Tomcat 6.x:

1. Implements the Servlet 2.5 and JSP 2.1 specifications


2. Support Unified Expression Language 2.1.
3. Designed to run on Java SE 5.0 and later.

2.4.3 JCreator
JCreator is a powerful IDE for Java
JCreator is the development tool for every programmer that likes to do what he does best:
programming. It is faster, more efficient and more reliable than other IDE’s. Therefore it
is the perfect tool for programmers of every level, from learning programmer to Java-
specialist.
JCreator provides the user with a wide range of functionality such as : Project
management, project templates, code-completion, debugger interface, editor with syntax
highlighting, wizards and a fully customizable user interface
With JCreator you can directly compile or run your Java program without activating
the main document first. JCreator will automatically find the file with the main method or
the html file holding the java applet, then it will start the appropriate tool.
JCreator is written entirely in C++, which makes it fast and efficient compared to the
Java based editors/IDE's.

7
2.5 Hardware Requirements:
The hardware chosen for the product had the following configuration:
1. Intel(R) 845GVSR motherboard
2. Pentium(R) 4 CPU 2.40GHz
3. 256MB of DDR RAM
4. 40 GB Hard disk
5. ATX cabinet

The consideration that is normally associated with technical feasibility includes resources
availability of the organization where the project is to be developed and implemented. By
taking these factors into consideration before developing, the resources availability at this
organization was observed and it was found that the resources available are adequate.
Thus, this project is considered technically feasible for development.

2.6 Data Mining Techniques


Data mining can be defined as "the nontrivial extraction of implicit, previously unknown,
and potentially useful information from data”. Data mining may also be defined as "the
science of extracting useful information from large data sets or databases".

Data mining is the principle of sorting through large amounts of data and picking out
relevant information. It is usually used by business intelligence organizations, and
financial analysts, but it is increasingly used in the sciences to extract information from
the enormous data sets generated by modern experimental and observational methods.

2.6.1 How does data mining work?

While large-scale information technology has been evolving separate transaction and
analytical systems, data mining provides the link between the two. Data mining software
analyzes relationships and patterns in stored transaction data based on open-ended user
queries. Several types of analytical software are available: statistical, machine learning,
and neural networks. Generally, any of four types of relationships are sought:

8
1. Classes: Stored data is used to locate data in predetermined groups. For example, a
restaurant chain could mine customer purchase data to determine when customers
visit and what they typically order. This information could be used to increase traffic
by having daily specials.

2. Clusters: Data items are grouped according to logical relationships or consumer


preferences. For example, data can be mined to identify market segments or consumer
affinities.

3. Associations: Data can be mined to identify associations. The beer-diaper example


is an example of associative mining.

4. Sequential patterns: Data is mined to anticipate behavior patterns and trends. For
example, an outdoor equipment retailer could predict the likelihood of a backpack
being purchased based on a consumer's purchase of sleeping bags and hiking shoes.

2.6.2 Data mining consists of five major elements:

1. Extract, transform, and load transaction data onto the data warehouse system.

2. Store and manage the data in a multidimensional database system.

3. Provide data access to business analysts and information technology professionals.

4. Analyze the data by application software.

4. Present the data in a useful format, such as a graph or table.

9
2.7 Sequential Pattern Mining
2.7.1 What Is Sequential Pattern Mining
1. Given a set of sequences, find the complete set of frequent subsequences A
sequence : < (ef) (ab) (df) c b >
2. A sequence database

SID sequence

10 <a(abc)(ac)d(cf)>

20 <(ad)c(bc)(ae)>

30 <(ef)(ab)(df)cb>

40 <eg(af)cbc>

3. An element may contain a set of items. Items within an element are unordered and
we list them alphabetically.
4. <a(bc)dc> is a subsequence of <a(abc)(ac)d(cf)>
5. Given support threshold min_sup =2, <(ab)c> is a sequential pattern

2.7.2 Challenges on Sequential Pattern Mining


1. A huge number of possible sequential patterns are hidden in databases
2. A mining algorithm should
1. Find the complete set of patterns, when possible, satisfying the minimum
support (frequency) threshold
2. Be highly efficient, scalable, involving only a small number of database
scans
3. Be able to incorporate various kinds of user-specific constraints
The sequence mining task is to discover a set of attributes, shared across time
among a large number of objects in a given database. In our domain, we have huge price

10
database of share market, where the objects represent companies and the attributes
represent shares. The discovered pattern will be the sequences of three market situations
“trend to rise” “trend to decline” and “trend of stability”. The tasks of discovering all
frequent sequences in large databases are quite challenging. The search space is very
large. With million of objects in the database the problem of I/O minimization becomes
paramount. However most current algorithms are iterative in nature requiring as many
full databases scans as the longest frequent sequence.

2.7.3 Sequential Pattern Mining Algorithms


1. Concept introductions and an initial Apriori-like algorithm.

2. Apriori-based method: GSP (Generalized Sequential Patterns)

3. Pattern-growth methods: FreeSpan & PrefixSpan

4. Vertical format-based mining: SPADE

5. Constraint-based sequential pattern mining (SPIRIT)

6. Mining closed sequential patterns: CloSpan

11
CHAPTER 3
DESIGN
Design is a meaningful engineering representation of something that is to be built.
It can be traced to a customer’s requirements and at the same time assessed for quality
against asset of predefined criteria for “good” design. In the software engineering
context, design focuses on four major areas of concern: data, architecture, interfaces, and
components. Software engineers design computer-based system, but the skills required at
each level of design work are different. At data and architectural level, design focuses on
patterns as they apply to the application to be built. At the interface level, human
ergonomics often dictate our design approach. At the component level, a “programming
approach” leads us to effective data and procedural designs. Design begins with the
requirements model. We work to transform this model into four levels of design detail:
data structure, system architecture, the interface representation and the component level
detail.

3.1 Algorithm Used : Spade


We will use SPADE (Sequential Pattern Discovery using Equivalence classes), for
discovering the set of all possible frequent sequences.
The key features of this algorithm are as follows:
1. It use a vertical id-list database format ,where we associate with each sequence a
list of objects in which it occurs, along with the time stamps. It will generate all
frequent sequences via simple temporal joins on id-list.
2. It decomposes the original search space in to smaller pieces which can be
processed independently in main memory.
3. It decouples the problem decomposition from the pattern search.
4. It enumerates the frequent sequences with in each sub space by using breadth-first
or depth-first search techniques.

Once the frequent sequences are known, they can be used to obtain rules that describe
the relation ship between different sequence items.

12
3.2 RAW DATA
Date Open High Low Close Volume Close*
9-Mar-06 128.54 129.57 124.15 124.28 30500 124.28
8-Mar-06 125.54 127.74 124.27 126.63 32700 126.63
7-Mar-06 131.25 131.26 128.04 129.48 34600 129.48
6-Mar-06 136.41 136.43 130.76 132.57 22000 132.57
3-Mar-06 137.48 138.71 136.65 137.15 22100 137.15
2-Mar-06 136.15 140.19 134.2 139.09 42100 139.09
1-Mar-06 134.92 136.26 134.15 135.47 27000 135.47
28-Feb-06 135.22 135.23 132.67 133.35 34400 133.35
27-Feb-06 138.53 138.58 135.45 135.67 38900 135.67
24-Feb-06 138.53 140.51 137.5 140.51 25600 140.51
23-Feb-06 141.53 141.54 136.95 137.05 15100 137.05
22-Feb-06 139.61 141.95 139.41 141.76 28700 141.76
21-Feb-06 141.32 141.95 139.92 140.64 25800 140.64
17-Feb-06 139.84 141.32 138.35 138.93 32700 138.93
16-Feb-06 134.55 138.06 134.13 137.38 36900 137.38
15-Feb-06 136.09 139.1 133.29 134.28 39900 134.28
14-Feb-06 136.02 138.32 134.31 137.61 28900 137.61
13-Feb-06 137.49 138.72 133.79 135.1 27600 135.1
10-Feb-06 142.15 142.18 136.78 138.66 30800 138.66
9-Feb-06 145.48 145.91 142.9 143.05 49400 143.05
8-Feb-06 142.47 143.2 139.1 140.8 51400 140.8
7-Feb-06 153.8 153.8 140.63 141.05 30500 141.05
6-Feb-06 149.43 151.8 149.34 151.8 19100 151.8
3-Feb-06 151.25 151.51 147.06 147.75 30000 147.75
2-Feb-06 154.57 155.07 150.4 152.11 47500 152.11
1-Feb-06 155.14 155.14 150.87 153.9 44400 153.9
31-Jan-06 151.91 156.47 151.89 154.19 30900 154.19
30-Jan-06 147.95 149.68 146.94 149.68 58900 149.68
27-Jan-06 147.22 148.78 145.79 146.79 47000 146.79

13
26-Jan-06 143.09 146.02 142.45 145.99 47400 145.99
25-Jan-06 144.57 145.41 142.71 144.02 27100 144.02
24-Jan-06 140.75 141.62 138.51 141.29 39100 141.29
23-Jan-06 141.19 141.53 138.7 141.42 42900 141.42
20-Jan-06 143.82 144.03 139.62 140.13 50300 140.13
19-Jan-06 140.22 142.38 139.58 141.88 37300 141.88
18-Jan-06 139.44 140.31 137.27 137.64 20900 137.64
17-Jan-06 141.77 144.34 141.22 141.97 18000 141.97
13-Jan-06 138.09 141.97 138.05 141.97 41700 141.97
12-Jan-06 137.35 139.45 136.79 137.59 44500 137.5

14
3.3 Proposed Implementation
EXTRACTING RAW SEQUENCES:
TIME PERIOD : 5 DAYS(A WEEK)

1st WEEK 2nd WEEK 3rd WEEK 4th WEEK

PRICE TREND PRICE. TREND PRICE. TREND PRICE TREND

147.0 I 153.0 I 150.0 S 152.0 I

144.0 I 151.0 I 150.0 D 151.0 I

141.0 S 150.0 I 152.0 D 150.0 I

141.0 I 148.0 S 154.0 I 149.0 D

140.0 I 148.0 S 150.0 D 154.0 D

In this sample database .We have four sequences, one sequence for a time period of 5
days.
We calculate three events of these sequences by comparing two days closing values.
For example:-
I – increase (if current day value – previous day value > 0)
D – Decrease (if current day value – previous day value<0 )
S - Stable (if current day value – previous day value =0 ).

Input values: Company share price, Time period.


Now by applying any pattern mining algorithms, we can predict the sequence of future
trends for a week. But by doing this we can only predict trends.
To predict values we will use probabilistic mathematical techniques.

15
Sequence-id Event-id Event
1 10/30/07 I
1 10/29/07 I
1 10/28/07 I
1 10/27/07 D
4th week
1 10/26/07 D
2 10/23/07 S
2 10/22/07 D
2 10/21/07 D
2 10/20/07 I
2 10/19/07 D 3rd week
3 10/16/07 I
3 10/15/07 I
3 10/14/07 I
3 10/13/07 S
3 10/12/07 S 2nd week
4 10/9/07 I
4 10/8/07 I
4 10/7/07 S
4 10/6/07 I
4 10/5/07 I 1st week

3.3.1 Frequent Sequences

Frequent 1 Frequency Frequent2 Frequency


-sequences I->I 3
I 4
D 2 I->D 1
S 3 I->S 1
D->I 2
D->D 2
Frequent 3 Frequency D->S 1
I->I->I 2 S->I 2

S->I->I 2 S->D 0
S->S 1
D->I->I 1

16
3.3.2 Rule Generation
Now after enumerating frequent sequences, we will generate rules that define the
relation ship between different sequence items.
For example: the sequence I->I occurs in 3 input sequences while seq D->I->I occurs in
2 input sequences. We can therefore say that if I->I occurs together, and then there is a
66% chance that D also occurs (D->II). Or we can say that the rule I->I => D->I->I has a
66% confidence. In this way we will generate rules.
Minimum support: Given a user specified threshold called the minimum support, we say
that a sequence is frequent if it occurs more than minimum support times.

17
3.4 Sequence of Events

Figure 1- Sequence Diagram

18
3.5 Pseudo Code
Pseudo code is written to get more clarity on the component so that the actual
implementation is made easier.

Component one
Register user (personal, financial details)
{
Set _login_and_password ();
}

Component two
Verify user (user-id, password)
{
Get_login_password ();
If login_id_valid (user-id, password)
{
Report error(‘Invalid login id’);
Return false;
}
}

Component three
User entry (company name, duration)
{
Get company name and duration
}

Component four
Algorithm_data (raw data set)
{

19
Load raw data set ():
Extract closing values ();
Generate seq
{ Enumerate seq ();
}
Get confidence ();
Get_max_confidence(seq_conf);
}

Component five
{
display advise();
}

20
CHAPTER 4
IMPLEMENTATION
This is the final phase of any software project development. It is the phase that
actually provides meaning to all the other phases. All the steps, starting from the
requirement analysis are carried out just for the sake of providing support to the
implementation. The implementation of this project is very difficult and long task if an
attempt is made to do so for all the possible variants and consideration of each and every
minor intricacy involved. Implementation model represents the current mode of
operation; that is the existing or proposed allocation for all system elements. The
essential model is generic in the sense that realization of function is not is not explicitly
indicated. Implementation is the development of the executable software as per design
specification of the desired system. The code generation step performs the task of
mapping system requirements as specified in the design phase into programming steps
that achieves the system functionality as specified by the user.
The implementation phase affects both testing and maintenance profoundly. The
time spent in implementation is small percentage of the total software cost, while testing
and maintenance consume the major percentage. Thus, the goal during implementation
should not be to reduce the implementation cost, but should be to reduce the cost of late
phases, even if it means that the cost of this phase has to increase. In other words, the
goal during this phase is not simplify the job of the programmer. Rather the goal should
be to simplify the job of tester & maintainer. Hence, keeping the consideration the above
facts, this tool is kept as modular as possible & proper documentation is provided for
maintainability. There are many different criteria for judging the program including
readability, size of the program, execution time and required memory.

21
4.1 Programming Languages

4.1.1 HTML
HTML, an acronym for Hyper Text Markup Language, is the predominant markup
language for web pages. It provides a means to describe the structure of text-based
information in a document — by denoting certain text as links, headings, paragraphs,
lists, and so on — and to supplement that text with interactive forms, embedded images,
and other objects. HTML is written in the form of tags, surrounded by angle brackets.
HTML can also describe, to some degree, the appearance and semantics of a document,
and can include embedded scripting language code (such as JavaScript) which can affect
the behavior of web browsers and other HTML processors.

4.1.2 JAVA
Java is a programming language originally developed by Sun Microsystems and released
in 1995 as a core component of Sun's Java platform. The language derives much of its
syntax from C and C++ but has a simpler object model and fewer low-level facilities.
Java applications are typically compiled to bytecode which can run on any Java virtual
machine (JVM) regardless of computer architecture.

One important characteristic of java is platform independence,which means that


programs written in the Java language run similarly on any supported
hardware/operating-system platform. One should be able to write a program once,
compile it once, and run it anywhere.

Java technology has become a complete software ecosystem that represents different
values to different types of consumer and business users. It offers developers a choice of
three Java platform editions depending on the need:

• 1. Java technology in small and mobile devices


• 2. Java technology in PC desktops
• 3. Java technology in medium to large businesses

22
For business, Java technology represents choice, performance, efficiency, and flexibility.
The Enterprise Java platform serves as an end-to-end infrastructure that gives IT
managers an extremely wide variety of compatible business logic applications,
independent of their application server or portal server vendor - whether it is BEA, IBM,
Oracle, or Sun. It significantly extends their reach and interactivity among employees,
customers, and partners. Just as important, IT managers know there is a global ecosystem
of Java developers, support engineers, and knowledge bases to reduce the risk and time
to deployment as well as the ongoing cost of ownership and maintenance. [29]

Java Server Pages (JSP) technology provides a simplified, fast way to create dynamic
web content. JSP technology enables rapid development of web-based applications that
are server and platform-independent. It allows software developers to dynamically
generate HTML, XML or other types of documents in response to a Web client request.
The technology allows Java code and certain pre-defined actions to be embedded into
static content.

The JSP syntax adds additional XML-like tags, called JSP actions, to be used to invoke
built-in functionality. Additionally, the technology allows for the creation of JSP tag
libraries that act as extensions to the standard HTML or XML tags. Tag libraries provide
a platform independent way of extending the capabilities of a Web server.

Java Servlet technology provides Web developers with a simple, consistent mechanism
for extending the functionality of a Web server and for accessing existing business
systems. A servlet can almost be thought of as an applet that runs on the server side--
without a face. Java servlets make many Web applications possible.

4.2 Front-End Implementation

4.2.1 Tools Used


(1) MICROSOFT FRONT PAGE
Microsoft FrontPage is an HTML (Hypertext Markup Language) editor and web site
administration tool from Microsoft. It is a powerful tool used to design, create and

23
publish web sites. FrontPage generates and organizes all the web site documents required
by a user for web site development. These documents can then be filled with the text,
pictures, sounds and other features as per the developer’s requirements.

By using a tool like FrontPage, creating a web site is much easier and more intuitive than
it was in the past. Also, knowledge of HTML, which is the language or code that web
browsers use to present web content, is not a prerequisite for designing a web site using
Front Page.

4.2.2 Graphical User Interface


4.2.2.1 Login Form

Figure 2

24
4.2.2.2 Home Page

Figure 3

25
4.2.2.3 Output

Figure 4

26
(2) JCREATOR

JCreator is a light-weight and powerful integrated development environment for Java


technologies. It is faster, more efficient and more reliable than other IDE’s. It provides a
wide range of functionalities such as project management, templates, customizable syntax
highlighting, debugger interface, class views, tabbed documents, wizards and a fully
customizable interface.

With JCreator one can directly compile or run his Java program without activating the
main document first. JCreator will automatically find the file with the main method or the
html file holding the java applet, and then it will start the appropriate tool.

4.3 Back-End Implementation


4.3.1 Software Used
For backend implementation, database software that we have used is MySQL
Enterprise Server (5.0).This software is the most reliable, secure and up-to-date version
of MySQL for cost-effectively delivering E-commerce, Online Transaction Processing
(OLTP), and multi-terabyte Data Warehousing applications. It is a fully integrated
transaction-safe, ACID compliant database with full commit, rollback, crash recovery and
row level locking capabilities. MySQL delivers the ease of use, scalability, and
performance that has made it MySQL the world’s most popular open source database. [30]

4.3.2 Database for Financial Advisory System


The data used was obtained from finance.yahoo in the form of excel sheets which
were further converted into my sql tables using a converter.
a) Database organization
The database conatains tables,which stores details of the daily prices of a company’s
share (open,close,high,low ,etc)

27
Below are the details of tables in the database and represents various fields with in each
table. Primary for each table is also given with each table.

1. COMPANY NAME
Company name
Sno
Open
Close
High
Low

4.4 Algorithm Implementation


import java.io.*;
import java.sql.*;
import java.io.IOException;
import java.io.PrintWriter;

class Frq1
{
void gen()
{
Connection x=null;
Statement s=null;
ResultSet z2=null,z1=null ;

try{
Class.forName("com.mysql.jdbc.Driver");

x=DriverManager.getConnection("jdbc:mysql:///fas","root","1234");
}catch(Exception e){}
try {
s=x.createStatement();

28
s.executeUpdate("create table Inc(sid INTEGER(10),Date
date)");
s.executeUpdate("Insert into Inc select sid,Date from
sheet1$ where status = 1");

s.executeUpdate("create table Dsc(sid INTEGER(10),Date


date)");
s.executeUpdate("Insert into Dsc select sid,Date from
sheet1$ where status = 2");

s.executeUpdate("create table Sta(sid INTEGER(10),Date


date)");
s.executeUpdate("Insert into Sta select sid,Date from
sheet1$ where status = 3");

x.close();
}

catch(Exception e){System.out.println("errror is : "+e);}


}
public static void main(String args[])
{
Frq1 f=new Frq1();
f.gen();
}
}

import java.io.*;

29
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.io.IOException;
import java.io.PrintWriter;

class Predict
{
public static void main(String args[])
{
String arr = new String();
int row=0,i=0,seq,flag;
float val,conf1=0,conf2=0,conf3=0;
Connection x=null;
Statement s=null;
ResultSet z2=null,z1=null ;
Frqcount obj = new Frqcount();
obj.count();

try
{
Class.forName("com.mysql.jdbc.Driver");

x=DriverManager.getConnection("jdbc:mysql:///fas","root","1234");
}
catch(Exception e)
{
System.out.println("error in drivers : "+e);
}

try

30
{
s=x.createStatement();
System.out.println("Executing");
z1=s.executeQuery("select status from sheet1$ where sid=(select
max(sid) from sheet1$) and status!=0");
z1.afterLast();
z1.previous();
row = z1.getRow();
System.out.println("Total rows are "+row);
if(row<2)
{
z1=s.executeQuery("select status from sheet1$ where sid=((select
max(sid) from sheet1$)-1) and status!=0");
}
z1.beforeFirst();
while(z1.next())
{
System.out.println("Going in switch ");
row = z1.getInt(1);
if(i==2)
break;
switch(row)
{
case 1 : arr="1"+arr;i++;break;
case 2 : arr="2"+arr;i++;break;
case 3 : arr="3"+arr;i++;

}
}
System.out.println("String is : "+arr);
seq = Integer.parseInt(arr);

31
switch(seq)
{

case 11 :
conf1=obj.III_II;
conf2=obj.IID_II;
conf3=obj.IIS_II;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 12 :
conf1=obj.IDI_ID;
conf2=obj.IDD_ID;
conf3=obj.IDS_ID;
val = conf1;
flag=1;
if(conf2>=val)
{

32
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 13 :
conf1=obj.ISI_IS;
conf2=obj.ISD_IS;
conf3=obj.ISS_IS;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

33
case 21 :
conf1=obj.DII_DI;
conf2=obj.DID_DI;
conf3=obj.DIS_DI;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 22 :
conf1=obj.DDI_DD;
conf2=obj.DDD_DD;
conf3=obj.DDS_DD;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;

34
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 23 :
conf1=obj.DSI_DS;
conf2=obj.DSD_DS;
conf3=obj.DSS_DS;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 31 :

35
conf1=obj.SII_SI;
conf2=obj.SID_SI;
conf3=obj.SIS_SI;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 32 :
conf1=obj.SDI_SD;
conf2=obj.SDD_SD;
conf3=obj.SDS_SD;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)

36
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 33 :
conf1=obj.SSI_SS;
conf2=obj.SSD_SS;
conf3=obj.SSS_SS;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

37
catch(Exception e)
{
System.out.println("Error : "+e);
}
}
}
/*
class Sequence
{
void prediction(ResultSet z1,class Frqcount obj)
{
String arr = new String();
int row=0,i=0,seq,flag;
float val,conf1=0,conf2=0,conf3=0;
while(z1.next())
{
System.out.println("Going in switch ");
row = z1.getInt(1);
if(i==2)
break;
switch(row)
{
case 1 : arr="1"+arr;i++;break;
case 2 : arr="2"+arr;i++;break;
case 3 : arr="3"+arr;i++;

}
}
System.out.println("String is : "+arr);
seq = Integer.parseInt(arr);
switch(seq)

38
{

case 11 :
conf1=obj.III_II;
conf2=obj.IID_II;
conf3=obj.IIS_II;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 12 :
conf1=obj.IDI_ID;
conf2=obj.IDD_ID;
conf3=obj.IDS_ID;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;

39
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 13 :
conf1=obj.ISI_IS;
conf2=obj.ISD_IS;
conf3=obj.ISS_IS;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

40
case 21 :
conf1=obj.DII_DI;
conf2=obj.DID_DI;
conf3=obj.DIS_DI;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 22 :
conf1=obj.DDI_DD;
conf2=obj.DDD_DD;
conf3=obj.DDS_DD;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}

41
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 23 :
conf1=obj.DSI_DS;
conf2=obj.DSD_DS;
conf3=obj.DSS_DS;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 31 :
conf1=obj.SII_SI;

42
conf2=obj.SID_SI;
conf3=obj.SIS_SI;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 32 :
conf1=obj.SDI_SD;
conf2=obj.SDD_SD;
conf3=obj.SDS_SD;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{

43
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

case 33 :
conf1=obj.SSI_SS;
conf2=obj.SSD_SS;
conf3=obj.SSS_SS;
val = conf1;
flag=1;
if(conf2>=val)
{
val = conf2;
flag=2;
}
else if(conf3>=val)
{
val = conf3;
flag=3;
}
System.out.println("Value is "+val+" and next
sequence is "+flag);
break;

}
}
}

44
4.5 Testing
TESTING MODULE
Week Selected Seq. Prediction for Actual Event True/ False
corresponding Monday
last 2 days of
week
1 SI D D T
2 SI D I
3 SS D S
4 DI D D T
5 SD S S T
6 SS D S
7 DS S S T
8 DS S I
9 IS D D T
10 SS D D T
11 SS D D T
12 SS D I
13 SD D S
14 II I S
15 DS S D
16 DS S D
17 SD S I
18 DI D S
19 IS D S
20 IS D D T

We have tested our algorithm for the actual values present in our database.
This is for finding the accuracy.
ACCUARACY = TRUE CASES/TOTAL CASES = (9/20) * 100 = 45%

45
CHAPTER 5
CONCLUSION

5.1 inferenece

1. The user/investor has to login in the system through a valid login name and
password .
2. When the user is authenticated he/she can choose the company in which he wants
to invest .
3. We achieved the following results :-
4. Upon entering the date for which the prediction was sought and company name
we got the trend(increase ,decrease or stable) of the date and the probability of
happening of that event.
5. We got a stable event with a probability of 0.58.We performed a test on previous
values and got an accuracy of 45%.
6. On the basis of these results we advised our user to perform a transaction or not.
7. An accuracy of 45% is not accurate enough and that is due to the fact that the
length of our frequent sequences is limited to only three.
8. Upon increasing the length of frequent sequence and the size of the data set better
accuracy can be obtained.

46
5.2 Future Enhancement

1. The financial entity for our system is stock, there are other fixtures such as mutual
funds, the system can be extended to include mutual funds and the same pattern
mining can be used to predict about them.

2. As the accuracy was only 45% .It can be increased by increasing the data sets and
increasing the length of the frequent sequences.

3. It is a pattern mining approach and therefore the results are not so accurate. We
can use some neural network approach to find the numerical value of the stock in
the future.

4. External market factors such as political change, change in the oil prices, natural
disasters were not taken into account while predicting the prices .They can be
included to obtain better results.

5. The system developed predicts the value of the next day till which the data is
available. It can be made to predict the value of the stock of the next week or even
next month making it more violable for the users.

47
References

1. citeseer.ist.psu.edu/zaki00spade.html

2. www.cs.uiuc.edu/~hanj.

3. Signing stock market situations by means of characteristic


sequential patterns by: M.Leleu1, J.F. Boulicaut

4. Wikipedia.org

5. Software engineering by R.Pressman

6. www.cs.rpi.edu/~zaki/PS/MLJ00.ps.gz

7. www.springerlink.com/index/N3T642725V615427.pdf

8. www.springerlink.com/index/N3T642725V615427.pdf

9. http://en.wikipedia.org/wiki/Data_mining

10. http://en.wikipedia.org/wiki/Financial_analyst

11. http://en.wikipedia.org/wiki/Prediction_market

12. www.cs.cornell.edu/johannes/papers/2002/kdd2002-spam.pdf

13. citeseer.ist.psu.edu/agrawal95mining.html

14.wwwsop.inria.fr/axis/personnel/Florent.Masseglia/International_Book_E
ncyclopedia_2005.pdf

48
SOURCE CODE

//frequent 1 sequences
import java.io.*;
import java.sql.*;
import java.io.IOException;
import java.io.PrintWriter;

class Frq1
{
void gen()
{
Connection x=null;
Statement s=null;
ResultSet z2=null,z1=null ;

try{
Class.forName("com.mysql.jdbc.Driver");

x=DriverManager.getConnection("jdbc:mysql:///fas","root","1234");
}catch(Exception e){}
try {
s=x.createStatement();

s.executeUpdate("create table Inc(sid INTEGER(10),Date


date)");
s.executeUpdate("Insert into Inc select sid,Date from
sheet1$ where status = 1");

49
s.executeUpdate("create table Dsc(sid INTEGER(10),Date
date)");
s.executeUpdate("Insert into Dsc select sid,Date from
sheet1$ where status = 2");

s.executeUpdate("create table Sta(sid INTEGER(10),Date


date)");
s.executeUpdate("Insert into Sta select sid,Date from
sheet1$ where status = 3");

x.close();
}
catch(Exception e){System.out.println("errror is : "+e);}
}
public static void main(String args[])
{
Frq1 f=new Frq1();
f.gen();
}
}

\\ Frequent 2 \\
import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.io.IOException;
import java.io.PrintWriter;

class Frqcount

50
{
public

float IIS_II,IIS_IS,IID_II,IID_ID,III_II,IDS_ID;
float
IDS_DS,IDD_ID,IDD_DD,IDI_ID,IDI_DI,ISS_IS,ISS_SS,ISD_IS,ISD_SD,ISI_IS,ISI_
SI,DIS_DI,DIS_IS,DID_DI,DID_ID,DII_DI,DII_II,DDS_DD,DDS_DS,DDD_DD,DDI_
DD;
float
DDI_DI,DSS_DS,DSS_SS,DSD_DS,DSD_SD,DSI_DS,DSI_SI,SIS_SI,SIS_IS,SII_SI,S
II_II,SDS_SD,SDS_DS,SDD_SD,SDD_DD,SDI_SD,SDI_DI,SSS_SS,SSD_SS,SSD_SD
,SSI_SS,SSI_SI;
float SID_SI,SID_ID;

void count()
{
int i=0;
Connection x=null;
Statement s=null;
ResultSet z2=null,z1=null ;

try{
Class.forName("com.mysql.jdbc.Driver");

x=DriverManager.getConnection("jdbc:mysql:///fas","root","1234");
}
catch(Exception e){System.out.println("error in drivers : "+e);}
try
{

s=x.createStatement();

51
System.out.println("Executing");
z1=s.executeQuery("select count(DISTINCT sid)from
Inc");
z1.next();
int I = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from


DSc");
z1.next();
int D = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
STA");
z1.next();
int S = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from Id");


z1.next();
int ID = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from


DD");
z1.next();
int DD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Di");
z1.next();
int DI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sd");

52
z1.next();
int SD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
SS");
z1.next();
int SS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from II");
z1.next();
int II = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
I_s");
z1.next();
int IS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from Si");
z1.next();
int SI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ds");
z1.next();
int DS = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from


Iid");
z1.next();
int IID = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Iis");
z1.next();
int IIS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
III");

53
z1.next();
int III = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Idd");
z1.next();
int IDD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ids");
z1.next();
int IDS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Idi");
z1.next();
int IDI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Isd");
z1.next();
int ISD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Iss");
z1.next();
int ISS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Isi");
z1.next();
int ISI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Did");
z1.next();
int DID = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from Dis");

54
z1.next();
int DIS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dii");
z1.next();
int DII = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
DDD");
z1.next();
int DDD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dds");
z1.next();
int DDS= z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ddi");
z1.next();
int DDI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dsd");
z1.next();
int DSD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dss");
z1.next();
int DSS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dsi");

z1.next();
int DSI = z1.getInt(1);

55
z1=s.executeQuery("select count(DISTINCT sid)from
Sid");
z1.next();
int SID = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from Sis");
z1.next();
int SIS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sii");
z1.next();
int SII = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sdd");
z1.next();
int SDD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sds");
z1.next();
int SDS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sdi");
z1.next();
int SDI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ssd");
z1.next();
int SSD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
SSS");
z1.next();
int SSS = z1.getInt(1);

56
z1=s.executeQuery("select count(DISTINCT sid)from
Ssi");
z1.next();
int SSI = z1.getInt(1);
System.out.println("the value of SSI is "+SSI);

// Confidence Generation For Frequent 3 Sequences

IIS_II=(IIS*100)/II;
System.out.println("the value is "+ IIS_II);
IIS_IS=(IIS*100)/IS;
System.out.println("the value is "+ IIS_IS);
IID_II=(IID*100)/II;
System.out.println("the value is "+ IID_II);
IID_ID=(IID*100)/ID;
System.out.println("the value is "+ IID_ID);
III_II=(III*100)/II;
System.out.println("the value is "+ III_II);
IDS_ID=(IDS*100)/ID;
System.out.println("the value is "+ IDS_ID);
IDS_DS=(IDS*100)/DS;
System.out.println("the value is "+ IDS_DS);
IDD_ID=(IDD*100)/ID;
IDD_DD=(IDD*100)/DD;
IDI_ID=(IDI*100)/ID;
IDI_DI=(IDI*100)/DI;
ISS_IS=(ISS*100)/IS;
ISS_SS=(ISS*100)/SS;
ISD_IS=(ISD*100)/IS;
ISD_SD=(ISD*100)/SD;

57
ISI_IS=(ISI*100)/IS;
ISI_SI=(ISI*100)/SI;
DIS_DI=(DIS*100)/DI;
DIS_IS=(DIS*100)/IS;
DID_DI=(DID*100)/DI;
DID_ID=(DID*100)/ID;
DII_DI=(DII*100)/DI;
DII_II=(DII*100)/II;
DDS_DD=(DDS*100)/DD;
DDS_DS=(DDS*100)/DS;
DDD_DD=(DDD*100)/DD;
DDI_DD=(DDI*100)/DD;
DDI_DI=(DDI*100)/DI;
DSS_DS=(DSS*100)/DS;
DSS_SS=(DSS*100)/SS;
DSD_DS=(DSD*100)/DS;
DSD_SD=(DSD*100)/SD;
DSI_DS=(DSI*100)/DS;
DSI_SI=(DSI*100)/SI;
SIS_SI=(SIS*100)/SI;
SIS_IS=(SIS*100)/IS;
SII_SI=(SII*100)/SI;
SII_II=(SII*100)/II;
SID_SI=(SID*100)/SI;
SID_ID=(SID*100)/ID;
SDS_SD=(SDS*100)/SD;
SDS_DS=(SDS*100)/DS;
SDD_SD=(SDD*100)/SD;
SDD_DD=(SDD*100)/DD;
SDI_SD=(SDI*100)/SD;
SDI_DI=(SDI*100)/DI;

58
SSS_SS=(SSS*100)/SS;
SSD_SS=(SSD*100)/SS;
SSD_SD=(SSD*100)/SD;
SSI_SS=(SSI*100)/SS;
SSI_SI=(SSI*100)/SI;

x.close();
}
catch(Exception e)
{
System.out.println("error "+e);
}
}

public static void main(String args[])


{
Frqcount obj = new Frqcount();
obj.count();
}

\\Frequency count

import java.io.*;
import java.sql.*;
import java.util.*;

59
import java.util.Date;
import java.io.IOException;
import java.io.PrintWriter;

class Frqcount
{
public

float IIS_II,IIS_IS,IID_II,IID_ID,III_II,IDS_ID;
float
IDS_DS,IDD_ID,IDD_DD,IDI_ID,IDI_DI,ISS_IS,ISS_SS,ISD_IS,ISD_SD,ISI_IS,ISI_
SI,DIS_DI,DIS_IS,DID_DI,DID_ID,DII_DI,DII_II,DDS_DD,DDS_DS,DDD_DD,DDI_
DD;
float
DDI_DI,DSS_DS,DSS_SS,DSD_DS,DSD_SD,DSI_DS,DSI_SI,SIS_SI,SIS_IS,SII_SI,S
II_II,SDS_SD,SDS_DS,SDD_SD,SDD_DD,SDI_SD,SDI_DI,SSS_SS,SSD_SS,SSD_SD
,SSI_SS,SSI_SI;
float SID_SI,SID_ID;

void count()
{
int i=0;
Connection x=null;
Statement s=null;
ResultSet z2=null,z1=null ;

try{
Class.forName("com.mysql.jdbc.Driver");

x=DriverManager.getConnection("jdbc:mysql:///fas","root","1234");
}

60
catch(Exception e){System.out.println("error in drivers : "+e);}
try
{

s=x.createStatement();

System.out.println("Executing");
z1=s.executeQuery("select count(DISTINCT sid)from
Inc");
z1.next();
int I = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from


DSc");
z1.next();
int D = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
STA");
z1.next();
int S = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from Id");


z1.next();
int ID = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from


DD");
z1.next();
int DD = z1.getInt(1);

61
z1=s.executeQuery("select count(DISTINCT sid)from
Di");
z1.next();
int DI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sd");
z1.next();
int SD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
SS");
z1.next();
int SS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from II");
z1.next();
int II = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
I_s");
z1.next();
int IS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from Si");
z1.next();
int SI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ds");
z1.next();
int DS = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from


Iid");
z1.next();
int IID = z1.getInt(1);

62
z1=s.executeQuery("select count(DISTINCT sid)from
Iis");
z1.next();
int IIS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
III");
z1.next();
int III = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Idd");
z1.next();
int IDD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ids");
z1.next();
int IDS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Idi");
z1.next();
int IDI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Isd");
z1.next();
int ISD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Iss");
z1.next();
int ISS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Isi");
z1.next();

63
int ISI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Did");
z1.next();
int DID = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from Dis");
z1.next();
int DIS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dii");
z1.next();
int DII = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
DDD");
z1.next();
int DDD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dds");
z1.next();
int DDS= z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ddi");
z1.next();
int DDI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dsd");
z1.next();
int DSD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dss");
z1.next();

64
int DSS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dsi");

z1.next();
int DSI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sid");
z1.next();
int SID = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from Sis");
z1.next();
int SIS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sii");
z1.next();
int SII = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sdd");
z1.next();
int SDD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sds");
z1.next();
int SDS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sdi");
z1.next();
int SDI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ssd");

65
z1.next();
int SSD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
SSS");
z1.next();
int SSS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ssi");
z1.next();
int SSI = z1.getInt(1);
System.out.println("the value of SSI is "+SSI);

// Confidence Generation For Frequent 3 Sequences

IIS_II=(IIS*100)/II;
System.out.println("the value is "+ IIS_II);
IIS_IS=(IIS*100)/IS;
System.out.println("the value is "+ IIS_IS);
IID_II=(IID*100)/II;
System.out.println("the value is "+ IID_II);
IID_ID=(IID*100)/ID;
System.out.println("the value is "+ IID_ID);
III_II=(III*100)/II;
System.out.println("the value is "+ III_II);
IDS_ID=(IDS*100)/ID;
System.out.println("the value is "+ IDS_ID);
IDS_DS=(IDS*100)/DS;
System.out.println("the value is "+ IDS_DS);
IDD_ID=(IDD*100)/ID;
IDD_DD=(IDD*100)/DD;

66
IDI_ID=(IDI*100)/ID;
IDI_DI=(IDI*100)/DI;
ISS_IS=(ISS*100)/IS;
ISS_SS=(ISS*100)/SS;
ISD_IS=(ISD*100)/IS;
ISD_SD=(ISD*100)/SD;
ISI_IS=(ISI*100)/IS;
ISI_SI=(ISI*100)/SI;
DIS_DI=(DIS*100)/DI;
DIS_IS=(DIS*100)/IS;
DID_DI=(DID*100)/DI;
DID_ID=(DID*100)/ID;
DII_DI=(DII*100)/DI;
DII_II=(DII*100)/II;
DDS_DD=(DDS*100)/DD;
DDS_DS=(DDS*100)/DS;
DDD_DD=(DDD*100)/DD;
DDI_DD=(DDI*100)/DD;
DDI_DI=(DDI*100)/DI;
DSS_DS=(DSS*100)/DS;
DSS_SS=(DSS*100)/SS;
DSD_DS=(DSD*100)/DS;
DSD_SD=(DSD*100)/SD;
DSI_DS=(DSI*100)/DS;
DSI_SI=(DSI*100)/SI;
SIS_SI=(SIS*100)/SI;
SIS_IS=(SIS*100)/IS;
SII_SI=(SII*100)/SI;
SII_II=(SII*100)/II;
SID_SI=(SID*100)/SI;
SID_ID=(SID*100)/ID;

67
SDS_SD=(SDS*100)/SD;
SDS_DS=(SDS*100)/DS;
SDD_SD=(SDD*100)/SD;
SDD_DD=(SDD*100)/DD;
SDI_SD=(SDI*100)/SD;
SDI_DI=(SDI*100)/DI;
SSS_SS=(SSS*100)/SS;
SSD_SS=(SSD*100)/SS;
SSD_SD=(SSD*100)/SD;
SSI_SS=(SSI*100)/SS;
SSI_SI=(SSI*100)/SI;

x.close();
}
catch(Exception e)
{
System.out.println("error "+e);
}
}

public static void main(String args[])


{
Frqcount obj = new Frqcount();
obj.count();
}

\\Frequent 3

68
import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.io.IOException;
import java.io.PrintWriter;

class Frqcount
{
public

float IIS_II,IIS_IS,IID_II,IID_ID,III_II,IDS_ID;
float
IDS_DS,IDD_ID,IDD_DD,IDI_ID,IDI_DI,ISS_IS,ISS_SS,ISD_IS,ISD_SD,ISI_IS,ISI_
SI,DIS_DI,DIS_IS,DID_DI,DID_ID,DII_DI,DII_II,DDS_DD,DDS_DS,DDD_DD,DDI_
DD;
float
DDI_DI,DSS_DS,DSS_SS,DSD_DS,DSD_SD,DSI_DS,DSI_SI,SIS_SI,SIS_IS,SII_SI,S
II_II,SDS_SD,SDS_DS,SDD_SD,SDD_DD,SDI_SD,SDI_DI,SSS_SS,SSD_SS,SSD_SD
,SSI_SS,SSI_SI;
float SID_SI,SID_ID;

void count()
{
int i=0;
Connection x=null;
Statement s=null;
ResultSet z2=null,z1=null ;

try{
Class.forName("com.mysql.jdbc.Driver");

69
x=DriverManager.getConnection("jdbc:mysql:///fas","root","1234");
}
catch(Exception e){System.out.println("error in drivers : "+e);}
try
{

s=x.createStatement();

System.out.println("Executing");
z1=s.executeQuery("select count(DISTINCT sid)from
Inc");
z1.next();
int I = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from


DSc");
z1.next();
int D = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
STA");
z1.next();
int S = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from Id");


z1.next();
int ID = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from


DD");

70
z1.next();
int DD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Di");
z1.next();
int DI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sd");
z1.next();
int SD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
SS");
z1.next();
int SS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from II");
z1.next();
int II = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
I_s");
z1.next();
int IS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from Si");
z1.next();
int SI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ds");
z1.next();
int DS = z1.getInt(1);

z1=s.executeQuery("select count(DISTINCT sid)from


Iid");

71
z1.next();
int IID = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Iis");
z1.next();
int IIS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
III");
z1.next();
int III = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Idd");
z1.next();
int IDD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ids");
z1.next();
int IDS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Idi");
z1.next();
int IDI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Isd");
z1.next();
int ISD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Iss");
z1.next();
int ISS = z1.getInt(1);

72
z1=s.executeQuery("select count(DISTINCT sid)from
Isi");
z1.next();
int ISI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Did");
z1.next();
int DID = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from Dis");
z1.next();
int DIS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dii");
z1.next();
int DII = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
DDD");
z1.next();
int DDD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dds");
z1.next();
int DDS= z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ddi");
z1.next();
int DDI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dsd");
z1.next();
int DSD = z1.getInt(1);

73
z1=s.executeQuery("select count(DISTINCT sid)from
Dss");
z1.next();
int DSS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Dsi");

z1.next();
int DSI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sid");
z1.next();
int SID = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from Sis");
z1.next();
int SIS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sii");
z1.next();
int SII = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sdd");
z1.next();
int SDD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sds");
z1.next();
int SDS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Sdi");
z1.next();

74
int SDI = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ssd");
z1.next();
int SSD = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
SSS");
z1.next();
int SSS = z1.getInt(1);
z1=s.executeQuery("select count(DISTINCT sid)from
Ssi");
z1.next();
int SSI = z1.getInt(1);
System.out.println("the value of SSI is "+SSI);

// Confidence Generation For Frequent 3 Sequences

IIS_II=(IIS*100)/II;
System.out.println("the value is "+ IIS_II);
IIS_IS=(IIS*100)/IS;
System.out.println("the value is "+ IIS_IS);
IID_II=(IID*100)/II;
System.out.println("the value is "+ IID_II);
IID_ID=(IID*100)/ID;
System.out.println("the value is "+ IID_ID);
III_II=(III*100)/II;
System.out.println("the value is "+ III_II);
IDS_ID=(IDS*100)/ID;
System.out.println("the value is "+ IDS_ID);
IDS_DS=(IDS*100)/DS;

75
System.out.println("the value is "+ IDS_DS);
IDD_ID=(IDD*100)/ID;
IDD_DD=(IDD*100)/DD;
IDI_ID=(IDI*100)/ID;
IDI_DI=(IDI*100)/DI;
ISS_IS=(ISS*100)/IS;
ISS_SS=(ISS*100)/SS;
ISD_IS=(ISD*100)/IS;
ISD_SD=(ISD*100)/SD;
ISI_IS=(ISI*100)/IS;
ISI_SI=(ISI*100)/SI;
DIS_DI=(DIS*100)/DI;
DIS_IS=(DIS*100)/IS;
DID_DI=(DID*100)/DI;
DID_ID=(DID*100)/ID;
DII_DI=(DII*100)/DI;
DII_II=(DII*100)/II;
DDS_DD=(DDS*100)/DD;
DDS_DS=(DDS*100)/DS;
DDD_DD=(DDD*100)/DD;
DDI_DD=(DDI*100)/DD;
DDI_DI=(DDI*100)/DI;
DSS_DS=(DSS*100)/DS;
DSS_SS=(DSS*100)/SS;
DSD_DS=(DSD*100)/DS;
DSD_SD=(DSD*100)/SD;
DSI_DS=(DSI*100)/DS;
DSI_SI=(DSI*100)/SI;
SIS_SI=(SIS*100)/SI;
SIS_IS=(SIS*100)/IS;
SII_SI=(SII*100)/SI;

76
SII_II=(SII*100)/II;
SID_SI=(SID*100)/SI;
SID_ID=(SID*100)/ID;
SDS_SD=(SDS*100)/SD;
SDS_DS=(SDS*100)/DS;
SDD_SD=(SDD*100)/SD;
SDD_DD=(SDD*100)/DD;
SDI_SD=(SDI*100)/SD;
SDI_DI=(SDI*100)/DI;
SSS_SS=(SSS*100)/SS;
SSD_SS=(SSD*100)/SS;
SSD_SD=(SSD*100)/SD;
SSI_SS=(SSI*100)/SS;
SSI_SI=(SSI*100)/SI;

x.close();
}
catch(Exception e)
{
System.out.println("error "+e);
}
}

public static void main(String args[])


{
Frqcount obj = new Frqcount();
obj.count();
}

77
78

You might also like