K-means clustering on WebLog Data, for 2-Dimenshional input

Ads

 
 

Share on Google+Share on Google+

Alok
K-means clustering on WebLog Data, for 2-Dimenshional input
0 Answer(s)      6 years and 5 months ago
Posted in : JSP-Servlet

The following is a JSP code for K-MEANS CLUSTERING .... My proect , titled "Pattern Analysis of Web Usage for System Improvement", involves the web log info from a database and then considering the attributes IP address and WEBPAGES,IN THE FORM OF NUMBERS(X,Y) for K-MEANS CLUSTERING... the output of this is used for WEB CACHE REPLACEMENT.. please let me knw,if the following code of K-MEANS CLUSTERING in JSP is proper and will take 2 dimenshional input(ip,webpages)... i m having hard time in converting ip and webpages into number for K-MEANS CLUSTERING...please reply.

<html>
<head>
<script type="text/javascript">

function kmeans( arrayToProcess, Clusters )
{

  var Groups = new Array();
  var Centroids = new Array();
  var oldCentroids = new Array();
  var changed = false;

  // order the input array
  arrayToProcess.sort(function(a,b){return a - b})  

  // initialise group arrays
  for( initGroups=0; initGroups < Clusters; initGroups++ )
  {

    Groups[initGroups] = new Array();

  }  

  // pick initial centroids

  initialCentroids=Math.round( arrayToProcess.length/(Clusters+1) );  

  for( i=0; i<Clusters; i++ )
  {

    Centroids[i]=arrayToProcess[ (initialCentroids*(i+1)) ];

  }

  do
  {

    for( j=0; j<Clusters; j++ )
    {

      Groups[j] = [];

    }

    changed=false;

    for( i=0; i<arrayToProcess.length; i++ )
    {

      Distance=-1;
      oldDistance=-1

      for( j=0; j<Clusters; j++ )
      {

        distance = Math.abs( Centroids[j]-arrayToProcess[i] );  

        if ( oldDistance==-1 )
        {

           oldDistance = distance;
           newGroup = j;

        }
        else if ( distance <= oldDistance )
        {

            newGroup=j;
            oldDistance = distance;

        }

      } 

      Groups[newGroup].push( arrayToProcess[i] );     

    }

    oldCentroids=Centroids;

    for ( j=0; j<Clusters; j++ )
    {

      total=0;
      newCentroid=0;

      for( i=0; i<Groups[j].length; i++ )
      {

        total+=Groups[j][i];

      } 

      newCentroid=total/Groups[newGroup].length;  

      Centroids[j]=newCentroid;

    }

    for( j=0; j<Clusters; j++ )
    {

      if ( Centroids[j]!=oldCentroids[j] )
      {

        changed=true;

      }

    }

  }
  while( changed==true );

  return Groups;
}


    </script>
</head>
<html>
Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
K-means clustering on WebLog Data, for 2-Dimenshional input
K-means clustering on WebLog Data, for 2-Dimenshional input  The following is a JSP code for K-MEANS CLUSTERING .... My proect , titled "Pattern... OF NUMBERS(X,Y) for K-MEANS CLUSTERING... the output of this is used for WEB CACHE
Clustering
Clustering  Plz let me know abt Clustering in Java with an example
Advertisements
Data input & output Stream
Data input & output Stream  Explain Data Input Stream and Data Output Stream Class.   DataInputStream and DataOutputStream A data input stream lets an application read primitive Java data types from an underlying input
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening the program. I am developing a college library management system, i would like
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening the program. I am developing a college library management system, i would like
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening the program. I am developing a college library management system, i would like
Managing Multiple User Input Data in an Array (or ArrayList)
Managing Multiple User Input Data in an Array (or ArrayList)  Hey... record alphabetically (2) If user chooses choice1, the input data is stored in an ARRAY (or ARRAYLIST) until the user chooses to stop inputting data. Kindly
input
input  a java program that will exchange the last names of two students that were input by a user
Version of com.brettonw>clustering dependency
List of Version of com.brettonw>clustering dependency
Version of geronimo>geronimo-clustering dependency
List of Version of geronimo>geronimo-clustering dependency
Version of com.apporiented>hierarchical-clustering dependency
List of Version of com.apporiented>hierarchical-clustering dependency
Maven Dependency clustering >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.brettonw >> clustering version1.0.0 in your project
Maven Dependency geronimo-clustering >> 1.0-M1
You should include the dependency code given in this page to add Maven Dependency of geronimo >> geronimo-clustering version1.0-M1 in your project
Maven Dependency geronimo-clustering >> 1.0-M2
You should include the dependency code given in this page to add Maven Dependency of geronimo >> geronimo-clustering version1.0-M2 in your project
Maven Dependency geronimo-clustering >> 1.0-M3
You should include the dependency code given in this page to add Maven Dependency of geronimo >> geronimo-clustering version1.0-M3 in your project
Maven Dependency geronimo-clustering >> 1.0-M4
You should include the dependency code given in this page to add Maven Dependency of geronimo >> geronimo-clustering version1.0-M4 in your project
Maven Dependency geronimo-clustering >> 1.0-M5
You should include the dependency code given in this page to add Maven Dependency of geronimo >> geronimo-clustering version1.0-M5 in your project
Maven Dependency hierarchical-clustering >> 1.0.3
You should include the dependency code given in this page to add Maven Dependency of com.apporiented >> hierarchical-clustering version1.0.3 in your project
Maven Dependency hierarchical-clustering >> 1.1.0
You should include the dependency code given in this page to add Maven Dependency of com.apporiented >> hierarchical-clustering version1.1.0 in your project
Problem in Blazeds with Jboss Clustering ( Mod_JK with SSL )
Problem in Blazeds with Jboss Clustering ( Mod_JK with SSL )  Hi, We are running our flex application in jboss clustering environment with the help... clustering is not needed as we have mod_jk and it will do all the stuff for us
input box
input box  give me the code of input box in core java
input box
input box  give me the code of input box in core java
input output
; Introduction The Java I/O means Java Input/Output and is a part... data types from the input stream in a machine format.... UTFDataFormatException A molformed UTF-8 has been read in a data input stream
escaping user input in php
escaping user input in php  Is it possible to escape the user input while submitting data into database in PHP
Array and input
to input one of the above numbers then i want to print the array without the number user input. how will i do tht
keyboard input
keyboard input  how do I use JOptionPane to accept keyboard input? I know how to import but not specific command on input line   import javax.swing.*; class JOPtionPaneExample { public static void main(String
Java Command Line Input
this code you will find the output as Please Input A Number 2 data is- 2...Java Command Line Input  How to get input from command line in java ?   Hi please Find the code for inputting data from the command line
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args
Input - Output String Functions
data from a user (text field, text area) since it is not secure to receive a string data and input them directly into your database. Some special characters... Input - Output String Functions      
Java Input/Output Examples
and interfaces to handle the system input & output through data streams...Java Input/Output Examples In this tutorial you will learn about how the Inputs and outputs are managed in java. To understand the Java Input & Output

Ads

 
Advertisement null

Ads