Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8458601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:07:27+00:00 2026-06-10T13:07:27+00:00

In Weka, class StringToWordVector defines a method called setNormalizeDocLength . It normalizes word frequencies

  • 0

In Weka, class StringToWordVector defines a method called setNormalizeDocLength. It normalizes word frequencies of a document. My questions are:

  1. what is meant by “normalizing word frequency of a document”?
  2. How Weka does this?

A practical example will help me best. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:07:29+00:00Added an answer on June 10, 2026 at 1:07 pm

    Looking in the Weka source, this is the method that does the normalising:

    private void normalizeInstance(Instance inst, int firstCopy) throws Exception 
    {
        double docLength = 0;
    
        if (m_AvgDocLength < 0) 
        {
            throw new Exception("Average document length not set.");
        }
    
        // Compute length of document vector
        for(int j=0; j<inst.numValues(); j++) 
        {
            if(inst.index(j)>=firstCopy) 
            {
                docLength += inst.valueSparse(j) * inst.valueSparse(j);
            }
        }     
        docLength = Math.sqrt(docLength);
    
        // Normalize document vector
        for(int j=0; j<inst.numValues(); j++) 
        {
            if(inst.index(j)>=firstCopy) 
            {
                double val = inst.valueSparse(j) * m_AvgDocLength / docLength;
                inst.setValueSparse(j, val);
                if (val == 0)
                {
                    System.err.println("setting value "+inst.index(j)+" to zero.");
                    j--;
                }
            }
        }
    }
    

    It looks like the most relevant part is

    double val = inst.valueSparse(j) * m_AvgDocLength / docLength;
    inst.setValueSparse(j, val);
    

    So it looks like the normalisation is value = currentValue * averageDocumentLength / actualDocumentLength.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program like this - import weka.core.stemmers.SnowballStemmer; public class TestProject{ public static
I'm trying to do a document classification using Weka java API. Here is my
I have been using Weka’s J48 decision tree to classify frequencies of keywords in
I came across the following documentation for HierarchicalClusterer class in WEKA: public void setLinkType(SelectedTag
In the case of Weka's Explorer, is there any way to get the class
in Weka there is a filter called ReplaceMissingValues that permit to replace all missing
In WEKA, when I try to debug the code with an instance that has
I am new to Weka and I am trying to build a classifier to
I want to run weka through the command line. I type in this command:
I am currently writing a program using Weka that builds a model (using one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.