public void setPriors(Instances train) throws Exception {

        m_NoPriors = false;

        if (!m_ClassIsNominal) {

            m_NumTrainClassVals = 0;
            m_TrainClassVals = null;
            m_TrainClassWeights = null;
            m_PriorEstimator = null;

            m_MinTarget = Double.MAX_VALUE;
            m_MaxTarget = -Double.MAX_VALUE;

            for (int i = 0; i < train.numInstances(); i++) {
                Instance currentInst = train.instance(i);
                if (!currentInst.classIsMissing()) {
                    addNumericTrainClass(currentInst.classValue(), currentInst.weight());
                }
            }

            m_ClassPriors[0] = m_ClassPriorsSum = 0;
            for (int i = 0; i < train.numInstances(); i++) {
                if (!train.instance(i).classIsMissing()) {
                    m_ClassPriors[0] += train.instance(i).classValue() * train.instance(i).weight();
                    m_ClassPriorsSum += train.instance(i).weight();
                }
            }

        } else {
            for (int i = 0; i < m_NumClasses; i++) {
                m_ClassPriors[i] = 1;
            }
            m_ClassPriorsSum = m_NumClasses;
            for (int i = 0; i < train.numInstances(); i++) {
                if (!train.instance(i).classIsMissing()) {
                    m_ClassPriors[(int) train.instance(i).classValue()] +=
                            train.instance(i).weight();
                    m_ClassPriorsSum += train.instance(i).weight();
                }
            }
            m_MaxTarget = m_NumClasses;
            m_MinTarget = 0;
        }
    }