DWDM Lab
DWDM Lab
LABORATORY MANUAL
DATA WAREHOUSING AND MINING LAB
Mission
The Educational Objectives of the programme offered by the department are listed
below:
PEO-1: The graduates will be able to design and implement IT based solutions for
real life problems using modern engineering tools.
PEO-2: The graduates will have the ability to analyze and interpret experimental
results in frontier areas of Information Technology and an inclination for higher
learning in multidisciplinary areas.
PEO-3: The graduates will be able to communicate and work in a team effectively
for professional development.
PEO-4: The graduates will engage in lifelong learning while sustaining ethical and
human values
PROGRAM SPECIFIC OUTCOMES (PSOs)
PSO1: Analyze, design and implement IT enabled solutions to meet the industry needs
using appropriate tools & techniques.
PSO2: Storing, processing, analyzing and learning from data for effective decision-
making while finding solutions for problems.
PROGRAM OUTCOMES (POs)
Engineering Graduates will be able to:
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and
an engineering specialization to the solution of complex engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
3. Design / development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to
provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse
teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and
design documentation, make effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multi-disciplinary environments.
12. Life- long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
TKR COLLEGE OF ENGINEERING & TECHNOLOGY
Medboli, Meerpet, Balapur,Hyderabad, Telangana
1. Students are advised to come to the laboratory at least 5 minutes before (to the
starting time), those who come after 5 minutes will not be allowed into the lab.
2. Plan your task properly much before to the commencement, come prepared to the
lab with the synopsis / program / experiment details.
3. Student should enter into the laboratory with:
a. Laboratory observation notes with all the details (Problem statement, Aim,
Algorithm, Procedure, Program, Expected Output, etc.,) filled in for the lab session.
b. Laboratory Record updated up to the last session experiments and other utensils
(if any) needed in the lab.
c. Proper Dress code and Identity card.
4. Sign in the laboratory login register, write the TIME-IN, and occupy the
computer system allotted to you by the faculty.
5. Execute your task in the laboratory, and record the results / output in the
lab observation note book, and get certified by the concerned faculty.
6. All the students should be polite and cooperative with the laboratorystaff,
must maintain the discipline and decency in the laboratory.
7. Computer labs are established with sophisticated and high end branded
systems, which should be utilized properly.
8. Students / Faculty must keep their mobile phones in SWITCHED OFF mode
during the lab sessions.Misuse of the equipment, misbehaviors with the staff and
systems etc., will attract severe punishment.
9. Students must take the permission of the faculty in case of any urgency to go out ;
if anybody found loitering outside the lab / class without permission during
working hours will be treated seriously and punished appropriately.
10. Students should LOG OFF/ SHUT DOWN the computer system before he/she
leaves the lab after completing the task (experiment) in all aspects. He/she must
ensure the system / seat is kept properly.
COURSE OBJECTIVES:
Ability to understand the various kinds of tools demonstrate the classification clusters and in
large data sets
COURSE OUTCOMES:
1. Build a data warehouse and query it (using open source tools like Pentaho Data Integration and Pentaho
Business Analytics). L3
2. Demonstrate the working of algorithms for data mining tasks such association rule mining, classification,
clustering, and regression. L3
3. Practice the data mining techniques with varied input values for different parameters.L3
DATAWARE HOUSE TOOLS
ParAccel (Actian)
Cloudera
Talend
Query surge
Amazon Redshift
Teradata
Oracle
TabLeau
Open Source Data Mining Tools
WEKA
Orange
KNIME
R-Programming
Apache Mahout
Tanagra
XL Miner
Rapid Miner
DATA WAREHOUSING AND MINING LAB- INDEX
A. Build Data Warehouse/Daata Mart (using open source tools like Pentaho
Data Integration Tool, Pentaho Business Analytics; or other data warehouse
tools like Microsoft-SSIS,Informatica,Business Objects,etc.,)
4. Hire fact table: contains 1000 hire transactions since 1 Jan 2011. It is a daily snapshot
fact table so that every day we insert 1000 rows into this fact table. So over time we can
track the changes of total bill, van charges, satnav income, etc.
So now we are going to create the 3 tables in HireBase database: Customer, Van, and Hire.
Then we populate them.
PAGE 1 | TKRCET
Data Warehousing and Miining Lab Department of IT
Customer table:
Van table:
Hire table:
PAGE 2 | TKRCET
Data Warehousing and Mining Lab Department of IT
-- Populate
Customer truncate
table Customer go
TKRCET page 3
T
Data Warehousing and Mining Lab Department of IT
go
-- Populate Van
table truncate table
Van go
go
TKRCET page 4
Data Warehousing and Mining Lab Department of IT
declare @i int, @si varchar(10), @DaysFrom1stJan int, @CustomerId int, @RegNo int, @mi int
set @i = 1
while @i <= 1000
begin
set @si = right('000'+convert(varchar(10), @i),4) -- string of i
set @DaysFrom1stJan = (@i-1)%200 --The Hire Date is derived from i modulo
200 set @CustomerId = (@i-1)%100+1 --The CustomerId is derived from i modulo
100 set @RegNo = (@i-1)%20+1 --The Van RegNo is derived from i modulo 20
set @mi = (@i-1)%3+1 --i modulo 3
insert into Hire (HireId, HireDate, CustomerId, RegNo, NoOfDays, VanHire,
SatNavHire, Insurance, DamageWaiver, TotalBill)
values ('H'+@si, DateAdd(d, @DaysFrom1stJan, '2011-01-01'),
left('N0'+CONVERT(varchar(10),@CustomerId),3), 'Reg'+CONVERT(varchar(10),
@RegNo), @mi, @mi*100, @mi*10, @mi*20, @mi*40, @mi*170) set @i += 1
end
go
So now we are going to create the 3 dimension tables and 1 fact table in the data warehouse:
DimDate, DimCustomer, DimVan and FactHire. We are going to populate the 3 dimensions but
we‘ll leave the fact table empty. The purpose of this article is to show how to populate the fact
table using SSIS.
TKRCET Pa ge 5
Data Warehousing and Mining Lab Department of IT
Date Dimension:
Customer Dimension:
Van Dimension:
TKRCET Page 6
Data Warehousing and Mining Lab Department of IT
And then we do it. This is the script to create and populate those dim and fact tables:
TKRCET
Data Warehousing and Mining Lab Department of IT
go
insert into DimVan (RegNo, Make, Model, [Year], Colour, CC, Class)
select * from HireBase.dbo.Van
go
TKRCET
Data Warehousing and Mining Lab Department of IT
A(ii). Design multi-demesional data models namely Star, Snowflake and Fact
Constellation schemas for any one enterprise (ex. Banking,Insurance, Finance,
Healthcare, manufacturing, Automobiles,sales etc).
Multidimensional schema is defined using Data Mining Query Language (DMQL). The two
primitives, cube definition and dimension definition, can be used for defining the data warehouses
and data marts.
Star Schema
The following diagram shows the sales data of a company with respect to the
four dimensions, namely time, item, branch, and location.
There is a fact table at the center. It contains the keys to each of four dimensions.
The fact table also contains the attributes, namely dollars sold and units sold.
Data Warehousing and Mining Lab Department of IT
Snowflake Schema
Unlike Star schema, the dimensions table in a snowflake schema is normalized. For
example, the item dimension table in star schema is normalized and split into two
dimension tables, namely item and supplier table.
Now the item dimension table contains the attributes item_key, item_name, type,
brand, and supplier-key.
The supplier key is linked to the supplier dimension table. The supplier dimension
table contains the attributes supplier_key and supplier_type.
Data Warehousing and Mining Lab Department of IT
A fact constellation has multiple fact tables. It is also known as galaxy schema.
The following diagram shows two fact tables, namely sales and shipping.
The shipping fact table has the five dimensions, namely item_key, time_key,
shipper_key, from_location, to_location.
The shipping fact table also contains two measures, namely dollars sold and units sold.
It is also possible to share dimension tables between fact tables. For example, time,
item, and location dimension tables are shared between the sales and shipping fact
table.
Data Warehousing and Mining Lab Department of IT
Data Warehousing and Mining Lab Department of IT
A (iii) Write ETL scripts and implement using data warehouse tools.
ETL comes from Data Warehousing and stands for Extract-Transform-Load. ETL covers a process
of how the data are loaded from the source system to the data warehouse. Extraction–
transformation–loading (ETL) tools are pieces of software responsible for the extraction of data
from several sources, its cleansing, customization, reformatting, integration, and insertion into a
data warehouse.
Building the ETL process is potentially one of the biggest tasks of building a warehouse; it is
complex, time consuming, and consumes most of data warehouse project‘s implementation efforts,
costs, and resources.
Building a data warehouse requires focusing closely on understanding three main areas:
1. Source Area- The source area has standard models such as entity relationship diagram.
2. Destination Area- The destination area has standard models such as star schema.
3. Mapping Area- But the mapping area has not a standard model till now.
ETL Process:
Extract
The Extract step covers the data extraction from the source system and makes it accessible for
further processing. The main objective of the extract step is to retrieve all the required data from
the source system with as little resources as possible. The extract step should be designed in a way
that it does not negatively affect the source system in terms or performance, response time or any
kind of locking.
Update notification - if the source system is able to provide a notification that a record has
been changed and describe the change, this is the easiest way to get the data.
Incremental extract - some systems may not be able to provide notification that an update has
occurred, but they are able to identify which records have been modified and provide an extract
of such records. During further ETL steps, the system needs to identify changes and propagate
it down. Note, that by using daily extract, we may not be able to handle deleted records
properly.
Full extract - some systems are not able to identify which data has been changed at all, so a full
extract is the only way one can get the data out of the system. The full extract requires keeping
a copy of the last extract in the same format in order to be able to identify changes. Full extract
handles deletions as well.
Data Warehousing and Mining Lab Department of IT
Transform
The transform step applies a set of rules to transform the data from the source to the target. This
includes converting any measured data to the same dimension (i.e. conformed dimension) using the
same units so that they can later be joined. The transformation step also requires joining data from
several sources, generating aggregates, generating surrogate keys, sorting, deriving new calculated
values, and applying advanced validation rules.
Load
During the load step, it is necessary to ensure that the load is performed correctly and with as little
resources as possible. The target of the Load process is often a database. In order to make the load
process efficient, it is helpful to disable any constraints and indexes before the load and enable
them back only after the load completes. The referential integrity needs to be maintained by ETL
tool to ensure consistency
TKRCET
Data Warehousing and Mining Lab Department of IT
A (iv) Perform Various OLAP operations such slice, dice, roll up, drill up and pivot.
OLAP OPERATIONS
Online Analytical Processing Server (OLAP) is based on the multidimensional data model. It
allows managers, and analysts to get an insight of the information through fast, consistent, and
interactive access to information.
Roll-up
Drill-down
Slice and dice
Pivot (rotate)
Roll-up
Roll-up performs aggregation on a data cube in any of the following ways:
TKRCET
Data Warehousing and Mining Lab Department of IT
Initially the concept hierarchy was "street < city < province < country".
On rolling up, the data is aggregated by ascending the location hierarchy from the
level of city to the level of country.
When roll-up is performed, one or more dimensions from the data cube are removed.
Drill-down
Drill-down is the reverse operation of roll-up. It is performed by either of the following ways:
TKRCET
Data Warehousing and Mining Lab Department of IT
Drill-down is performed by stepping down a concept hierarchy for the dimension time.
Initially the concept hierarchy was "day < month < quarter < year."
On drilling down, the time dimension is descended from the level of quarter to the
level of month.
When drill-down is performed, one or more dimensions from the data cube are added.
It navigates the data from less detailed data to highly detailed data.
Slice
The slice operation selects one particular dimension from a given cube and provides a new sub-
cube. Consider the following diagram that shows how slice works.
TKRCET
Data Warehousing and Mining Lab Department of IT
Here Slice is performed for the dimension "time" using the criterion time = "Q1".
Dice
Dice selects two or more dimensions from a given cube and provides a new sub-cube. Consider
the following diagram that shows the dice operation.
TKRCET
Data Warehousing and Mining Lab Department of IT
The dice operation on the cube based on the following selection criteria involves three dimensions.
TKRCET
Data Warehousing and Mining Lab Department of IT
TKRCET
Data Warehousing and Mining Lab Department of IT
1. Download the software as your requirements from the below given link.
http://www.cs.waikato.ac.nz/ml/weka/downloading.html
2. The Java is mandatory for installation of WEKA so if you have already Java on your
machine then download only WEKA else download the software with JVM.
3. Then open the file location and double click on the file
4. Click Next
TKRCET
Data Warehousing and Mining Lab Department of IT
5. Click I Agree.
TKRCET
Data Warehousing and Mining Lab Department of IT
6. As your requirement do the necessary changes of settings and click Next. Full and
Associate files are the recommended settings.
TKRCET
Data Warehousing and Mining Lab Department of IT
8. If you want a shortcut then check the box and click Install.
9. The Installation will start wait for a while it will finish within a minute.
TKRCET
Data Warehousing and Mining Lab Department of IT
11. Hurray !!!!!!! That‘s all click on the Finish and take a shovel and start Mining. Best of
Luck.
TKRCET
Data Warehousing and Mining Lab Department of IT
This is the GUI you get when started. You have 4 options Explorer, Experimenter,
KnowledgeFlow and Simple CLI.
B (ii) Understand the features of WEKA tool kit such as Explorer, Knowledge flow
interface, Experimenter, command-line interface.
Ans: WEKA
The Weka GUI Chooser (class weka.gui.GUIChooser) provides a starting point for
launching Weka‘s main GUI applications and supporting tools. If one prefers a MDI (―multiple
document interface‖) appearance, then this is provided by an alternative launcher called ―Main‖
TKRCET
Data Warehousing and Mining Lab Department of IT
(class weka.gui.Main). The GUI Chooser consists of four buttons—one for each of the four major
Weka applications—and four menus.
Explorer An environment: for exploring data with WEKA (the rest of this
Documentation deals with this application in more detail).
Experimenter: An environment for performing experiments and conducting
statistical tests between learning schemes.
Knowledge Flow: This environment supports essentially the same functions as the
Explorer but with a drag-and-drop interface. One advantage is that it supports
incremental learning.
Simple CLI Provides: a simple command-line interface that allows direct execution of
WEKA commands for operating systems that do not provide their own command line
interface.
TKRCET
Data Warehousing and Mining Lab Department of IT
1. Explorer
Section Tabs
At the very top of the window, just below the title bar, is a row of tabs. When the Explorer
is first started only the first tab is active; the others are grayed out. This is because it is
necessary to open (and potentially pre-process) a data set before starting to explore the data.
The tabs are as follows:
Once the tabs are active, clicking on them flicks between different screens, on which the
respective actions can be performed. The bottom area of the window (including the status box, the
log button, and the Weka bird) stays visible regardless of which section you are in. The Explorer
can be easily extended with custom tabs. The Wiki article ―Adding tabs in the Explorer‖
explains this in detail.
2. Weka Experimenter:-
The Weka Experiment Environment enables the user to create, run, modify, and analyze
experiments in a more convenient manner than is possible when processing the schemes
individually. For example, the user can create an experiment that runs several schemes against a
series of datasets and then analyze the results to determine if one of the schemes is (statistically)
better than the other schemes.
TKRCET
Data Warehousing and Mining Lab Department of IT
The Experiment Environment can be run from the command line using the Simple CLI. For
example, the following commands could be typed into the CLI to run the OneR scheme on the Iris
dataset using a basic train and test process. (Note that the commands would be typed on one line
into the CLI.) While commands can be typed directly into the CLI, this technique is not particularly
convenient and the experiments are not easy to modify. The Experimenter comes in two flavors‘,
either with a simple interface that provides most of the functionality one needs for experiments, or
with an interface with full access to the Experimenter’s capabilities. You can
choose between those two with the Experiment Configuration Mode radio buttons:
Simple
Advanced
Both setups allow you to setup standard experiments, that are run locally on a single machine,
or remote experiments, which are distributed between several hosts. The distribution of
experiments cuts down the time the experiments will take until completion, but on the other hand
the setup takes more time. The next section covers the standard experiments (both, simple and
advanced), followed by the remote experiments and finally the analyzing of the results.
TKRCET
Data Warehousing and Mining Lab Department of IT
3. Knowledge Flow
Introduction
The Knowledge Flow provides an alternative to the Explorer as a graphical front end to
WEKA’s core algorithms.
The Knowledge Flow presents a data-flow inspired interface to WEKA. The user can select
WEKA components from a palette, place them on a layout canvas and connect them together in
order to form a knowledge flow for processing and analyzing data. At present, all of WEKA’s
classifiers, filters, clusterers, associators, loaders and savers are available in the
Knowledge Flow along with some extra tools.
The Knowledge Flow can handle data either incrementally or in batches (the Explorer
handles batch data only). Of course learning from data incremen- tally requires a classifier that can
TKRCET
Data Warehousing and Mining Lab Department of IT
be updated on an instance by instance basis. Currently in WEKA there are ten classifiers that can
handle data incrementally.
The Simple CLI provides full access to all Weka classes, i.e., classifiers, filters, clusterers,
etc., but without the hassle of the CLASSPATH (it facilitates the one, with which Weka was
started). It offers a simple Weka shell with separated command line and output.
TKRCET
Data Warehousing and Mining Lab Department of IT
Commands
Break
Stops the current thread, e.g., a running classifier, in a friendly manner kill stops the current
thread in an unfriendly fashion.
Cls
Clears the output area
Lists the capabilities of the specified class, e.g., for a classifier with its.
option:
exit
help [<command>]
TKRCET
Data Warehousing and Mining Lab Department of IT
Invocation
In order to invoke a Weka class, one has only to prefix the class with ‖java‖. This
command tells the Simple CLI to load a class and execute it with any given parameters. E.g., the
J48 classifier can be invoked on the iris dataset with the following command:
Command redirection
Note: the > must be preceded and followed by a space, otherwise it is not recognized as redirection,
but part of another parameter.
Command completion
Commands starting with java support completion for classnames and filenames via Tab
(Alt+BackSpace deletes parts of the command again). In case that there are several matches, Weka
lists all possible matches.
weka.classifiers
weka.clusterers
Classname completion
TKRCET
Data Warehousing and Mining Lab Department of IT
Possible matches:
weka.classifiers.meta.AdaBoostM1
weka.classifiers.meta.AdditiveRegression
weka.classifiers.meta.AttributeSelectedClassifier
Filename Completion
In order for Weka to determine whether a the string under the cursor is a classname or a
filename, filenames need to be absolute (Unix/Linx: /some/path/file;Windows: C:\Some\Path\file)
or relative and starting with a dot (Unix/Linux:./some/other/path/file; Windows:
.\Some\Other\Path\file).
TKRCET
Data Warehousing and Mining Lab Department of IT
TKRCET
Data Warehousing and Mining Lab Department of IT
An ARFF (= Attribute-Relation File Format) file is an ASCII text file that describes a list of
instances sharing a set of attributes.
ARFF files are not the only format one can load, but all files that can be converted with
Weka’s ―core converters‖. The following formats are currently supported:
ARFF (+ compressed)
C4.5
CSV
libsvm
binary serialized instances
XRFF (+ compressed)
Overview
ARFF files have two distinct sections. The first section is the Header information, which is
followed the Data information. The Header of the ARFF file contains the name of the relation, a
list of the attributes (the columns in the data), and their types.
2. Sources:
TKRCET
Data Warehousing and Mining Lab Department of IT
@RELATION iris
@ATTRIBUTE sepal length NUMERIC
@ATTRIBUTE sepal width NUMERIC
@ATTRIBUTE petal length NUMERIC
@ATTRIBUTE petal width NUMERIC
@ATTRIBUTE class {Iris-setosa, Iris-versicolor, Iris-irginica} The Data of the ARFF file looks
like the following:
@DATA
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
The ARFF Header section of the file contains the relation declaration and at-
tribute declarations.
The relation name is defined as the first line in the ARFF file. The format is: @relation
<relation-name>
where <relation-name> is a string. The string must be quoted if the name includes spaces.
TKRCET
Data Warehousing and Mining Lab Department of IT
Attribute declarations take the form of an ordered sequence of @attribute statements. Each
attribute in the data set has its own @attribute statement which uniquely defines the name
of that attribute and it’s data type. The order the attributes are declared indicates the
column position in the data section of the file. For example, if an attribute is the third one
declared then Weka expects that all that attributes values will be found in the third comma
delimited column.
where the <attribute-name> must start with an alphabetic character. If spaces are to be
included in the name then the entire name must be quoted.
numeric
integer is treated as numeric
real is treated as numeric
<nominal-specification>
string
date [<date-format>]
relational for multi-instance data (for future use)
where <nominal-specification> and <date-format> are defined below. The keywords numeric,
real, integer, string and date are case insensitive.
Numeric attributes
TKRCET
Data Warehousing and Mining Lab Department of IT
Nominal attributes
String attributes
String attributes allow us to create attributes containing arbitrary textual values. This is very
useful in text-mining applications, as we can create datasets with string attributes, then
write Weka Filters to manipulate strings (like String- ToWordVectorFilter). String
attributes are declared as follows:
Date attributes
Date attribute declarations take the form: @attribute <name> date [<date-format>] where
<name> is the name for the attribute and <date-format> is an optional string specifying how
date values should be parsed and printed (this is the same format used by
SimpleDateFormat). The default format string accepts the ISO-8601 combined date and
time format: yyyy-MM-dd’T’HH:mm:ss. Dates must be specified in the data section as
the corresponding string representations of the date/time (see example below).
Relational attributes
TKRCET
Data Warehousing and Mining Lab Department of IT
The ARFF Data section of the file contains the data declaration line and the actual instance
lines.
The @data declaration is a single line denoting the start of the data segment in the file. The
format is:
@data
Each instance is represented on a single line, with carriage returns denoting the end of the
instance. A percent sign (%) introduces a comment, which continues to the end of the line.
Attribute values for each instance are delimited by commas. They must appear in the order
that they were declared in the header section (i.e. the data corresponding to the nth
@attribute declaration is always the nth field of the attribute).
@data 4.4,?,1.5,?,Iris-setosa
Values of string and nominal attributes are case sensitive, and any that contain space or the
comment-delimiter character % must be quoted. (The code suggests that double-quotes are
acceptable and that a backslash will escape individual characters.)
TKRCET
Data Warehousing and Mining Lab Department of IT
Dates must be specified in the data section using the string representation specified in the
attribute declaration.
For example:
@RELATION Timestamps
@ATTRIBUTE timestamp DATE "yyyy-MM-dd HH:mm:ss" @DATA
"2001-04-03 12:12:12"
"2001-05-03 12:59:55"
Relational data must be enclosed within double quotes ‖. For example an instance of the
MUSK1 dataset (‖...‖ denotes an omission):
MUSK-188,"42,...,30",1
A (v) Explore the available data sets in WEKA.
TKRCET Page 51
Data Warehousing and Mining Lab Department of IT
contact-lens.arff
cpu.arff
cpu.with-vendor.arff
diabetes.arff
glass.arff
ionospehre.arff
iris.arff
labor.arff
ReutersCorn-train.arff
TKRCET Page 52
Data Warehousing and Mining Lab Department of IT
ReutersCorn-test.arff
ReutersGrain-train.arff
ReutersGrain-test.arff
segment-challenge.arff
segment-test.arff
soybean.arff
supermarket.arff
vote.arff
weather.arff
weather.nominal.arff
A. (vi) Load a data set (ex: Weather dataset, Iris dataset, etc.)
TKRCET Page 53
Data Warehousing and Mining Lab Department of IT
TKRCET Page 54
Data Warehousing and Mining Lab Department of IT
1. outlook
2. temperature
3. humidity
4. windy
5. play
TKRCET Page 55
Data Warehousing and Mining Lab Department of CSE
1. sunny
2. overcast
3. rainy
MRCET page 56
Data Warehousing and Mining Lab Department of IT
TKRCET Page 57
Data Warehousing and Mining Lab Department of IT
sunny,hot,high,FALSE,no
sunny,hot,high,TRUE,no
overcast,hot,high,FALSE,yes
rainy,mild,high,FALSE,yes
rainy,cool,normal,FALSE,yes
rainy,cool,normal,TRUE,no
overcast,cool,normal,TRUE,yes
sunny,mild,high,FALSE,no
sunny,cool,normal,FALSE,yes
rainy,mild,normal,FALSE,yes
sunny,mild,normal,TRUE,yes
overcast,mild,high,TRUE,yes
overcast,hot,normal,FALSE,yes
rainy,mild,high,TRUE,no
TKRCET Page 58
Data Warehousing and Mining Lab Department of IT
A. Explore various options in Weka for Preprocessing data and apply (like
Discretization Filters, Resample filter, etc.) n each dataset.
Ans:
Preprocess Tab
1. Loading Data
The first four buttons at the top of the preprocess section enable you to load data into
WEKA:
1. Open file .....Brings up a dialog box allowing you to browse for the data file on the local file
system.
2. Open URL. ....Asks for a Uniform Resource Locator address for where the data is stored.
3. Open DB .... Reads data from a database. (Note that to make this work you might have to edit
the file in weka/experiment/DatabaseUtils.props.)
4. Generate..... Enables you to generate artificial data from a variety of Data Generators. Using
the Open file ... button you can read files in a variety of formats: WEKA’s ARFF format, CSV
format, C4.5 format, or serialized Instances format. ARFF files typically have a .arff extension,
CSV files a .csv extension, C4.5 files a .data and .names extension, and serialized Instances objects
a .bsi extension.
TKRCET Page 59
Data Warehousing and Mining Lab Department of IT
Current Relation: Once some data has been loaded, the Preprocess panel shows a variety of
information. The Current relation box (the ―current relation‖ is the currently loaded
data, which can be interpreted as a single relational table in database terminology) has three entries:
1. Relation. The name of the relation, as given in the file it was loaded from. Filters (described
below) modify the name of a relation.
Below the Current relation box is a box titled Attributes. There are four buttons, and
beneath them is a list of the attributes in the current relation.
TKRCET Page 60
Data Warehousing and Mining Lab Department of IT
1. No. A number that identifies the attribute in the order they are specified in the data file.
2. Selection tick boxes. These allow you select which attributes are present in the relation.
3. Name. The name of the attribute, as it was declared in the data file. When you click ondifferent
rows in the list of attributes, the fields change in the box to the right titled Selected attribute.
This box displays the characteristics of the currently highlighted attribute in the list:
1. Name. The name of the attribute, the same as that given in the attribute list.
3. Missing. The number (and percentage) of instances in the data for which this attribute is
missing (unspecified).
4. Distinct. The number of different values that the data contains for this attribute.
5. Unique. The number (and percentage) of instances in the data having a value for this attribute
that no other instances have.
Below these statistics is a list showing more information about the values stored in this
attribute, which differ depending on its type. If the attribute is nominal, the list consists of each
possible value for the attribute along with the number of instances that have that value. If the
attribute is numeric, the list gives four statistics describing the distribution of values in the data—
the minimum, maximum, mean and standard deviation. And below these statistics there is a
coloured histogram, colour-coded according to the attribute chosen as the Class using the box
above the histogram. (This box will bring up a drop-down list of available selections when
clicked.) Note that only nominal Class attributes will result in a colour-coding. Finally, after
pressing the Visualize All button, histograms for all the attributes in the data are shown in a
separate window.
Returning to the attribute list, to begin with all the tick boxes are unticked.
TKRCET Page 61
Data Warehousing and Mining Lab Department of IT
They can be toggled on/off by clicking on them individually. The four buttons above can
also be used to change the selection:
PREPROCESSING
4. Pattern. Enables the user to select attributes based on a Perl 5 Regular Expression. E.g., .* id
selects all attributes which name ends with id.
Once the desired attributes have been selected, they can be removed by clicking the Remove
button below the list of attributes. Note that this can be undone by clicking the Undo button, which
is located next to the Edit button in the top-right corner of the Preprocess panel.
The preprocess section allows filters to be defined that transform the data in various
ways. The Filter box is used to set up the filters that are required. At the left of the Filter
box is a Choose button. By clicking this button it is possible to select one of the filters in
WEKA. Once a filter has been selected, its name and options are shown in the field next to
the Choose button. Clicking on this box with the left mouse button brings up a
GenericObjectEditor dialog box. A click with the right mouse button (or Alt+Shift+left
click) brings up a menu where you can choose, either to display the properties in a
GenericObjectEditor dialog box, or to copy the current setup string to the clipboard.
TKRCET Page 62
Data Warehousing and Mining Lab Department of IT
The GenericObjectEditor dialog box lets you configure a filter. The same kind
of dialog box is used to configure other objects, such as classifiers and clusterers
(see below). The fields in the window reflect the available options.
Right-clicking (or Alt+Shift+Left-Click) on such a field will bring up a popup menu, listing the
following options:
1. Show properties... has the same effect as left-clicking on the field, i.e., a dialog appears
allowing you to alter the settings.
2. Copy configuration to clipboard copies the currently displayed configuration string to the
system’s clipboard and therefore can be used anywhere else in WEKA or in the console. This is
rather handy if you have to setup complicated, nested schemes.
3. Enter configuration... is the ―receiving‖ end for configurations that got copied to the
clipboard earlier on. In this dialog you can enter a class name followed by options (if the class
supports these). This also allows you to transfer a filter setting from the Preprocess panel to a
Filtered Classifier used in the Classify panel.
TKRCET Page 63
Data Warehousing and Mining Lab Department of IT
Left-Clicking on any of these gives an opportunity to alter the filters settings. For example,
the setting may take a text string, in which case you type the string into the text field provided. Or
it may give a drop-down box listing several states to choose from. Or it may do something else,
depending on the information required. Information on the options is provided in a tool tip if you
let the mouse pointer hover of the corresponding field. More information on the filter and its
options can be obtained by clicking on the More button in the About panel at the top of the
GenericObjectEditor window.
Applying Filters
Once you have selected and configured a filter, you can apply it to the data by pressing the
Apply button at the right end of the Filter panel in the Preprocess panel. The Preprocess panel will
then show the transformed data. The change can be undone by pressing the Undo button. You can
also use the Edit...button to modify your data manually in a dataset editor. Finally, the Save...
button at the top right of the Preprocess panel saves the current version of the relation in file
formats that can represent the relation, allowing it to be kept for future use.
TKRCET Page 64
Data Warehousing and Mining Lab Department of IT
TKRCET Page 65
Data Warehousing and Mining Lab Department of IT
B. Load each dataset into Weka and run Aprior algorithm with different support and
confidence values. Study the rules generated.
Ans:
TKRCET Page 66
Data Warehousing and Mining Lab Department of IT
TKRCET Page 67
Data Warehousing and Mining Lab Department of IT
Association Rule:
An association rule has two parts, an antecedent (if) and a consequent (then). An antecedent is an
item found in the data. A consequent is an item that is found in combination with the antecedent.
Association rules are created by analyzing data for frequent if/then patterns and using the
criteriasupport and confidence to identify the most important relationships. Support is an indication
of how frequently the items appear in the database. Confidence indicates the number of times the
if/then statements have been found to be true.
In data mining, association rules are useful for analyzing and predicting customer behavior. They
play an important part in shopping basket data analysis, product clustering, catalog design and store
layout.
Support count: The support count of an itemset X, denoted by X.count, in a data set T is the
number of transactions in T that contain X. Assume T has n transactions.
Then,
( X ∪ Y ).count
support
n
confidence ( X ∪ Y ).count
X .count
support = support({A U C})
TKRCET Page 68
Data Warehousing and Mining Lab Department of IT
C. Apply different discretization filters on numerical attributes and run the Aprior
association rule algorithm. Study the rules generated. Derive interesting insights
and observe the effect of discretization in the rule generation process.
TKRCT Page 69
Data Warehousing and Mining Lab Department of IT
Classification Tab
Selecting a Classifier
At the top of the classify section is the Classifier box. This box has a text fieldthat gives the
name of the currently selected classifier, and its options. Clicking on the text box with the left
mouse button brings up a GenericObjectEditor dialog box, just the same as for filters, that you can
use to configure the options of the current classifier. With a right click (or Alt+Shift+left click) you
can once again copy the setup string to the clipboard or display the properties in a
GenericObjectEditor dialog box. The Choose button allows you to choose one of the classifiers that
are available in WEKA.
1. Use training set. The classifier is evaluated on how well it predicts the class of the instances it
was trained on.
2. Supplied test set. The classifier is evaluated on how well it predicts the class of a set of
instances loaded from a file. Clicking the Set... button brings up a dialog allowing you to choose the file
to test on.
3. Cross-validation. The classifier is evaluated by cross-validation, using the number of folds that
are entered in the Folds text field.
4. Percentage split. The classifier is evaluated on how well it predicts a certain percentage of the
data which is held out for testing. The amount of data held out depends on the value entered in the %
field.
1. Output model. The classification model on the full training set is output so that it can be viewed,
visualized, etc. This option is selected by default.
TKRCET Page 71
Data Warehousing and Mining Lab Department of IT
2. Output per-class stats. The precision/recall and true/false statistics for each class areoutput.
This option is also selected by default.
3. Output entropy evaluation measures. Entropy evaluation measures are included in the
output. This option is not selected by default.
4. Output confusion matrix. The confusion matrix of the classifier’s predictions is
included in the output. This option is selected by default.
Note that in the case of a cross-validation the instance numbers do not correspond to the location in
the data!
predictions, e.g., an ID attribute for tracking misclassifications, then the index of this attribute can
be specified here. The usual Weka ranges are supported,―first‖ and ―last‖ are therefore
valid indices as well (example: ―first-3,6,8,12-last‖).
8. Cost-sensitive evaluation. The errors is evaluated with respect to a cost matrix. The Set...
button allows you to specify the cost matrix used.
9. Random seed for xval / % Split. This specifies the random seed used when randomizing the
data before it is divided up for evaluation purposes.
10. Preserve order for % Split. This suppresses the randomization of the data before splitting into
train and test set.
11. Output source code. If the classifier can output the built model as Java source code, you can
specify the class name here. The code will be printed in the ―Classifier output‖ area.
TKRCET Page 72
Data Warehousing and Mining Lab Department of IT
attribute, which is the target for prediction. Some classifiers can only learn nominal classes; others
can only learn numeric classes (regression problems) still others can learn both.
By default, the class is taken to be the last attribute in the data. If you want
to train a classifier to predict a different attribute, click on the box below the Test options box to
bring up a drop-down list of attributes to choose from.
Training a Classifier
Once the classifier, test options and class have all been set, the learning process is started by
clicking on the Start button. While the classifier is busy being trained, the little bird moves around.
You can stop the training process at any time by clicking on the Stop button. When training is
complete, several things happen. The Classifier output area to the right of the display is filled with
text describing the results of training and testing. A new entry appears in the Result list box. We
look at the result list below; but first we investigate the text that has been output.
A. Load each dataset into Weka and run id3, j48 classification algorithm, study the
classifier output. Compute entropy values, Kappa ststistic.
Ans:
TKRCET Page 73
Data Warehousing and Mining Lab Department of IT
Output:
=== Run information ===
Scheme:weka.classifiers.trees.J48 -C 0.25 -M 2
Relation: iris
Instances: 150
Attributes: 5
sepallength
sepalwidth
petallength
petalwidth
class
Test mode:evaluate on training data
Number of Leaves : 5
TKRCET Page 74
Data Warehousing and Mining Lab Department of IT
a b c <-- classified as
50 0 0 | a = Iris-setosa
0 49 1 | b = Iris-versicolor
0 2 48 | c = Iris-virginica
TKRCET Page 75
Data Warehousing and Mining Lab Department of IT
The text in the Classifier output area has scroll bars allowing you to browse
the results. Clicking with the left mouse button into the text area, while holding Alt
and Shift, brings up a dialog that enables you to save the displayed output
in a variety of formats (currently, BMP, EPS, JPEG and PNG). Of course, you
can also resize the Explorer window to get a larger display area.
The output is
1. Run information. A list of information giving the learning scheme options, relation name,
instances, attributes and test mode that were involved in the process.
TKRCET Page 76
Data Warehousing and Mining Lab Department of IT
2. Classifier model (full training set). A textual representation of the classification model that was
produced on the full training data.
3. The results of the chosen test mode are broken down thus.
4. Summary. A list of statistics summarizing how accurately the classifier was able to predict the
true class of the instances under the chosen test mode.
5. Detailed Accuracy By Class. A more detailed per-class break down of the classifier’s
prediction accuracy.
6. Confusion Matrix. Shows how many instances have been assigned to each class. Elements show
the number of test examples whose actual class is the row and whose predicted class is the column.
7. Source code (optional). This section lists the Java source code if one
chose ―Output source code‖ in the ―More options‖ dialog.
B. Extract if-then rues from decision tree gentrated by classifier, Observe the confusion
matrix and derive Accuracy, F- measure, TPrate, FPrate , Precision and recall values. Apply
cross-validation strategy with various fold levels and compare the accuracy results.
Ans:
A decision tree is a structure that includes a root node, branches, and leaf nodes. Each internal
node denotes a test on an attribute, each branch denotes the outcome of a test, and each leaf node
holds a class label. The topmost node in the tree is the root node.
The following decision tree is for the concept buy_computer that indicates whether a customer at a
company is likely to buy a computer or not. Each internal node represents a test on an attribute.
Each leaf node represents a class.
TKRCET Page 77
Data Warehousing and Mining Lab Department of IT
IF-THEN Rules:
Rule-based classifier makes use of a set of IF-THEN rules for classification. We can express a rule
in the following from −
Points to remember −
The antecedent part the condition consist of one or more attribute tests and these tests are
logically ANDed.
TKRCET Page 78
Data Warehousing and Mining Lab Department of IT
Rule Extraction
Here we will learn how to build a rule-based classifier by extracting IF-THEN rules from a
decision tree.
Points to remember −
One rule is created for each path from the root to the leaf node.
The leaf node holds the class prediction, forming the rule consequent.
Some of the sequential Covering Algorithms are AQ, CN2, and RIPPER. As per the general
strategy the rules are learned one at a time. For each time rules are learned, a tuple covered by the
rule is removed and the process continues for the rest of the tuples. This is because the path to
each leaf in a decision tree corresponds to a rule.
Note − The Decision tree induction can be considered as learning a set of rules simultaneously.
The Following is the sequential learning Algorithm where rules are learned for one class at a time.
When learning a rule from a class Ci, we want the rule to cover all the tuples from class C only
and no tuple form any other class.
Input:
D, a data set class-labeled tuples,
Att_vals, the set of all attributes and their possible values.
TKRCET Page 79
Data Warehousing and Mining Lab Department of IT
repeat
Rule = Learn_One_Rule(D, Att_valls, c);
remove tuples covered by Rule form D;
until termination condition;
The Assessment of quality is made on the original set of training data. The rule may
perform well on training data but less well on subsequent data. That's why the rule pruning
is required.
The rule is pruned by removing conjunct. The rule R is pruned, if pruned version of R has
greater quality than what was assessed on an independent set of tuples.
FOIL is one of the simple and effective method for rule pruning. For a given rule R,
Note − This value will increase with the accuracy of R on the pruning set. Hence, if the FOIL_Prune
value is higher for the pruned version of R, then we prune R.
TKRCET Page 80
Data Warehousing and Mining Lab Department of IT
Output:
=== Run information ===
Scheme:weka.classifiers.rules.DecisionTable -X 1 -S "weka.attributeSelection.BestFirst -D
1 -N 5"
Relation: iris
Instances: 150
Attributes: 5
sepallength
sepalwidth
petallength
petalwidth
class
Test mode:10-fold cross-validation
Decision Table:
TKRCET Page 81
Data Warehousing and Mining Lab Department of IT
a b c <-- classified as
50 0 0 | a = Iris-setosa
0 44 6 | b = Iris-versicolor
0 5 45 | c = Iris-virginica
TKRCET Page 82
Data Warehousing and Mining Lab Department of IT
C. Load each dataset into Weka and perform Naïve-bayes classification and k-
Nearest Neighbor classification, Interpret the results obtained.
Ans:
Steps for run Naïve-bayes and k-nearest neighbor Classification algorithms in WEKA
TKRCET Page 83
Data Warehousing and Mining Lab Department of IT
Scheme:weka.classifiers.bayes.NaiveBayes
Relation: iris
Instances: 150
Attributes: 5
sepallength
sepalwidth
petallength
petalwidth
class
Test mode:evaluate on training data
Class
Attribute Iris-setosa Iris-versicolor Iris-virginica
(0.33) (0.33) (0.33)
===============================================================
sepallength
mean 4.9913 5.9379 6.5795
std. dev. 0.355 0.5042 0.6353
weight sum 50 50 50
precision 0.1059 0.1059 0.1059
sepalwidth
mean 3.4015 2.7687 2.9629
std. dev. 0.3925 0.3038 0.3088
weight sum 50 50 50
precision 0.1091 0.1091 0.1091
petallength
TKRCET Page 84
Data Warehousing and Mining Lab Department of IT
petalwidth
mean 0.2743 1.3097 2.0343
std. dev. 0.1096 0.1915 0.2646
weight sum 50 50 50
precision 0.1143 0.1143 0.1143
TKRCET Page 85
Data Warehousing and Mining Lab Department of IT
a b c <-- classified as
50 0 0 | a = Iris-setosa
0 48 2 | b = Iris-versicolor
0 4 46 | c = Iris-virginica.
Scheme:weka.classifiers.lazy.IBk -K 1 -W 0 -A "weka.core.neighboursearch.LinearNNSearch -A
\"weka.core.EuclideanDistance -R first-last\""
Relation: iris
Instances: 150
Attributes: 5
sepallength
sepalwidth
petallength
TKRCET Page 86
Data Warehousing and Mining Lab Department of IT
petalwidth
class
Test mode:evaluate on training data
a b c <-- classified as
50 0 0 | a = Iris-setosa
0 50 0 | b = Iris-versicolor
0 0 50 | c = Iris-virginica
TKRCET Page 87
Data Warehousing and Mining Lab Department of IT
TKRCET Page 88
Data Warehousing and Mining Lab Department of IT
E. Compare classification results of ID3,J48, Naïve-Bayes and k-NN classifiers for each dataset ,
and reduce which classifier is performing best and poor for each dataset and justify.
Ans:
TKRCET Page 89
Data Warehousing and Mining Lab Department of IT
Scheme:weka.classifiers.trees.J48 -C 0.25 -M 2
Relation: iris
Instances: 150
Attributes: 5
sepallength
sepalwidth
petallength
petalwidth
class
Test mode:evaluate on training data
Number of Leaves : 5
TKRCET Page 90
Data Warehousing and Mining Lab Department of IT
a b c <-- classified as
50 0 0 | a = Iris-setosa
0 49 1 | b = Iris-versicolor
0 2 48 | c = Iris-virginica
Naïve-bayes:
=== Run information ===
Scheme:weka.classifiers.bayes.NaiveBayes
Relation: iris
Instances: 150
Attributes: 5
sepallength
TKRCET Page 91
Data Warehousing and Mining Lab Department of IT
sepalwidth
petallength
petalwidth
class
Test mode:evaluate on training data
=== Classifier model (full training set) ===
Naive Bayes Classifier
Class
Attribute Iris-setosa Iris-versicolor Iris-virginica
(0.33) (0.33) (0.33)
===============================================================
sepallength
mean 4.9913 5.9379 6.5795
std. dev. 0.355 0.5042 0.6353
weight sum 50 50 50
precision 0.1059 0.1059 0.1059
sepalwidth
mean 3.4015 2.7687 2.9629
std. dev. 0.3925 0.3038 0.3088
weight sum 50 50 50
precision 0.1091 0.1091 0.1091
petallength
mean 1.4694 4.2452 5.5516
std. dev. 0.1782 0.4712 0.5529
weight sum 50 50 50
precision 0.1405 0.1405 0.1405
petalwidth
mean 0.2743 1.3097 2.0343
std. dev. 0.1096 0.1915 0.2646
weight sum 50 50 50
precision 0.1143 0.1143 0.1143
TKRCET Page 92
Data Warehousing and Mining Lab Department of IT
TKRCET Page 93
Data Warehousing and Mining Lab Department of IT
a b c <-- classified as
50 0 0 | a = Iris-setosa
0 50 0 | b = Iris-versicolor
0 0 50 | c = Iris-virginica
TKRCET Page 94
Data Warehousing and Mining Lab Department of IT
Selecting a Clusterer
By now you will be familiar with the process of selecting and configuring objects. Clicking
on the clustering scheme listed in the Clusterer box at the top of the
Cluster Modes
The Cluster mode box is used to choose what to cluster and how to evaluate
the results. The first three options are the same as for classification: Use training set, Supplied test
set and Percentage split (Section 5.3.1)—except that now the data is assigned to clusters instead of
trying to predict a specific class. The fourth mode, Classes to clusters evaluation, compares how
well the chosen clusters match up with a pre-assigned class in the data. The drop-down box below
this option selects the class, just as in the Classify panel.
An additional option in the Cluster mode box, the Store clusters for visualization tick box,
determines whether or not it will be possible to visualize the clusters once training is complete.
When dealing with datasets that are so large that memory becomes a problem it may be helpful to
disable this option.
Ignoring Attributes
Often, some attributes in the data should be ignored when clustering. The Ignore attributes
button brings up a small window that allows you to select which attributes are ignored. Clicking on
an attribute in the window highlights it, holding down the SHIFT key selects a range of
consecutive attributes, and holding down CTRL toggles individual attributes on and off. To cancel
the selection, back out with the Cancel button. To activate it, click the Select button. The next time
clustering is invoked, the selected attributes are ignored.
TKRCET Page 95
Data Warehousing and Mining Lab Department of IT
The Filtered Clusterer meta-clusterer offers the user the possibility to apply filters directly
before the clusterer is learned. This approach eliminates the manual application of a filter in the
Preprocess panel, since the data gets processed on the fly. Useful if one needs to try out different
filter setups.
Learning Clusters
The Cluster section, like the Classify section, has Start/Stop buttons, a result text area and a
result list. These all behave just like their classification counterparts. Right-clicking an entry in the
result list brings up a similar menu, except that it shows only two visualization options: Visualize
cluster assignments and Visualize tree. The latter is grayed out when it is not applicable.
A. Load each dataset into Weka and run simple k-means clustering algorithm with
different values of k(number of desired clusters). Study the clusters formed.
Observe the sum of squared errors and centroids, and derive insights.
Ans:
Output:
TKRCET Page 96
Data Warehousing and Mining Lab Department of IT
Instances: 150
Attributes: 5
sepallength
sepalwidth
petallength
petalwidth
class
Test mode:evaluate on training data
kMeans
======
Number of iterations: 7
Within cluster sum of squared errors: 62.1436882815797
Missing values globally replaced with mean/mode
Cluster centroids:
Cluster#
Attribute Full Data 0 1
(150) (100) (50)
==================================================================
sepallength 5.8433 6.262 5.006
sepalwidth 3.054 2.872 3.418
petallength 3.7587 4.906 1.464
petalwidth 1.1987 1.676 0.244
class Iris-setosa Iris-versicolor Iris-setosa
Clustered Instances
0 100 ( 67%)
1 50 ( 33%)
TKRCET Page 97
Data Warehousing and Mining Lab Department of IT
TKRCET Page 98
Data Warehousing and Mining Lab Department of IT
WEKA‘s visualization allows you to visualize a 2-D plot of the current working relation.
Visualization is very useful in practice, it helps to determine difficulty of the learning problem.
WEKA can visualize single attributes (1-d) and pairs of attributes (2-d), rotate 3-d visualizations
(Xgobi-style). WEKA has ―Jitter‖ option to deal with nominal attributes and to detect ―hidden‖
data points.
Access To Visualization From The Classifier, Cluster And Attribute Selection Panel Is Available
From A Popup Menu. Click The Right Mouse Button Over An Entry In The Result List To Bring Up
The Menu. You Will Be Presented With Options For Viewing Or Saving The Text Output And
--- Depending On The Scheme --- Further Options For Visualizing Errors, Clusters, Trees Etc.
TKRCET Page 99
Data Warehousing and Mining Lab Department of IT
Select a square that corresponds to the attributes you would like to visualize. For example, let‘s
choose ‗outlook‘ for X – axis and ‗play‘ for Y – axis. Click anywhere inside the square that
corresponds to ‗play o
In the visualization window, beneath the X-axis selector there is a drop-down list,
‗Colour‘, for choosing the color scheme. This allows you to choose the color of points based on
the attribute selected. Below the plot area, there is a legend that describes what values the colors
correspond to. In your example, red represents ‗no‘, while blue represents ‗yes‘. For better
visibility you should change the color of label ‗yes‘. Left-click on ‗yes‘ in the ‗Class colour‘
box and select lighter color from the color palette.
TKRCET page100
Data Warehousing and Mining Lab Department of IT
Selecting Instances
Sometimes it is helpful to select a subset of the data using visualization tool. A special
case is the ‗UserClassifier‘, which lets you to build your own classifier by interactively
selecting instances. Below the Y – axis there is a drop-down list that allows you to choose a
selection method. A group of points on the graph can be selected in four ways [2]:
attributes of the point. If more than one point will appear at the same location, more than
one set of attributes will be shown.
TKRCET Page101
Data Warehousing and Mining Lab Department of IT
3. Polygon. You can select several points by building a free-form polygon. Left-click on the
graph to add vertices to the polygon and right-click to complete it.
TKRCET Page102
Data Warehousing and Mining Lab Department of IT
4. Polyline. To distinguish the points on one side from the once on another, you can build
a polyline. Left-click on the graph to add vertices to the polyline and right-click to finish.
Regression:
Regression is a data mining function that predicts a number. Age, weight, distance, temperature,
income, or sales could all be predicted using regression techniques. For example, a regression
model could be used to predict children's height, given their age, weight, and other factors.
A regression task begins with a data set in which the target values are known. For example, a
regression model that predicts children's height could be developed based on observed data for
many children over a period of time. The data might track age, height, weight, developmental
milestones, family history, and so on. Height would be the target, the other attributes would be
the predictors, and the data for each child would constitute a case.
In the model build (training) process, a regression algorithm estimates the value of the target as a
function of the predictors for each case in the build data. These relationships between predictors
and target are summarized in a model, which can then be applied to a different data set in which
the target values are unknown.
Regression models are tested by computing various statistics that measure the difference between
the predicted values and the expected values. See "Testing a Regression Model".
Regression modeling has many applications in trend analysis, business planning, marketing,
financial forecasting, time series prediction, biomedical and drug response modeling, and
environmental modeling.
Exercise:
y = F(x,θ) + e
The process of training a regression model involves finding the best parameter values for the
function that minimize a measure of the error, for example, the sum of squared errors.
There are different families of regression functions and different ways of measuring the error.
Linear Regression
The simplest form of regression to visualize is linear regression with a single predictor. A linear
regression technique can be used if the relationship between x and y can be approximated with a
straight line, as shown in Figure 4-1.
In a linear regression scenario with a single predictor (y = θ 2x + θ1), the regression parameters
(also called coefficients) are:
The slope of the line (θ2) — the angle between a data point and the regression
line and
The y intercept (θ1) — the point where x crosses the y axis (x = 0)
Nonlinear Regression
Often the relationship between x and y cannot be approximated with a straight line. In this case,
a nonlinear regression technique may be used. Alternatively, the data could be preprocessed to
make the relationship linear.
In Figure 4-2, x and y have a nonlinear relationship. Oracle Data Mining supports nonlinear
regression via the gaussian kernel of SVM. (See "Kernel-Based Learning".)
Multivariate Regression
Multivariate regression refers to regression with multiple predictors (x1 , x2 , ..., xn). For
purposes of illustration, Figure 4-1and Figure 4-2 show regression with a single predictor.
Multivariate regression is also referred to as multiple regression.
Regression Algorithms
Generalized Linear Models (GLM) is a popular statistical technique for linear modeling.
Oracle Data Mining implements GLM for regression and classification. See Chapter 12,
"Generalized Linear Models"
Support Vector Machines (SVM) is a powerful, state-of-the-art algorithm for linear and
nonlinear regression. Oracle Data Mining implements SVM for regression and other
mining functions. See Chapter 18, "Support Vector Machines"
Note:
Both GLM and SVM, as implemented by Oracle Data Mining, are particularly suited for mining
data that includes many predictors (wide data).
The Root Mean Squared Error and the Mean Absolute Error are statistics for evaluating the
overall quality of a regression model. Different statistics may also be available depending on the
regression methods used by the algorithm.
The Root Mean Squared Error (RMSE) is the square root of the average squared distance of a
data point from the fitted line.Figure 4-3 shows the formula for the RMSE.
The Mean Absolute Error (MAE) is the average of the absolute value of the residuals. The MAE
is very similar to the RMSE but is less sensitive to large errors. Figure 4-4 shows the formula for
the MAE.
A. Load each dataset into Weka and build Linear Regression model. Study the
cluster formed. Use training set option. Interpret the regression model and derive
patterns and conclusions from the regression results.
Ans:
9. Select the LinearRegression leaf ans select use training set test option.
10. Click on start button.
Output:
Relation: labor-neg-data
Instances: 57
Attributes: 17
duration
wage-increase-first-year
wage-increase-second-year
wage-increase-third-year
cost-of-living-adjustment
working-hours
pension
standby-pay
shift-differential
education-allowance
statutory-holidays
vacation
longterm-disability-assistance
contribution-to-dental-plan
bereavement-assistance
contribution-to-health-plan
class
duration =
0.4689 * cost-of-living-adjustment=tc,tcf +
0.6523 * pension=none,empl_contr +
1.0321 * bereavement-assistance=yes +
0.3904 * contribution-to-health-plan=full +
0.2765
B. Use options cross-validation and percentage split and repeat running the
Linear Regression Model. Observe the results and derive meaningful results.
Output: cross-validation
vacation
longterm-disability-assistance
contribution-to-dental-plan
bereavement-assistance
contribution-to-health-plan
class
duration =
0.4689 * cost-of-living-adjustment=tc,tcf +
0.6523 * pension=none,empl_contr +
1.0321 * bereavement-assistance=yes +
0.3904 * contribution-to-health-plan=full +
0.2765
contribution-to-dental-plan
bereavement-assistance
contribution-to-health-plan
class
Test mode: split 66.0% train, remainder test
C. E xplore Simple linear regression techniques that only looks at one variable.
9. Select the S i m p l e Linear Regression leaf and select test options cross-validation.
Description: The business of banks is making loans. Assessing the credit worthiness of an applicant
is of crucial importance. You have to develop a system to help a loan officer decide whether the
credit of a customer is good or bad.
A bank’s business rulesregarding loans must consider two opposing factors. On th one
han, a bank wants to make as many loans as possible.
Interest on these loans is the banks profit source. On the other hand, a bank can not afford to
make too many bad loans. Too many bad loans could lead to the collapse of the bank. The
bank’s loan policy must involve a compromise. Not too strict and not too lenient.
To do the assignment, you first and foremost need some knowledge about the world of credit.
You can acquire such knowledge in a number of ways.
1. Knowledge engineering: Find a loan officer who is willing to talk. Interview her and try
to represent her knowledge in a number of ways.
2. Books: Find some training manuals for loan officers or perhaps a suitable textbook on
finance. Translate this knowledge from text from to production rule form.
3. Common sense: Imagine yourself as a loan officer and make up reasonable rules which
can be used to judge the credit worthiness of a loan applicant.
4. Case histories: Find records of actual cases where competent loan officers correctly
judged when and not to. Approve a loan application.
Actual historical credit data is not always easy to come by because of confidentiality
rules. Here is one such data set. Consisting of 1000 actual cases collected in Germany.
In spite of the fact that the data is German, you should probably make use of it for this
assignment(Unless you really can consult a real loan officer!)
There are 20 attributes used in judging a loan applicant( ie., 7 Numerical attributes and 13
Categoricl or Nominal attributes). The goal is the classify the applicant into one of two
categories. Good or Bad.
1. Checking_Status
2. Duration
3. Credit_history
4. Purpose
5. Credit_amout
6. Savings_status
7. Employment
8. Installment_Commitment
9. Personal_status
10. Other_parties
11. Residence_since
12. Property_Magnitude
13. Age
14. Other_payment_plans
15. Housing
16. Existing_credits
17. Job
18. Num_dependents
19. Own_telephone
20. Foreign_worker
Dimension
_name
_hierarchies
Dimensions objects(dimension) consists of set of levels and set of hierarchies defined over those
levels.the levels represent levels of aggregation.hierarchies describe-child relationships among a
set of levels.
For example .a typical calander dimension could contain five levels.two hierarchies can be
defined on these levels.
H1: YearL>QuarterL>MonthL>DayL
H2: YearL>WeekL>DayL
The hierarchies are describes from parent to child,so that year is the parent of Quarter,quarter
are parent of month,and so forth.
When you create a definition for a hierarchy,warehouse builder creates an identifier key for
each level of the hierarchy and unique key constraint on the lowest level (base level)
PATIENT(patient_name,age,address,etc)
MEDICINE(Medicine_brand_name,Drug_name,supplier,no_units,units_price,etc..,)
SUPPLIER:( Supplier_name,medicine_brand_name,address,etc..,)
If each dimension has 6 levels,decide the levels and hierarchies,assumes the level
names suitably.
Design the hospital management system data warehousing using all schemas.give the
example 4-D cube with assumption names