Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet K-means clustering on WebLog Data, for 2-Dimenshional input
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Alok
K-means clustering on WebLog Data, for 2-Dimenshional input
0 Answer(s)      3 years and 6 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>

Advertisement
View Answers

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
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
input  a java program that will exchange the last names of two students that were input by a user
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
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
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
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
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 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
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
Take input in batch file
Take input in batch file  How to take input in batch file? Thanks   Hi, You can use the following line of code in your batch file: set /p myfile=Enter file name: In the above code myfile variable will hold the data
store input and display previous input as well current input. in jsp
store input and display previous input as well current input. in jsp  Hi Friend, In this JSP program i want display the previous input as well current inputs also. currently only current input i am able to display whenever i
input - Java Beginners
to input the data from the command prompt. Try the following code to input name... me soon.  Hi Friend, There are lot of ways to input data.You can use...:"); Scanner input=new Scanner(System.in); String name=input.nextLine
How to create an input box?
How to create an input box?  How to create an input box
php date input calendar
php date input calendar  I'm having an issue while writing the date input calendar function in PHP.. any help? Thanks
Input in Stateless Bean - EJB
Input in Stateless Bean  Hello, I am having problem in taking the input in stateless bean, when I am trying to get integer or double type input from the user in the client file, It shows me the error
validate input php
validate input php  How to validate the input fields in PHP & HTML.   Hi, Please let's know many fields is to be validated. Then I will make an example for you. Thanks
The input device used by computer is
The input device used by computer is  The input device used by computer is 1. Motherboard 2. Central Processing Unit 3. Keyboard 4. System Unit 5. All of the above   Answer: 2. Central Processing Unit
data
data  Handling data
HTML5 input examples, Introduction and implementation of input tag.
HTML5 input examples, Introduction and implementation of input tag. Introduction:In this tutorial, you will see the use of input tag. The input tag is a input field in a form. In which user can insert data, and the type of data
button to accept user input
the radiobutton and spinner.The user input does not show on my Studentinfo.mdb..."); PreparedStatement st=con.prepareStatement("insert into data(firstname,lastname...(3,g); int i=st.executeUpdate(); JOptionPane.showMessageDialog(null,"Data
 

 

 

DMCA.com