• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • About
  • Life
  • Tech
  • Travel
  • Work
  • Questions
  • Contact

Welcome

.

How to solve this java.lang.ArrayIndexOutOfBoundsException

April 11, 2020 by

Questions › How to solve this java.lang.ArrayIndexOutOfBoundsException
0
Vote Up
Vote Down
Garmaine asked 4 years ago
public static int classify(int Newlength, int count7, int count8, int count2, int count6, int count3, int count1,
        int count4, int count5, boolean Backslash, boolean if_https, boolean if_http, boolean ifIP, int count10,
        int count11, int count12)// ,boolean Backslash,boolean if_https, boolean if_http,boolean ifIP
{

    // Create attributes to be used with classifiers
    // Test the model

    int result = 0;
    try {

        ArrayList<Attribute> attributeList = new ArrayList<Attribute>();

        Attribute length = new Attribute("length");
        Attribute hashtag = new Attribute("#");
        Attribute percentage = new Attribute("%");
        Attribute at = new Attribute("@");
        Attribute qustionmark = new Attribute("?");
        Attribute and = new Attribute("&");
        Attribute singdoller = new Attribute("$");
        Attribute dot = new Attribute(".");
        Attribute colon = new Attribute(":");// its mean :
        Attribute doublebackshalsh = new Attribute("//");
        Attribute https = new Attribute("https");
        Attribute http = new Attribute("http");
        Attribute ip = new Attribute("Ip");
        Attribute Greek = new Attribute("Greek");
        Attribute Cyrillic = new Attribute(" Cyrillic");
        Attribute latin = new Attribute("Glatin");

        ArrayList<String> classVal = new ArrayList<String>();
        classVal.add("YES");
        classVal.add("NO");

        attributeList.add(length);
        attributeList.add(hashtag);
        attributeList.add(percentage);
        attributeList.add(at);
        attributeList.add(qustionmark);
        attributeList.add(and);
        attributeList.add(singdoller);
        attributeList.add(dot);
        attributeList.add(colon);
        attributeList.add(doublebackshalsh);
        attributeList.add(https);
        attributeList.add(http);
        attributeList.add(ip);
        attributeList.add(Greek);
        attributeList.add(Cyrillic);
        attributeList.add(latin);

        attributeList.add(new Attribute("@@Target@", classVal));

        Instances data = new Instances("TestInstances", attributeList, 0);
        System.out.println(data);
        Instance inst_co;

        data.setClassIndex(data.numAttributes() - 1);
        inst_co = new DenseInstance(data.numAttributes());
        data.add(inst_co);

        String bs = Boolean.toString(Backslash);// for backslash
        String hs = Boolean.toString(if_https);// for https
        String hp = Boolean.toString(if_http);// for http
        String ips = Boolean.toString(ifIP);// for ip

        inst_co.setValue(length, Newlength);
        inst_co.setValue(hashtag, count7);
        inst_co.setValue(percentage, count8);
        inst_co.setValue(at, count2);
        inst_co.setValue(qustionmark, count6);
        inst_co.setValue(and, count3);
        inst_co.setValue(singdoller, count1);
        inst_co.setValue(dot, count4);
        inst_co.setValue(colon, count5);
        inst_co.setValue(doublebackshalsh, 2);
        inst_co.setValue(https, 3);
        inst_co.setValue(http, 5);
        inst_co.setValue(ip, 3);

        inst_co.setValue(Greek, count10);
        inst_co.setValue(Cyrillic, count11);
        inst_co.setValue(latin, count12);
        inst_co.setDataset(data);
        System.out.println("The instance: " + inst_co);
        // inst_co.setDataset(race);

        // load classifier from file
        Classifier cls_co = (Classifier) weka.core.SerializationHelper
                .read("src/user_withexcel3/NaivBayesmodel.model");

        result = (int) cls_co.classifyInstance(inst_co);

        System.out.println(result);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return result;
}
Are you looking for the answer?
Original Question and Possible Answers can be found on `http://stackoverflow.com`

Question Tags: java, weka

Please login or Register to submit your answer




Primary Sidebar

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Newsletter

Complete the form below, and we'll send you all the latest news.

Footer

Footer Funnies

Who knew that reading the footer could be such a hilarious adventure? As we navigate websites, books, and documents, we often stumble upon the unassuming space at the bottom, only to discover a treasure trove of amusement. In this side-splitting compilation, we present 100 jokes that celebrate the unsung hero of content – the footer. Get ready to chuckle, giggle, and maybe even snort as we dive into the world of footnotes, disclaimers, and hidden comedic gems. Brace yourself for a wild ride through the footer!

Recent

  • Unveiling the Enigma: Almost-Magical Lamp Lights Highway Turns
  • The Impact of Young Onset Dementia on Employment and Finances: Optimizing Post-Diagnostic Approaches
  • 11 Wonders of 2023 Technological Breakthrough – Unveiling the Future
  • Work from Home and Stay Mentally Sane – Achieve Productivity and Well-being
  • Hidden Gems of New York City – Uncover the Must-See Treasures!

Search

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Copyright © 2023