Package weka.filters.unsupervised.instance

Examples of weka.filters.unsupervised.instance.Randomize


     */
    @Test
    public void testLoad() throws Exception {
        System.out.println("load");

        Randomize filter = new Randomize();
        filter.setRandomSeed(455);

        ArrayList<Filter> filtersList = new ArrayList<Filter>();
        filtersList.add(filter);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream objOut = new ObjectOutputStream(out);
        objOut.writeObject(filtersList);
        out.close();
        byte[] serializedBytes = out.toByteArray();

        ByteArrayInputStream input = new ByteArrayInputStream(serializedBytes);
        FeatureSpecification instance = new FeatureSpecification();
        assertTrue(instance.load(input));
        input.close();

        List<Filter> filters = instance.getFilters();
        assertEquals(1, filters.size());
        assertTrue(filters.get(0) instanceof Randomize);
        Randomize serialized = (Randomize) filters.get(0);
        assertEquals(filter.getRandomSeed(), serialized.getRandomSeed());
    }
View Full Code Here


     */
    @Test
    public void testSave() throws Exception {
        System.out.println("save");;

        Randomize filter = new Randomize();
        filter.setRandomSeed(455);

        FeatureSpecification instance = new FeatureSpecification();
        instance.addFilter(filter);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        assertTrue(instance.save(out));
        out.close();
        byte[] bytes = out.toByteArray();

        //It wrote something
        assertTrue(bytes.length > 0);

        //It wrote the correct thing
        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
        try {
            List<Filter> serialized = (List<Filter>) in.readObject();
            in.close();
            assertEquals(1, serialized.size());
            assertTrue(serialized.get(0) instanceof Randomize);
            Randomize randomize = (Randomize) serialized.get(0);
            assertEquals(filter.getRandomSeed(), randomize.getRandomSeed());
        } catch (ClassNotFoundException e) {
            assertTrue(e.getMessage(), false);
        } catch (IOException e) {
            assertTrue(e.getMessage(), false);
        }
View Full Code Here

     */
    @Test
    public void testAddFilter() {
        System.out.println("addFilter");

        Randomize filter = new Randomize();

        FeatureSpecification instance = new FeatureSpecification();
        instance.addFilter(filter);

        assertEquals(filter, instance.getFilters().get(0));
View Full Code Here

TOP

Related Classes of weka.filters.unsupervised.instance.Randomize

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.