📄 optics.java
字号:
new Option("\tdistance-type (default = weka.clusterers.forOPTICSAndDBScan.DataObjects.EuclidianDataObject)", "D", 1, "-D <String>")); vector.addElement( new Option("\twrite results to OPTICS_#TimeStamp#.TXT - File", "F", 0, "-F")); return vector.elements(); } /** * Sets the OptionHandler's options using the given list. All options * will be set (or reset) during this call (i.e. incremental setting * of options is not possible). <p/> * <!-- options-start --> * Valid options are: <p/> * * <pre> -E <double> * epsilon (default = 0.9)</pre> * * <pre> -M <int> * minPoints (default = 6)</pre> * * <pre> -I <String> * index (database) used for OPTICS (default = weka.clusterers.forOPTICSAndDBScan.Databases.SequentialDatabase)</pre> * * <pre> -D <String> * distance-type (default = weka.clusterers.forOPTICSAndDBScan.DataObjects.EuclidianDataObject)</pre> * * <pre> -F * write results to OPTICS_#TimeStamp#.TXT - File</pre> * <!-- options-end --> * * @param options The list of options as an array of strings * @throws java.lang.Exception If an option is not supported */ public void setOptions(String[] options) throws Exception { String optionString = Utils.getOption('E', options); if (optionString.length() != 0) { setEpsilon(Double.parseDouble(optionString)); } optionString = Utils.getOption('M', options); if (optionString.length() != 0) { setMinPoints(Integer.parseInt(optionString)); } optionString = Utils.getOption('I', options); if (optionString.length() != 0) { setDatabase_Type(optionString); } optionString = Utils.getOption('D', options); if (optionString.length() != 0) { setDatabase_distanceType(optionString); } setWriteOPTICSresults(Utils.getFlag('F', options)); } /** * Gets the current option settings for the OptionHandler. * * @return String[] The list of current option settings as an array of strings */ public String[] getOptions() { String[] options = new String[9]; int current = 0; options[current++] = "-E"; options[current++] = "" + getEpsilon(); options[current++] = "-M"; options[current++] = "" + getMinPoints(); options[current++] = "-I"; options[current++] = "" + getDatabase_Type(); options[current++] = "-D"; options[current++] = "" + getDatabase_distanceType(); if (writeOPTICSresults) { options[current++] = "-F"; } while (current < options.length) { options[current++] = ""; } return options; } /** * Returns a new Class-Instance of the specified database * @param database_Type String of the specified database * @param instances Instances that were delivered from WEKA * @return Database New constructed Database */ public Database databaseForName(String database_Type, Instances instances) { Object o = null; Constructor co = null; try { co = (Class.forName(database_Type)).getConstructor(new Class[]{Instances.class}); o = co.newInstance(new Object[]{instances}); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return (Database) o; } /** * Returns a new Class-Instance of the specified database * @param database_distanceType String of the specified distance-type * @param instance The original instance that needs to hold by this DataObject * @param key Key for this DataObject * @param database Link to the database * @return DataObject New constructed DataObject */ public DataObject dataObjectForName(String database_distanceType, Instance instance, String key, Database database) { Object o = null; Constructor co = null; try { co = (Class.forName(database_distanceType)). getConstructor(new Class[]{Instance.class, String.class, Database.class}); o = co.newInstance(new Object[]{instance, key, database}); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return (DataObject) o; } /** * Sets a new value for minPoints * @param minPoints MinPoints */ public void setMinPoints(int minPoints) { this.minPoints = minPoints; } /** * Sets a new value for epsilon * @param epsilon Epsilon */ public void setEpsilon(double epsilon) { this.epsilon = epsilon; } /** * Returns the value of epsilon * @return double Epsilon */ public double getEpsilon() { return epsilon; } /** * Returns the value of minPoints * @return int MinPoints */ public int getMinPoints() { return minPoints; } /** * Returns the distance-type * @return String Distance-type */ public String getDatabase_distanceType() { return database_distanceType; } /** * Returns the type of the used index (database) * @return String Index-type */ public String getDatabase_Type() { return database_Type; } /** * Sets a new distance-type * @param database_distanceType The new distance-type */ public void setDatabase_distanceType(String database_distanceType) { this.database_distanceType = database_distanceType; } /** * Sets a new database-type * @param database_Type The new database-type */ public void setDatabase_Type(String database_Type) { this.database_Type = database_Type; } /** * Returns the flag for writing actions * @return writeOPTICSresults (flag) */ public boolean getWriteOPTICSresults() { return writeOPTICSresults; } /** * Sets the flag for writing actions * @param writeOPTICSresults Results are written to a file if the flag is set */ public void setWriteOPTICSresults(boolean writeOPTICSresults) { this.writeOPTICSresults = writeOPTICSresults; } /** * Returns the resultVector * @return resultVector */ public FastVector getResultVector() { return resultVector; } /** * Returns the tip text for this property * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String epsilonTipText() { return "radius of the epsilon-range-queries"; } /** * Returns the tip text for this property * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String minPointsTipText() { return "minimun number of DataObjects required in an epsilon-range-query"; } /** * Returns the tip text for this property * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String database_TypeTipText() { return "used database"; } /** * Returns the tip text for this property * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String database_distanceTypeTipText() { return "used distance-type"; } /** * Returns the tip text for this property * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String writeOPTICSresultsTipText() { return "if the -F option is set, the results are written to OPTICS_#TimeStamp#.TXT"; } /** * Returns a string describing this DataMining-Algorithm * @return String Information for the gui-explorer */ public String globalInfo() { return getTechnicalInformation().toString(); } /** * Returns an instance of a TechnicalInformation object, containing * detailed information about the technical background of this class, * e.g., paper reference or book this class is based on. * * @return the technical information about this class */ public TechnicalInformation getTechnicalInformation() { TechnicalInformation result; result = new TechnicalInformation(Type.INPROCEEDINGS); result.setValue(Field.AUTHOR, "Mihael Ankerst and Markus M. Breunig and Hans-Peter Kriegel and Joerg Sander"); result.setValue(Field.TITLE, "OPTICS: Ordering Points To Identify the Clustering Structure"); result.setValue(Field.BOOKTITLE, "ACM SIGMOD International Conference on Management of Data"); result.setValue(Field.YEAR, "1999"); result.setValue(Field.PAGES, "49-60"); result.setValue(Field.PUBLISHER, "ACM Press"); return result; } /** * Returns the internal database * * @return the internal database */ public SERObject getSERObject() { SERObject serObject = new SERObject(resultVector, database.size(), database.getInstances().numAttributes(), getEpsilon(), getMinPoints(), writeOPTICSresults, getDatabase_Type(), getDatabase_distanceType(), numberOfGeneratedClusters, Utils.doubleToString(elapsedTime, 3, 3)); return serObject; } /** * Returns a description of the clusterer * * @return the clusterer as string */ public String toString() { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("OPTICS clustering results\n" + "============================================================================================\n\n"); stringBuffer.append("Clustered DataObjects: " + database.size() + "\n"); stringBuffer.append("Number of attributes: " + database.getInstances().numAttributes() + "\n"); stringBuffer.append("Epsilon: " + getEpsilon() + "; minPoints: " + getMinPoints() + "\n"); stringBuffer.append("Write results to file: " + (writeOPTICSresults ? "yes" : "no") + "\n"); stringBuffer.append("Index: " + getDatabase_Type() + "\n"); stringBuffer.append("Distance-type: " + getDatabase_distanceType() + "\n"); stringBuffer.append("Number of generated clusters: " + numberOfGeneratedClusters + "\n"); DecimalFormat decimalFormat = new DecimalFormat(".##"); stringBuffer.append("Elapsed time: " + decimalFormat.format(elapsedTime) + "\n\n"); for (int i = 0; i < resultVector.size(); i++) { stringBuffer.append(format_dataObject((DataObject) resultVector.elementAt(i))); } return stringBuffer.toString() + "\n"; } /** * Main Method for testing OPTICS * @param args Valid parameters are: 'E' epsilon (default = 0.9); 'M' minPoints (default = 6); * 'I' index-type (default = weka.clusterers.forOPTICSAndDBScan.Databases.SequentialDatabase); * 'D' distance-type (default = weka.clusterers.forOPTICSAndDBScan.DataObjects.EuclidianDataObject); * 'F' write results to OPTICS_#TimeStamp#.TXT - File */ public static void main(String[] args) { runClusterer(new OPTICS(), args); } // ***************************************************************************************************************** // inner classes // *****************************************************************************************************************}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -