function Utils() { } Utils.prototype = { constructor: Utils, isElementInView: function (element, fullyInView) { var pageTop = $(window).scrollTop(); var pageBottom = pageTop + $(window).height(); var elementTop = $(element).offset().top; var elementBottom = elementTop + $(element).height(); if (fullyInView === true) { return ((pageTop < elementTop) && (pageBottom > elementBottom)); } else { return ((elementTop <= pageBottom) && (elementBottom >= pageTop)); } } }; var Utils = new Utils();
public class Main extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Utils util = new Utils(this); util.startTest(); } @Override protected void onActivityResult(int arg0, int arg1, Intent arg2) { Toast.makeText(this, "onActivityResult called", Toast.LENGTH_LONG).show(); super.onActivityResult(arg0, arg1, arg2); } }
Instances dataUnlabeled = new Instances("TestInstances", atts, 0); dataUnlabeled.add(newInst); dataUnlabeled.setClassIndex(dataUnlabeled.numAttributes() - 1); double classif = ibk.classifyInstance(dataUnlabeled.firstInstance());
System.out.println("--------------------------"); double[] instanceValue1 = new double[dataRaw.numAttributes()]; instanceValue1[0] = dataRaw.attribute(0).addStringValue("This is a string!"); instanceValue1[1] = 0; dataRaw.add(new DenseInstance(1.0, instanceValue1)); System.out.println("--------------------------"); double[] instanceValue2 = new double[dataRaw.numAttributes()]; instanceValue2[0] = dataRaw.attribute(0).addStringValue("This is second string!"); instanceValue2[1] = 1; dataRaw.add(new DenseInstance(1.0, instanceValue2));
DataSource source = new DataSource(new File("mycsvinputfile")); System.out.println(source.getStructure()); Instances data = source.getDataSet(); // setting class attribute if the data format does not provide this information // For example, the XRFF format saves the class attribute information as well if (data.classIndex() == -1) data.setClassIndex(data.numAttributes() - 1); //initialize svm classifier LibSVM svm = new LibSVM(); svm.buildClassifier(data);
//load model String rootPath="/some/where/"; Classifier cls = (Classifier) weka.core.SerializationHelper.read(rootPath+"tree.model"); //predict instance class values Instances originalTrain= //load or create Instances to predict //which instance to predict class value int s1=0; //perform your prediction double value=cls.classifyInstance(originalTrain.instance(s1)); //get the name of the class value String prediction=originalTrain.classAttribute().value((int)value); System.out.println("The predicted value of instance "+ Integer.toString(s1)+ ": "+prediction);
double[] prediction=model.distributionForInstance(test.get(s1)); test.classAttribute().value(i)+ " : "+Double.toString(prediction[i]));
public void testResettingOptions() { CheckOptionHandler optionHandler = new CheckOptionHandler(); DictionaryBuilder builder = new DictionaryBuilder(); optionHandler.setOptionHandler(builder); if (!optionHandler.checkResettingOptions()) { fail("Resetting of options failed"); } }
/** * Parses a given list of options. * * @param options the list of options as an array of strings * @throws Exception if an option is not supported */ @Override public void setOptions(String[] options) throws Exception { super.setOptions(options); setProlog(!Utils.getFlag("noprolog", options)); }
/** * Parses a given list of options. * * @param options the list of options as an array of strings * @throws Exception if an option is not supported */ @Override public void setOptions(String[] options) throws Exception { super.setOptions(options); setProlog(!Utils.getFlag("noprolog", options)); }
public void testCanonicalUserOptions() { CheckOptionHandler optionHandler = new CheckOptionHandler(); DictionaryBuilder builder = new DictionaryBuilder(); optionHandler.setOptionHandler(builder); if (!optionHandler.checkCanonicalUserOptions()) { fail("setOptions method failed"); } }
public void testListOptions() { CheckOptionHandler optionHandler = new CheckOptionHandler(); DictionaryBuilder builder = new DictionaryBuilder(); optionHandler.setOptionHandler(builder); if (!optionHandler.checkListOptions()) { fail("Options cannot be listed via listOptions"); } }
public void testSetOptions() { CheckOptionHandler optionHandler = new CheckOptionHandler(); DictionaryBuilder builder = new DictionaryBuilder(); optionHandler.setOptionHandler(builder); if (!optionHandler.checkSetOptions()) { fail("setOptions method failed"); } }
/** * Sets which attributes are to be processed. * * @param attributes an array containing indexes of attributes to process. * Since the array will typically come from a program, attributes are * indexed from 0. * @throws IllegalArgumentException if an invalid set of ranges is supplied */ public void setAttributeIndicesArray(int[] attributes) { setAttributeIndices(Range.indicesToRangeList(attributes)); }
public void testResettingOptions() { CheckOptionHandler optionHandler = new CheckOptionHandler(); DictionaryBuilder builder = new DictionaryBuilder(); optionHandler.setOptionHandler(builder); if (!optionHandler.checkResettingOptions()) { fail("Resetting of options failed"); } }