⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbscan.java

📁 数据挖掘中聚类的算法
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        1,                        "-I <String>"));        vector.addElement(                new Option("\tdistance-type (default = weka.clusterers.forOPTICSAndDBScan.DataObjects.EuclidianDataObject)",                        "D",                        1,                        "-D <String>"));        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 &lt;double&gt;     *  epsilon (default = 0.9)</pre>     *      * <pre> -M &lt;int&gt;     *  minPoints (default = 6)</pre>     *      * <pre> -I &lt;String&gt;     *  index (database) used for DBScan (default = weka.clusterers.forOPTICSAndDBScan.Databases.SequentialDatabase)</pre>     *      * <pre> -D &lt;String&gt;     *  distance-type (default = weka.clusterers.forOPTICSAndDBScan.DataObjects.EuclidianDataObject)</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);        }    }    /**     * 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[8];        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();        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 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 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, "Martin Ester and Hans-Peter Kriegel and Joerg Sander and Xiaowei Xu");      result.setValue(Field.TITLE, "A Density-Based Algorithm for Discovering Clusters in Large Spatial Databases with Noise");      result.setValue(Field.BOOKTITLE, "Second International Conference on Knowledge Discovery and Data Mining");      result.setValue(Field.EDITOR, "Evangelos Simoudis and Jiawei Han and Usama M. Fayyad");      result.setValue(Field.YEAR, "1996");      result.setValue(Field.PAGES, "226-231");      result.setValue(Field.PUBLISHER, "AAAI Press");            return result;    }    /**     * Returns a description of the clusterer     *      * @return a string representation of the clusterer     */    public String toString() {        StringBuffer stringBuffer = new StringBuffer();        stringBuffer.append("DBScan 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("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 < database.size(); i++) {            DataObject dataObject = database.getDataObject(Integer.toString(i));            stringBuffer.append("(" + Utils.doubleToString(Double.parseDouble(dataObject.getKey()),                    (Integer.toString(database.size()).length()), 0) + ".) "                    + Utils.padRight(dataObject.toString(), 69) + "  -->  " +                    ((dataObject.getClusterLabel() == DataObject.NOISE) ?                    "NOISE\n" : dataObject.getClusterLabel() + "\n"));        }        return stringBuffer.toString() + "\n";    }    /**     * Main Method for testing DBScan     * @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);     */    public static void main(String[] args) {        runClusterer(new DBScan(), args);    }    // *****************************************************************************************************************    // inner classes    // *****************************************************************************************************************}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -