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 8816955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:44:15+00:00 2026-06-14T04:44:15+00:00

I created a SparseInstace object using JavaML library, I put some values into that

  • 0

I created a SparseInstace object using JavaML library, I put some values into that instance but I could not find a solution to assign label on it. For example, the instance is created like

{{2=1.0, 4=2.2};null} 

I want to add specific string value instead of that “null” area. Here is my code:

package helloworld;

import java.io.IOException;
import net.sf.javaml.core.Dataset;
import net.sf.javaml.core.DefaultDataset;
import net.sf.javaml.core.Instance;
import net.sf.javaml.core.SparseInstance;
import net.sf.javaml.matrix.Matrix;
import net.sf.javaml.tools.InstanceTools;
import net.sf.javaml.tools.data.FileHandler;

public class WekaT2 {

public static void main(String[] args) throws IOException, Exception {

    Dataset data = new DefaultDataset();
    Instance tmpInstance = new SparseInstance();

        tmpInstance.put(2, 1.0);
        tmpInstance.put(4, 2.2);
        data.add(tmpInstance);       
    }
}

http://java-ml.sourceforge.net/api/0.1.7/net/sf/javaml/core/SparseInstance.html

How can I add these labels(object names) into the instaces?

  • 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-14T04:44:16+00:00Added an answer on June 14, 2026 at 4:44 am

    What you are trying to set is called the class label or class value as it is stated in the documentation. You can use the following method
    setClassValue(java.lang.Object value)
    Sample usage would be

        Instance tmpInstance = new SparseInstance();
        tmpInstance.put(2, 1.0);
        tmpInstance.put(4, 2.2);
        tmpInstance.setClassValue("positive");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Created a google map with GMap2 and put pinpoints on there that open up
Created using Sphinx 0.6.5. I know Python's documentation uses reStructuredText , but it has
I created a regular expression that reads a string and transforms found url's into
Created an array that needs randomizing however the array_rand is not working. Is my
Created an OpenGraph action and object. Trying to submit my action. When I click
I created a python server on port 8000 using python -m SimpleHTTPServer . When
Created new scaffold Users that has fields name & description All working as suppose
Created a AlertDialog that is used to prompting the user to enter a keyword.
Created basic C++ DLL and exported names using Module Definition file (MyDLL.def). After compilation
Created a profile using content provider. After running it correctly, added 3 fields to

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.