Java Double Array Convert doubleArrayToClassNames(int[] labels, String[] classNames, Character separatorChar)

Here you can find the source of doubleArrayToClassNames(int[] labels, String[] classNames, Character separatorChar)

Description

Converts a bipartition array into a list of class names.

License

Apache License

Declaration

public static String doubleArrayToClassNames(int[] labels, String[] classNames, Character separatorChar) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright 2016/*from  www .  j  a  va 2 s. c  om*/
 * Ubiquitous Knowledge Processing (UKP) Lab
 * Technische Universit?t Darmstadt
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

public class Main {
    /**
     * Converts a bipartition array into a list of class names. Parameter arrays must have the same
     * length
     */
    public static String doubleArrayToClassNames(int[] labels, String[] classNames, Character separatorChar) {
        StringBuffer buffer = new StringBuffer();

        for (int y = 0; y < labels.length; y++) {
            if (labels[y] == 1) {
                buffer.append(classNames[y] + separatorChar);
            }
        }
        String classString;
        try {
            classString = buffer.substring(0, buffer.length() - 1).toString();
        } catch (StringIndexOutOfBoundsException e) {
            classString = "";
        }
        return classString;
    }
}

Related

  1. doubleArrayToBytes(double[] d)
  2. doubleArrayToFloatArray(double[] doubleArray)
  3. doubleArrayToIntArray(double[] doubles)