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

📄 plsregressionmodel.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * Loads a PLSRegressionModel object from disk in to the current session.     *     * @param fileName The disk file containing the model     * @throws QSARModelException if the model being loaded is not a PLS regression model     * object     */    public void  loadModel(String fileName) throws QSARModelException {        // should probably check that the filename does exist        Object model = (Object)revaluator.call("loadModel", new Object[]{ (Object)fileName });        String modelName = (String)revaluator.call("loadModel.getName", new Object[] { (Object)fileName });        if (model.getClass().getName().equals("org.openscience.cdk.qsar.model.R.PLSRegressionModelFit")) {            this.modelfit = (PLSRegressionModelFit)model;            this.setModelName(modelName);        } else throw new QSARModelException("The loaded model was not a PLSRegressionModel");    }    /**     * Loads an PLSRegressionModel object from a serialized string into the current session.     *     * @param serializedModel A String containing the serialized version of the model     * @param modelName A String indicating the name of the model in the R session     * @throws QSARModelException if the model being loaded is not a PLS regression model     * object     */    public void  loadModel(String serializedModel, String modelName) throws QSARModelException {        // should probably check that the fileName does exist        Object model = (Object)revaluator.call("unserializeModel", new Object[]{ (Object)serializedModel, (Object)modelName });        String modelname = modelName;        if (model.getClass().getName().equals("org.openscience.cdk.qsar.model.R.PLSRegressionModelFit")) {            this.modelfit =(PLSRegressionModelFit)model;            this.setModelName(modelname);        } else throw new QSARModelException("The loaded model was not a PLSRegressionModel");    }    /**     * Sets parameters required for building a PLS model or using one for prediction.     *     * This function allows the caller to set the various parameters available     * for the pls()  and predict.mvr() R routines. See the R help pages for the details of the available     * parameters.     *      * @param key A String containing the name of the parameter as described in the      * R help pages     * @param obj An Object containing the value of the parameter     * @throws QSARModelException if the type of the supplied value does not match the      * expected type     */    public void setParameters(String key, Object obj) throws QSARModelException {        // since we know the possible values of key we should check the coresponding        // objects and throw errors if required. Note that this checking can't really check        // for values (such as number of variables in the X matrix to build the model and the        // X matrix to make new predictions) - these should be checked in functions that will        // use these parameters. The main checking done here is for the class of obj and        // some cases where the value of obj is not dependent on what is set before it        if (key.equals("Y")) {            if (!(obj instanceof Double[])) {                throw new QSARModelException("The class of the 'Y' object must be Double[][]");            }        }        if (key.equals("X")) {            if (!(obj instanceof Double[][])) {                throw new QSARModelException("The class of the 'X' object must be Double[][]");            }        }        if (key.equals("method")) {            if (!(obj instanceof String)) {                throw new QSARModelException("The class of the 'method' object must be String");            }            if (!(obj.equals("SIMPLS") || obj.equals("kernelPLS"))) {                throw new QSARModelException("The value of method must be: SIMPLS or kernelPLS ");            }        }        if (key.equals("validation")) {            if (!(obj instanceof String)) {                throw new QSARModelException("The class of the 'validation' object must be String");            }            if (!(obj.equals("none") || obj.equals("CV"))) {                throw new QSARModelException("The value of validation must be: none or CV");            }        }                if (key.equals("newX")) {            if ( !(obj instanceof Double[][])) {                throw new QSARModelException("The class of the 'newX' object must be Double[][]");            }        }        if (key.equals("grpsize")) {            if (!(obj instanceof Integer)) {                throw new QSARModelException("The class of the 'grpsize' object must be Integer");            }        }        if (key.equals("niter")) {            if (!(obj instanceof Integer)) {                throw new QSARModelException("The class of the 'niter' object must be Integer");            }        }        if (key.equals("nlv")) {            if (!(obj instanceof Integer)) {                throw new QSARModelException("The class of the 'nlv' object must be Integer");            }        }                if (key.equals("ncomp")) {            if (!(obj instanceof Integer[])) {                throw new QSARModelException("The class of the 'ncomp' object must be Integer[]");            }            Integer[] tmp = (Integer[])obj;            if (tmp.length != 1 && tmp.length != 2) {                throw new QSARModelException("The 'ncomp' array can have a length of 1 or 2. See documentation");            }        }                this.params.put(key,obj);    }                   /* interface to fit object */    /**     * The method used to build the PLS model.     *     * @return String containing 'SIMPLS' or 'kernelPLS'     */    public String getFitMethod() {        return(this.modelfit.getMethod());    }    /**     * Returns the fit NComp value.     *     * @return An array of integers indicating the number of components     * (latent variables)     */    public int[] getFitNComp() {        return(this.modelfit.getNComp());    }    /**     * Gets the coefficents.     *     * The return value is a 3D array. The first dimension corresponds     * to the specific number of LV's (1 or 2 or 3 and so on). The second     * dimension corresponds to the independent variables and the third     * dimension corresponds to the Y variables.     *     * @return double[][][] containing the coefficients     */    public double[][][] getFitB() {        return(this.modelfit.getB());    }        /**     * Get the Root Mean Square (RMS) error for the fit.     *     * @return A 2-dimensional array of RMS errors.     */    public double[][] getFitRMS() {        return(this.modelfit.getTrainingRMS());    }    /**     * Get the predicted Y's.     *     * Each set of latent variables is used to make predictions for all the     * Y variables.     *     * @return A 3-dimensional array of doubles. The first dimension corresponds     * to the set of latent variables and the remaining two correspond to the      * Y's themselves.     */    public double[][][] getFitYPred() {        return(this.modelfit.getTrainingYPred());    }    /**     * Get the X loadings.     *     * @return A 2-dimensional array of doubles containing the X loadings     */    public double[][] getFitXLoading() {        return(this.modelfit.getXLoading());    }    /**     * Get the Y loadings.     *     * @return A 2-dimensional array of doubles containing the Y loadings     */    public double[][] getFitYLoading() {        return(this.modelfit.getYLoading());    }    /**     * Get the X scores.     *     * @return A 2-dimensional array of doubles containing the X scores     */    public double[][] getFitXScores() {        return(this.modelfit.getXScores());    }    /**     * Get the Y scores.     *     * @return A 2-dimensional array of doubles containing the Y scores     */    public double[][] getFitYScores() {        return(this.modelfit.getYScores());    }    /**     * Indicates whether CV was used to build the model.     *     * @return A boolean indicating whether CV was used     */    public boolean getFitWasValidated() {        return(this.modelfit.wasValidated());    }    /**     * The number of iterations used during CV.     *     * @return An int value indicating the number of iterations in CV     */    public int getValidationIter() {        return(this.modelfit.getValidationIter());    }    /**     * The number of latent variables suggested by CV.     *     * @return An int value indicating the number of LV's     */    public int getValidationLV() {        return(this.modelfit.getValidationLV());    }    /**     * Get the R^2 value for validation.     *     * @return A 2-dimensional array of doubles     */    public double[][] getValidationR2() {        return(this.modelfit.getValidationR2());    }    /**     * Get the RMS value for validation.     *     * @return A 2-dimensional array of doubles     */    public double[][] getValidationRMS() {        return(this.modelfit.getValidationRMS());    }    /**     * Get the standard deviation of the RMS errrors for validation.     *     * @return A 2-dimensional array of doubles     */    public double[][] getValidationRMSsd() {        return(this.modelfit.getValidationRMSSD());    }    /**     * Get the predicted Y values from validation.     *     * @return A 2-dimensional array of doubles     */    public double[][][] getValidationYPred() {        return(this.modelfit.getValidationYPred());    }        /* interface to predict object */    /**     * Returns the predicted values for the prediction set.      *     * This function only returns meaningful results if the <code>predict</code>     * method of this class has been called.     *     * @return A double[][] containing the predicted values     */    public  double[][] getPredictPredicted() {        return(this.modelpredict.getPredictions());    }}

⌨️ 快捷键说明

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