Your SlideShare is downloading. ×
Weka and NetDraw
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Weka and NetDraw

2,151

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,151
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
105
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MIS510 Spring 2009 Introduction to Weka and Net D raw
  • 2. Outline
    • Weka
      • Introduction
      • Weka Tools/Functions
      • How to use Weka ?
        • Weka Data File Format (Input)
        • Weka for D ata M ining
        • Sample O utput from Weka (Output)
      • Conclusion
    • NetDraw
      • Introduction
      • How to use NetDraw?
        • NetDraw Input Data File Format
        • Draw Networks using NetDraw
      • Conclusion
  • 3. Weka
  • 4. Introduction to Weka (Data Mining Tool)
    • Weka was d eveloped at the University of Waikato in New Zealand. http://www.cs.waikato.ac.nz/ml/weka/
    • Weka is a open source data mining tool developed in Java. It is u sed for research, education, and applications. It can be run on Windows, Linux and Mac.
  • 5. What can Weka do?
    • Weka is a collection of machine learning algorithms for data mining tasks. The algorithms can either be applied directly to a dataset (using GUI) or called from your own Java code (using Weka Java library) .
    • Weka contains tools for data pre-processing, classification, regression, clustering, association rules, and visualization. It is also well-suited for developing new machine learning schemes.
  • 6. Weka Tools/Functions
    • Tools (or functions) in Weka include:
      • D ata preprocessing ( e.g. , Data Filters ),
      • Classification ( e.g. , BayesNet, KNN, C4.5 Decision Tree, Neural Networks, SVM ) ,
      • Regression ( e.g. , Linear Regression, Isotonic Regression, SVM for Regression ),
      • Clustering ( e.g. , Simple K-means, Expectation Maximization (EM)) ,
      • Association rules ( e.g. , Apriori Algorithm, Predictive Accuracy, Confirmation Guided ),
      • Feature Selection ( e.g. , Cfs Subset Evaluation, Information Gain, Chi-squared Statistic ), and
      • Visualization ( e.g. , View different two-dimensional plots of the data ) .
  • 7. Weka’s R ole in the B ig P icture
    • Input
    • Raw data
    • Data Ming
    • by Weka
    • Pre-processing
    • Classification
    • Regression
    • Clustering
    • Association Rules
    • Visualization
    • Output
    • Result
  • 8. How to use Weka ?
    • Weka Data File Format (Input)
    • Weka for D ata M ining
    • Sample O utput from Weka (Output)
  • 9. Weka Data File Format (Input)
    • FILE FORMAT
    • @relation RELATION_NAME
    • @attribute ATTRIBUTE_NAME ATTRIBUTE_TYPR
    • @attribute ATTRIBUTE_NAME ATTRIBUTE_TYPR
    • @attribute ATTRIBUTE_NAME ATTRIBUTE_TYPR
    • @attribute ATTRIBUTE_NAME ATTRIBUTE_TYPR
    • @data
    • DATAROW1
    • DATAROW2
    • DATAROW3
    • The m ost popular data input format of Weka is “a rff ” (with “arff” being the extension name of your input data file) .
  • 10.
    • @relation heart-disease-simplified
    • @attribute age numeric
    • @attribute sex { female, male}
    • @attribute chest_pain_type { typ_angina, asympt, non_anginal, atyp_angina}
    • @attribute cholesterol numeric
    • @attribute exercise_induced_angina { no, yes}
    • @attribute class { present, not_present}
    • @data
    • 63,male,typ_angina,233,no,not_present
    • 67,male,asympt,286,yes,present
    • 67,male,asympt,229,yes,present
    • 38,female,non_anginal,?,no,not_present
    • ...
    Example of “a rff ” Input File numeric attribute nominal attribute
  • 11. Weka for D ata M ining
    • There are mainly 2 ways to use Weka to conduct your data mining tasks.
      • Use Weka Graphical U ser I nterfaces (GUI)
        • GUI is straightforward and e asy to use. But it is not flexible. It can not be called from you own application.
      • Import Weka Java library to your own java application.
        • Developers can leverage on Weka Java library to develop software or modify the source code to meet special requirements. It is more flexible and advanced. But it is not as easy to use as GUI.
  • 12. Weka GUI Different analysis tools/functions Different attributes to choose The value set of the chosen attribute and the # of input items with each value
  • 13. Weka GUI Classification Algorithms
  • 14. Import Weka Java library to your own J ava application
    • Three sets of classes you may need to use when developing your own application
      • Classes for Loading D ata
      • Classes for Classifiers
      • Classes for Evaluation
  • 15. Classes for Loading D ata
    • Related Weka c lasses
      • weka.core.Instances
      • weka.core.Instance
      • weka.core.Attribute
    • How to l oad input data file into i nstances ?
      • Every DataRow -> Instance, Every Attribute -> Attribute, Whole -> Instances
    # Load a file as Instances FileReader reader; reader = new FileReader(path); Instances instances = new Instances(reader);
  • 16.
    • Instances contains Attribute and Instance
      • How to get every Instance within the Instances ?
      • How to get an Attribute ?
    # Get Instance Instance instance = instances.instance(index); # Get Instance Count int count = instances.numInstances(); # Get Attribute Name Attribute attribute = instances.attribute(index); # Get Attribute Count int count = instances.numAttributes(); Classes for Loading D ata
  • 17.
      • How to g et the Attribute value of each Instance ?
      • Class Index (Very important!)
    # Get value instance.value(index); or instance.value(attrName); # Get Class Index instances.classIndex(); or instances. classAttribute ().index(); # Set Class Index instances.setClass(attribute); or instances.setClassIndex(index); Classes for Loading D ata
  • 18. Classes for Classifiers
    • Weka c lasses for C4.5, Naïve Bayes, and SVM
      • Classifier: all classes which extend weka.classifiers.Classifier
        • C4.5: weka.classifier.trees.J48
        • NaiveBayes: weka.classifiers.bayes.NaiveBayes
        • SVM: weka.classifiers.functions.SMO
    • How to b uild a classifier ?
    # Build a C4.5 Classifier Classifier c = new weka.classifier.trees.J48(); c.buildClassifier(trainingInstances); Build a SVM Classifier Classifier e = weka.classifiers.functions.SMO(); e.buildClassifier(trainingInstances);
  • 19. Classes for Evaluation
    • Related Weka c lasses
      • weka.classifiers.CostMatrix
      • weka.classifiers.Evaluation
    • How to use the evaluation classes?
    # Use Classifier To Do Classification CostMatrix costMatrix = null; Evaluation eval = new Evaluation(testingInstances, costMatrix); for (int i = 0; i < testingInstances.numInstances(); i++){ eval.evaluateModelOnceAndRecordPrediction(c,testingInstances.instance(i)); System. out.println(eval.toSummaryString( false)); System. out.println(eval.toClassDetailsString()) ; System. out.println(eval.toMatrixString()); }
  • 20. Classes for Evaluation
    • Cross Validation
      • In cross validation process, we split a single dataset into N equal shares. While taking N-1 shares as a training dataset , the rest will be used as testing dataset .
      • The most widely used is 10 cross fold validation.
  • 21. Classes for Evaluation
    • How to obtain the training dataset and the testing dataset?
    Random random = new Random(seed); instances.randomize(random); instances.stratify(N); for (int i = 0; i < N; i++) { Instances train = instances.trainCV(N, i , random); Instances test = instances.testCV(N, i , random); }
  • 22. Sample O utput from Weka
  • 23. Conclusion about Weka
    • In sum, t he overall goal of Weka is to build a state-of-the-art facility for developing machine learning (ML) techniques and allow people to apply them to real-world data mining problems.
    • Detailed documentation about different functions provided by Weka can be found on Weka website.
    • WEKA is available at :
    • http:// www.cs.waikato.ac.nz/ml/weka
  • 24. NetDraw
  • 25. Introduction to NetDraw (Visualization Tool)
    • NetDraw is a n open source program written by Steve Borgatti from Analytic Technologies . It is often used for visualizing both 1-mode and 2-mode social network data.
    • You can download it from:
      • http:// www.analytictech.com/downloadnd.htm
    • (Compared to Weka, it is much easier to use :P)
  • 26. What can NetDraw do?
    • NetDraw can:
      • h andle multiple relations at the same time, and
      • use node attributes to set colors, shapes, and sizes of nodes.
    • Pictures can be saved in metafile, jpg, gif and bitmap formats.
    • Two basic kinds of layouts are implemented: a circle and an MDS based on geodesic distance.
    • You can also rotate, flip, shift, resize and zoom configurations.
  • 27. How to use NetDraw?
    • NetDraw Input Data File Format
    • Draw Networks using NetDraw
  • 28. NetDraw Input Data File Format *node data &quot;ID&quot;, num &quot;$10 Gift Card off REGIS SALON (SALON SERVICES) + E&quot; 2 &quot;$10 iTunes Gift Certificate exp 9/2008&quot; 2 &quot;$10 STARBUCKS gift CARD CERTIFICATE&quot; 3 &quot;$10 Target Gift Card&quot; 3 &quot;$10.00 iTunes Music Gift Card - Free Shipping&quot; 2 &quot;$100 Best Buy Gift Card&quot; 15 &quot;$100 Gap Gift Card - FREE Shipping&quot; 9 … … … … … … … … *Tie data FROM TO &quot;Strength&quot; &quot;Home Depot Gift Card $500.&quot; &quot;$100 Home Depot Gift Card Accepted Nationwide&quot; 1 &quot;** $250 Best Buy GiftCard Gift Card Gift Certifica&quot; &quot;$25 Best Buy Gift Card for Store or Online!&quot; 1 &quot;$50 Bed Bath & Beyond Gift Card - FREE SHIPPING!&quot; &quot;$200 Cost Plus World Market Gift Card 4 Jewelry Be&quot; 1 &quot;$500.00 Best Buy gift certificate&quot; &quot;$15 Best Buy Gift Card *Free Shipping*&quot; 1 &quot;$25 Best Buy Gift Card for Store or Online!&quot; &quot;$15 Best Buy Gift Card *Free Shipping*&quot; 1 &quot;Bath and Body Works $25 Gift Card&quot; &quot;$200 Cost Plus World Market Gift Card 4 Jewelry Be&quot; 1 “ vna” Data Format The VNA data format (with “vna” being the extension name of the input data file) allows user s to store not only network data but also attributes of the nodes, along with information about how to display them (color, size, etc.).
  • 29. Draw Networks using NetDraw Display setup of the nodes and relations Different functions The networks: nodes representing the individuals and links representing the relations
  • 30. Analysis Example: Hot Item Analysis based on Giftcard selling information from eBay
    • Each circle in the graph represents an active item in the database.
    • The label of the circle is the item title.
    • The bigger the circle and the label of circle, the hotter the item.
    • Items are clustered together based on the brand information.
    • Hot Topics during April 15 – April 22, 2007
    • Hot Topics during April 22 – April 29, 2007
  • 31. Conclusion
    • In sum, NetDraw can be used for social network visualization.
    • There are a lot of parameters to play with in the tool. The results can be saved as EMF, WMF, BMP and JPG files.
    • NetDraw is available at :
    • http://www.analytictech.com/downloadnd.htm
    • The website also provides detailed documentation .
    • If you have interest, you may also try some other visualization tools such as JUNG ( http://jung.sourceforge.net/ ) and GraphViz ( http:// www.graphviz.org / ).
  • 32.
    • Carefully prepare your data according to the input format required by each tool.
    • Read the documentation of each tool that you decide to use and understand its functionality. Think how it can be applied to your project.
    • Download and play with the tools. You cannot learn anything unless you t ry them by yourself! !!
    Some Suggestions
  • 33. Thanks! Good luck for your projects! 

×