Ejemplo n.º 1
0
bool RandomForests::combineModels( const RandomForests &forest ){

    if( !getTrained() ){
        errorLog << "combineModels( const RandomForests &forest ) - This instance has not been trained!" << endl;
        return false;
    }

    if( !forest.getTrained() ){
        errorLog << "combineModels( const RandomForests &forest ) - This external forest instance has not been trained!" << endl;
        return false;
    }

    if( this->getNumInputDimensions() != forest.getNumInputDimensions() ) {
        errorLog << "combineModels( const RandomForests &forest ) - The number of input dimensions of the external forest (";
        errorLog << forest.getNumInputDimensions() << ") does not match the number of input dimensions of this instance (";
        errorLog << this->getNumInputDimensions() << ")!" << endl;
        return false;
    }

    //Add the trees in the other forest to this model
    DecisionTreeNode *node;
    for(UINT i=0; i<forest.getForestSize(); i++){
        node = forest.getTree(i);
        if( node ){
            this->forest.push_back( node->deepCopy() );
            forestSize++;
        }
    }

    return true;
}
Ejemplo n.º 2
0
bool RandomForests::setDecisionTreeNode( const DecisionTreeNode &node ){
    
    if( decisionTreeNode != NULL ){
        delete decisionTreeNode;
        decisionTreeNode = NULL;
    }
    this->decisionTreeNode = node.deepCopy();
    
    return true;
}
Ejemplo n.º 3
0
RandomForests::RandomForests(const DecisionTreeNode &decisionTreeNode,const UINT forestSize,const UINT numRandomSplits,const UINT minNumSamplesPerNode,const UINT maxDepth,const UINT trainingMode,const bool removeFeaturesAtEachSpilt,const bool useScaling,const Float bootstrappedDatasetWeight)
{
    this->decisionTreeNode = decisionTreeNode.deepCopy();
    this->forestSize = forestSize;
    this->numRandomSplits = numRandomSplits;
    this->minNumSamplesPerNode = minNumSamplesPerNode;
    this->maxDepth = maxDepth;
    this->trainingMode = trainingMode;
    this->removeFeaturesAtEachSpilt = removeFeaturesAtEachSpilt;
    this->useScaling = useScaling;
    this->bootstrappedDatasetWeight = bootstrappedDatasetWeight;
    classType = "RandomForests";
    classifierType = classType;
    classifierMode = STANDARD_CLASSIFIER_MODE;
    useNullRejection = false;
    supportsNullRejection = false;
    useValidationSet = true;
    validationSetSize = 20;
    debugLog.setProceedingText("[DEBUG RandomForests]");
    errorLog.setProceedingText("[ERROR RandomForests]");
    trainingLog.setProceedingText("[TRAINING RandomForests]");
    warningLog.setProceedingText("[WARNING RandomForests]");
}