All Downloads are FREE. Search and download functionalities are using the official Maven repository.

au.gov.amsa.risky.format.LibSvm Maven / Gradle / Ivy

There is a newer version: 0.6.19
Show newest version
package au.gov.amsa.risky.format;

import java.io.IOException;
import java.io.Writer;

public class LibSvm {

    public static void write(Writer writer, int classification, double... values) {
        try {
            writer.write(Integer.toString(classification));

            for (int i = 0; i < values.length; i++) {
                double value = values[i];
                if (value != 0) {
                    writer.write(' ');
                    writer.write(Integer.toString(i + 1));
                    writer.write(':');
                    writer.write(Float.toString((float) value));
                }
            }
            writer.write('\n');
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy