moa.clusterers.outliers.AnyOut.util.DataObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moa Show documentation
Show all versions of moa Show documentation
Massive On-line Analysis is an environment for massive data mining. MOA
provides a framework for data stream mining and includes tools for evaluation
and a collection of machine learning algorithms. Related to the WEKA project,
also written in Java, while scaling to more demanding problems.
/* * DataObject.java * * @author F. Sanchez, I. Assent, P. Kranen, C. Baldauf, T. Seidl * @author G. Piskas, A. Gounaris * * 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. * * */ package moa.clusterers.outliers.AnyOut.util; import com.yahoo.labs.samoa.instances.Instance; /** * This object encapsulates a data point. * @author Fernando Sanchez Villaamil */ public class DataObject { private int id; private Instance inst; private double[] features; private int classLabel; private boolean isOutiler; /** * Returns the features (label attribute excluded). * @return An array
. * @return Andouble[]
with the features. */ public double[] getFeatures() { double[] filteredFeatures = new double[features.length-1]; for (int i = 0; iDataObject int
with the id of theDataObject
. */ public int getId() { return id; } public void setId(int id){ this.id=id; } /** * Return the label for theDataObject
. * @return Anint
which codes the label. */ public int getClassLabel() { return classLabel; } /** * Return theInstance
of theDataObject
. * @return AnInstance
. */ public Instance getInstance() { return inst; } /** * Standard constructor forDataObject
. * @param idCounter The id for theDataObject
. * @param features The feature as adouble[]
* @param classLabel The label id for theDataObject
. */ public DataObject(int idCounter, Instance inst){ this.id = idCounter; this.inst = inst; this.features = inst.toDoubleArray(); this.classLabel = (int)inst.classValue(); this.isOutiler = false; } /** * Returns the number of features (label attribute excluded). * @return The number of features in the point. */ public int getNrOfDimensions(){ return this.features.length-1; } /** * Returns aString
representation of the point. The features are written comma * separated between parenthesis and the label id is written after the closing parenthesis * surrounded by squared brackets. * @return AString
representation of the point. */ @Override public String toString(){ String res = "("; for (int i = 0; i < features.length; i++) { double d = features[i]; res += d; if (i != features.length - 1) res += ","; } res += ")"; res += "[" + this.classLabel + "]"; return res; } public void setOutiler(boolean val) { isOutiler = val; } public boolean isOutiler() { return isOutiler; } }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy