0% found this document useful (0 votes)
72 views24 pages

Data Warehousing Lab Exp 1-3

Uploaded by

rajar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views24 pages

Data Warehousing Lab Exp 1-3

Uploaded by

rajar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

DEPARTMENT OF COMPUTER SCIENCE ENGINEERING

22CSE009- DATA WAREHOUSING LABORATORY


Exp 1: Introduction to WEKA:
WEKA - an open source software provides tools for data preprocessing, implementation of
several Machine Learning algorithms, and visualization tools so that you can develop
machine learning techniques and apply them to real-world data mining problems. What
WEKA offers is summarized in the following diagram:

If you observe the beginning of the flow of the image, you will understand that there are
many stages in dealing with Big Data to make it suitable for machine learning:

First, you will start with the raw data collected from the field. This data may contain
several null values and irrelevant fields. You use the data preprocessing tools provided in
WEKA to cleanse the data.

Then, you would save the preprocessed data in your local storage for applying ML
algorithms.
Next, depending on the kind of ML model that you are trying to develop you would select
one of the options such as Classify, Cluster, or Associate. The Attributes Selection
allows the automatic selection of features to create a reduced dataset.

Note that under each category, WEKA provides the implementation of several algorithms.
You would select an algorithm of your choice, set the desired parameters and run it on
the dataset.

Then, WEKA would give you the statistical output of the model processing. It provides you
a visualization tool to inspect the data.

The various models can be applied on the same dataset. You can then compare the
outputs of different models and select the best that meets your purpose.

Thus, the use of WEKA results in a quicker development of machine learning models on
the whole.

Now that we have seen what WEKA is and what it does, in the next chapter let us learn
how to install WEKA on your local computer.
Weka Installation:
To install WEKA on your machine, visit WEKA’s official website and download the
installation file. WEKA supports installation on Windows, Mac OS X and Linux. You just
need to follow the instructions on this page to install WEKA for your OS.

The steps for installing on Mac are as follows:

 Download the Mac installation file.

 Double click on the downloaded weka-3-8-3-corretto-jvm.dmg file.


You will see the following screen on successful installation

 Click on the weak-3-8-3-corretto-jvm icon to start Weka.

 Optionally you may start it from the command line:

java -jar weka.jar

The WEKA GUI Chooser application will start and you would see the following screen:

The GUI Chooser application allows you to run five different types of applications as
listed here:
 Explorer
 Experimenter
 KnowledgeFlow
 Workbench
 Simple CLI

We will be using Explorer in this tutorial.


Weka – Launching Explorer

In this chapter, let us look into various functionalities that the explorer provides for
working with big data.
When you click on the Explorer button in the Applications selector, it opens the followingscreen:

On the top, you will see several tabs as listed here:

 Preprocess
 Classify
 Cluster
 Associate
 Select Attributes
 Visualize
Under these tabs, there are several pre-implemented machine learning algorithms. Let us
look into each of them in detail now.

Preprocess Tab
Initially as you open the explorer, only the Preprocess tab is enabled. The first step in
machine learning is to preprocess the data. Thus, in the Preprocess option, you will
select the data file, process it and make it fit for applying the various machine learning
algorithms.

Classify Tab
The Classify tab provides you several machine learning algorithms for the classification of
your data. To list a few, you may apply algorithms such as Linear Regression, Logistic
Regression, Support Vector Machines, Decision Trees, RandomTree, RandomForest,
NaiveBayes, and so on. The list is very exhaustive and provides both supervised and
unsupervised machine learning algorithms.

Cluster Tab
Under the Cluster tab, there are several clustering algorithms provided - such as
SimpleKMeans, FilteredClusterer, HierarchicalClusterer, and so on.

Associate Tab
Under the Associate tab, you would find Apriori, FilteredAssociator and FPGrowth.

Select Attributes Tab


Select Attributes allows you feature selections based on several algorithms such as
ClassifierSubsetEval, PrinicipalComponents, etc.

Visualize Tab
Lastly, the Visualize option allows you to visualize your processed data for analysis.

As you noticed, WEKA provides several ready-to-use algorithms for testing and building your
machine learning applications. To use WEKA effectively, you must have a sound
knowledge of these algorithms, how they work, which one to choose under what
circumstances, what to look for in their processed output, and so on. In short, you must
have a solid foundation in machine learning to use WEKA effectively in building your apps.

In the upcoming chapters, you will study each tab in the explorer in depth.
Exp 2: Data exploration and integration with WEKA
2.1) Weka : Loading data

In this chapter, we start with the first tab that you use to preprocess the data. This is
common to all algorithms that you would apply to your data for building the model and is
a common step for all subsequent operations in WEKA.

For a machine learning algorithm to give acceptable accuracy, it is important that you
must cleanse your data first. This is because the raw data collected from the field may
contain null values, irrelevant columns and so on.

In this chapter, you will learn how to preprocess the raw data and create a clean,
meaningful dataset for further use.

First, you will learn to load the data file into the WEKA explorer. The data can be loaded
from the following sources:
 Local file system
 Web
 Database
In this chapter, we will see all the three options of loading data in detail.

LoadingDatafromLocalFileSystem
Just under the Machine Learning tabs that you studied in the previous lesson, you would
find the following three buttons:
 Open file …
 Open URL …
 Open DB …
Click on the Open file ... button. A directory navigator window opens as shown in
the following screen:
Now, navigate to the folder where your data files are stored. WEKA installation
comes up with many sample databases for you to experiment. These are available
in the data folderof the WEKA installation.

For learning purpose, select any data file from this folder. The contents of the file
would be loaded in the WEKA environment. We will very soon learn how to inspect
and process this loaded data. Before that, let us look at how to load the data file
from the Web.

LoadingDatafromWeb
Once you click on the Open URL … button, you can see a window as follows:
We will open the file from a public URL Type the following URL in the popup box:

https://storm.cis.fordham.edu/~gweiss/data-mining/weka-
data/weather.nominal.arff

You may specify any other URL where your data is stored. The Explorer will load the
datafrom the remote site into its environment

LoadingDatafromDB
Once you click

Set the connection string to your database, set up the query for data selection, processthe query
and load the selected records in WEKA
Exp 3: Apply weka tool for data validation
3.1) Weka – Preprocessing the data

The data that is collected from the field contains many unwanted things that leads to
wrong analysis. For example, the data may contain null fields, it may contain columns
that are irrelevant to the current analysis, and so on. Thus, the data must be
preprocessed to meet the requirements of the type of analysis you are seeking. This is
the done in the preprocessing module.

To demonstrate the available features in preprocessing, we will use the Weather


database that is provided in the installation.

Using the Open file ... option under the Preprocess tag select the weather- nominal.arff file.

When you open the file, your screen looks like as shown here:
This screen tells us several things about the loaded data, which are discussed further inthis
chapter.

3.2)UnderstandingData
Let us first look at the highlighted Current relation sub window. It shows the name of
the database that is currently loaded. You can infer two points from this sub window:
 There are 14 instances - the number of rows in the table.

 The table contains 5 attributes - the fields, which are discussed in the upcomingsections.

On the left side, notice the Attributes sub window that displays the various fields in the
database.
The weather database contains five fields - outlook, temperature, humidity, windy and
play. When you select an attribute from this list by clicking on it, further details on the
attribute itself are displayed on the right hand side.
Let us select the temperature attribute first. When you click on it, you would see the
following screen
In the Selected Attribute subwindow, you can observe the following:

 The name and the type of the attribute are displayed.

 The type for the temperature attribute is Nominal.

 The number of Missing values is zero.

 There are three distinct values with no unique value.

 The table underneath this information shows the nominal values for this field ashot, mild and cold.

 It also shows the count and weight in terms of a percentage for each nominal value.

At the bottom of the window, you see the visual representation of the class values.
If you click on the Visualize All button, you will be able to see all features in one single
window as shown here:

RemovingAttributes
Many a time, the data that you want to use for model building comes with many
irrelevant fields. For example, the customer database may contain his mobile number
which is relevant in analysing his credit rating.
To remove Attribute/s select them and click on the Remove button at the bottom.
The selected attributes would be removed from the database. After you fully preprocess
the data, you can save it for model building.

Next, you will learn to preprocess the data by applying filters on this data.

3.2)ApplyingFilters
Some of the machine learning techniques such as association rule mining requires categorical data. To illustrate
the use of filters, we will use weather-numeric.arff database that contains two numeric attributes -
temperature and humidity.

We will convert these to nominal by applying a filter on our raw data. Click on the Choose
button in the Filter subwindow and select the following filter:

weka->filters->supervised->attribute->Discretize
Click on the Apply button and examine the temperature and/or humidity attribute.
Youwill notice that these have changed from numeric to nominal types
Let us look into another filter now. Suppose you want to select the best attributes for
deciding the play. Select and apply the following filter:

weka->filters->supervised->attribute->AttributeSelection
You will notice that it removes the temperature and humidity attributes from thedatabase.

After you are satisfied with the preprocessing of your data, save the data by clicking the
Save … button. You will use this saved file for model building.

In the next chapter, we will explore the model building using several predefined ML
algorithms.
Weka – Classifiers
Many machine learning applications are classification related. For example, you may like
to classify a tumor as malignant or benign. You may like to decide whether to play an
outside game depending on the weather conditions. Generally, this decision is dependent
on several features/conditions of the weather. So you may prefer to use a tree classifier to
make your decision of whether to play or not.

In this chapter, we will learn how to build such a tree classifier on weather data to decide
on the playing conditions.

3.3) SettingTestData
We will use the preprocessed weather data file from the previous lesson. Open the saved
file by using the Open file ... option under the Preprocess tab, click on the Classify
tab, and you would see the following screen:

Before you learn about the available classifiers, let us examine the Test options. You will
notice four testing options as listed below:
 Training set
 Supplied test set
 Cross-validation
 Percentage split
Unless you have your own training set or a client supplied test set, you would use cross-
validation or percentage split options. Under cross-validation, you can set the number of
folds in which entire data would be split and used during each iteration of training. In the
percentage split, you will split the data between training and testing using the set split
percentage.

Now, keep the default play option for the output class:

Next, you will select the classifier.

SelectingClassifier
Click on the Choose button and select the following classifier:

weka->classifiers>trees>J48
This is shown in the screenshot below:
Click on the Start button to start the classification process. After a while, the classification
results would be presented on your screen as shown here:
Let us examine the output shown on the right hand side of the screen.

It says the size of the tree is 6. You will very shortly see the visual representation of the
tree. In the Summary, it says that the correctly classified instances as 2 and the
incorrectly classified instances as 3, It also says that the Relative absolute error is 110%.
It also shows the Confusion Matrix. Going into the analysis of these results is beyond the
scope of this tutorial. However, you can easily make out from these results that the
classification is not acceptable and you will need more data for analysis, to refine your
features selection, rebuild the model and so on until you are satisfied with the model’s
accuracy. Anyway, that’s what WEKA is all about. It allows you to test your ideas quickly.

VisualizeResults
To see the visual representation of the results, right click on the result in the Result list
box. Several options would pop up on the screen as shown here:
Select Visualize tree to get a visual representation of the traversal tree as seen in the
screenshot below:
Selecting Visualize classifier errors would plot the results of classification as shown here:

A cross represents a correctly classified instance while squares represents incorrectly classified
instances. At the lower left corner of the plot you see a cross that indicates if outlook is sunny
then play the game. So this is a correctly classified instance. To locateinstances, you can
introduce some jitter in it by sliding the jitter slide bar
The current plot is outlook versus play. These are indicated by the two drop down list
boxes at the top of the screen.

You might also like