//Clone method
bool FFTFeatures::clone(const FeatureExtraction *featureExtraction){ 
        
    if( featureExtraction == NULL ) return false;
    
    if( this->getFeatureExtractionType() == featureExtraction->getFeatureExtractionType() ){
        
        FFTFeatures *ptr = (FFTFeatures*)featureExtraction;
            
        this->fftWindowSize = ptr->fftWindowSize;
        this->numChannelsInFFTSignal = ptr->numChannelsInFFTSignal;
        this->computeMaxFreqFeature = ptr->computeMaxFreqFeature;
        this->computeMaxFreqSpectrumRatio = ptr->computeMaxFreqSpectrumRatio;
        this->computeCentroidFeature = ptr->computeCentroidFeature;
        this->computeTopNFreqFeatures = ptr->computeTopNFreqFeatures;
        this->N = ptr->N;
        this->maxFreqFeature = ptr->maxFreqFeature;
        this->maxFreqSpectrumRatio = ptr->maxFreqSpectrumRatio;
        this->centroidFeature = ptr->centroidFeature;
        
        copyBaseVariables((FeatureExtraction*)this, featureExtraction);
    }
    
    errorLog << "clone(FeatureExtraction *featureExtraction) -  FeatureExtraction Types Do Not Match!" << endl;
    
    return false;
}
Ejemplo n.º 2
0
bool AdaBoost::deepCopyFrom(const Classifier *classifier){
    
    if( classifier == NULL ){
        errorLog << "deepCopyFrom(const Classifier *classifier) - The classifier pointer is NULL!" << endl;
        return false;
    }
    
    if( this->getClassifierType() == classifier->getClassifierType() ){
        //Clone the AdaBoost values
        AdaBoost *ptr = (AdaBoost*)classifier;
        
        //Clear the current weak classifiers
        clearWeakClassifiers();
        
        this->numBoostingIterations = ptr->numBoostingIterations;
        this->predictionMethod = ptr->predictionMethod;
        this->models = ptr->models;
        
        if( ptr->weakClassifiers.size() > 0 ){
            for(UINT i=0; i<ptr->weakClassifiers.size(); i++){
                WeakClassifier *weakClassiferPtr = ptr->weakClassifiers[i]->createNewInstance();
                weakClassifiers.push_back( weakClassiferPtr );
            }
        }
        
        //Clone the classifier variables
        return copyBaseVariables( classifier );
    }
    return false;
}
bool SVM::deepCopyFrom(const Classifier *classifier){
    
    if( classifier == NULL ) return false;
    
    if( this->getClassifierType() == classifier->getClassifierType() ){
        SVM *ptr = (SVM*)classifier;
        
        this->clear();
        
        //SVM variables
        this->problemSet = false;
        this->model = ptr->deepCopyModel();
        this->deepCopyParam( ptr->param, this->param );
        this->numInputDimensions = ptr->numInputDimensions;
        this->kFoldValue = ptr->kFoldValue;
        this->classificationThreshold = ptr->classificationThreshold;
        this->crossValidationResult = ptr->crossValidationResult;
        this->useAutoGamma = ptr->useAutoGamma;
        this->useCrossValidation = ptr->useCrossValidation;
        
        //Classifier variables
        return copyBaseVariables( classifier );
    }
    
    return false;
}
Ejemplo n.º 4
0
GaussianMixtureModels::GaussianMixtureModels(const GaussianMixtureModels &rhs){
    
    classType = "GaussianMixtureModels";
    clustererType = classType;
    debugLog.setProceedingText("[DEBUG GaussianMixtureModels]");
    errorLog.setProceedingText("[ERROR GaussianMixtureModels]");
    trainingLog.setProceedingText("[TRAINING GaussianMixtureModels]");
    warningLog.setProceedingText("[WARNING GaussianMixtureModels]");
    
    if( this != &rhs ){
        
        this->numTrainingSamples = rhs.numTrainingSamples;
        this->loglike = rhs.loglike;
        this->mu = rhs.mu;
        this->resp = rhs.resp;
        this->frac = rhs.frac;
        this->lndets = rhs.lndets;
        this->det = rhs.det;
        this->sigma = rhs.sigma;
        this->invSigma = rhs.invSigma;
        
        //Clone the Clusterer variables
        copyBaseVariables( (Clusterer*)&rhs );
    }
    
}
Ejemplo n.º 5
0
bool Derivative::deepCopyFrom(const PreProcessing *preProcessing){
    
    if( preProcessing == NULL ) return false;
    
    if( this->getPreProcessingType() == preProcessing->getPreProcessingType() ){
        
        Derivative *ptr = (Derivative*)preProcessing;
        
        //Clone the Derivative values 
        this->derivativeOrder = ptr->derivativeOrder;
        this->filterSize = ptr->filterSize;
        this->delta = ptr->delta;
        this->filterData = ptr->filterData;
        this->filter = ptr->filter;
        this->yy = ptr->yy;
        this->yyy = ptr->yyy;
        
        //Clone the base class variables
        return copyBaseVariables( preProcessing );
    }
    
    errorLog << "clone(const PreProcessing *preProcessing) -  PreProcessing Types Do Not Match!" << endl;
    
    return false;
}
Ejemplo n.º 6
0
HighPassFilter::HighPassFilter(const HighPassFilter &rhs){
    this->filterFactor = rhs.filterFactor;
    this->gain = rhs.gain;
	this->xx = rhs.xx;
    this->yy = rhs.yy;
    copyBaseVariables( (PreProcessing*)&rhs );
}
Ejemplo n.º 7
0
bool DTW::deepCopyFrom(const Classifier *classifier){
    
    if( classifier == NULL ) return false;
    
    if( this->getClassifierType() == classifier->getClassifierType() ){
        
        DTW *ptr = (DTW*)classifier;
        this->templatesBuffer = ptr->templatesBuffer;
        this->distanceMatrices = ptr->distanceMatrices;
        this->warpPaths = ptr->warpPaths;
        this->rangesBuffer = ptr->rangesBuffer;
        this->continuousInputDataBuffer = ptr->continuousInputDataBuffer;
        this->numTemplates = ptr->numTemplates;
        this->rejectionMode = ptr->rejectionMode;
        this->useSmoothing = ptr->useSmoothing;
        this->useZNormalisation = ptr->useZNormalisation;
        this->constrainZNorm = ptr->constrainZNorm;
        this->constrainWarpingPath = ptr->constrainWarpingPath;
        this->trimTrainingData = ptr->trimTrainingData;
        this->zNormConstrainThreshold = ptr->zNormConstrainThreshold;
        this->radius = ptr->radius;
        this->offsetUsingFirstSample = ptr->offsetUsingFirstSample;
        this->trimThreshold = ptr->trimThreshold;
        this->maximumTrimPercentage = ptr->maximumTrimPercentage;
        this->smoothingFactor = ptr->smoothingFactor;
        this->distanceMethod = ptr->distanceMethod;
        this->rejectionMode = ptr->rejectionMode;
        this->averageTemplateLength = ptr->averageTemplateLength;
        
	    //Copy the classifier variables
		return copyBaseVariables( classifier );
    }
    return false;
}
Ejemplo n.º 8
0
KMeans::KMeans(const KMeans &rhs){
    
    classType = "KMeans";
    clustererType = classType;
    debugLog.setProceedingText("[DEBUG KMeans]");
    errorLog.setProceedingText("[ERROR KMeans]");
    trainingLog.setProceedingText("[TRAINING KMeans]");
    warningLog.setProceedingText("[WARNING KMeans]");
    
    if( this != &rhs ){
        
        this->numTrainingSamples = rhs.numTrainingSamples;
        this->nchg = rhs.nchg;
        this->computeTheta = rhs.computeTheta;
        this->finalTheta = rhs.finalTheta;
        this->clusters = rhs.clusters;
        this->assign = rhs.assign;
        this->count = rhs.count;
        this->thetaTracker = rhs.thetaTracker;
        
        //Clone the Clusterer variables
        copyBaseVariables( (Clusterer*)&rhs );
    }
    
}
Ejemplo n.º 9
0
bool SavitzkyGolayFilter::deepCopyFrom(const PreProcessing *preProcessing){
    
    if( preProcessing == NULL ) return false;
    
    if( this->getPreProcessingType() == preProcessing->getPreProcessingType() ){
        
        SavitzkyGolayFilter *ptr = (SavitzkyGolayFilter*)preProcessing;
        
        //Clone the SavitzkyGolayFilter values 
        this->numPoints = ptr->numPoints;
        this->numLeftHandPoints = ptr->numLeftHandPoints;
        this->numRightHandPoints = ptr->numRightHandPoints;
        this->derivativeOrder = ptr->derivativeOrder;
        this->smoothingPolynomialOrder = ptr->smoothingPolynomialOrder;
        this->data = ptr->data;
        this->yy = ptr->yy;
        this->coeff = ptr->coeff;
        
        //Clone the base class variables
        return copyBaseVariables( preProcessing );
    }
    
    errorLog << "clone(PreProcessing *preProcessing) -  PreProcessing Types Do Not Match!" << std::endl;
    
    return false;
}
Ejemplo n.º 10
0
DTW& DTW::operator=(const DTW &rhs){
	
	if( this != &rhs ){
		
		this->templatesBuffer = rhs.templatesBuffer;
        this->distanceMatrices = rhs.distanceMatrices;
        this->warpPaths = rhs.warpPaths;
        this->rangesBuffer = rhs.rangesBuffer;
        this->continuousInputDataBuffer = rhs.continuousInputDataBuffer;
        this->numTemplates = rhs.numTemplates;
        this->rejectionMode = rhs.rejectionMode;
        this->useSmoothing = rhs.useSmoothing;
        this->useZNormalisation = rhs.useZNormalisation;
        this->constrainZNorm = rhs.constrainZNorm;
        this->constrainWarpingPath = rhs.constrainWarpingPath;
        this->trimTrainingData = rhs.trimTrainingData;
        this->zNormConstrainThreshold = rhs.zNormConstrainThreshold;
        this->radius = rhs.radius;
        this->offsetUsingFirstSample = rhs.offsetUsingFirstSample;
        this->trimThreshold = rhs.trimThreshold;
        this->maximumTrimPercentage = rhs.maximumTrimPercentage;
        this->smoothingFactor = rhs.smoothingFactor;
        this->distanceMethod = rhs.distanceMethod;
        this->rejectionMode = rhs.rejectionMode;
        this->averageTemplateLength = rhs.averageTemplateLength;

	    //Copy the classifier variables
		copyBaseVariables( (Classifier*)&rhs );
	}
	return *this;
}
Ejemplo n.º 11
0
RandomForests& RandomForests::operator=(const RandomForests &rhs){
    if( this != &rhs ){
        //Clear this tree
        clear();
        
        //Copy the base classifier variables
        if( copyBaseVariables( (Classifier*)&rhs ) ){
            
            //Deep copy the main node
            if( this->decisionTreeNode != NULL ){
                delete decisionTreeNode;
                decisionTreeNode = NULL;
            }
            this->decisionTreeNode = rhs.deepCopyDecisionTreeNode();
            
            if( rhs.getTrained() ){
                //Deep copy the forest
                for(UINT i=0; i<rhs.forest.size(); i++){
                    this->forest.push_back( rhs.forest[i]->deepCopy() );
                }
            }
            
            this->forestSize = rhs.forestSize;
            this->numRandomSplits = rhs.numRandomSplits;
            this->minNumSamplesPerNode = rhs.minNumSamplesPerNode;
            this->maxDepth = rhs.maxDepth;
            this->removeFeaturesAtEachSpilt = rhs.removeFeaturesAtEachSpilt;
            this->bootstrappedDatasetWeight = rhs.bootstrappedDatasetWeight;
            this->trainingMode = rhs.trainingMode;
            
        }else errorLog << "deepCopyFrom(const Classifier *classifier) - Failed to copy base variables!" << endl;
	}
	return *this;
}
Ejemplo n.º 12
0
bool Node::deepCopyFrom(const Node *node) {
    //cout<<"node deep copy attempt"<<endl;

    if( node == NULL ){
        return false;
    }
    
    copyBaseVariables(node);
    for(int i=0;i<node->m_Children.size();i++){    //Recursively deep copy the left child
        
        Node* c = node->m_Children[i]->createNewInstance();
        if(c ==NULL){
            //cout<<"child not copied"<<endl;
            return false;
  
        }
        //Validate that the classifier was cloned correctly
        if( !c->deepCopyFrom( node->m_Children[i] ) ){
            delete c;
            c=NULL;
            //cout<<"child not copied because of deep copy"<<endl;
            return false;
        }
        this->m_Children.push_back(c);
        c->m_Parent = this;
        //cout<<"child copy success at "<<i<<endl;

        //this->leftChild->parent = node;
    }
    return true;
}
Ejemplo n.º 13
0
bool RegressionTree::deepCopyFrom(const Regressifier *regressifier){
    
    if( regressifier == NULL ) return false;
    
    if( this->getRegressifierType() == regressifier->getRegressifierType() ){
        
        RegressionTree *ptr = (RegressionTree*)regressifier;
        
        //Clear this tree
        this->clear();
        
        if( ptr->getTrained() ){
            //Deep copy the tree
            this->tree = dynamic_cast< RegressionTreeNode* >( ptr->deepCopyTree() );
        }
        
        this->numSplittingSteps = ptr->numSplittingSteps;
        this->minNumSamplesPerNode = ptr->minNumSamplesPerNode;
        this->maxDepth = ptr->maxDepth;
        this->removeFeaturesAtEachSpilt = ptr->removeFeaturesAtEachSpilt;
        this->trainingMode = ptr->trainingMode;
        this->minRMSErrorPerNode = ptr->minRMSErrorPerNode;
        
        //Copy the base variables
        return copyBaseVariables( regressifier );
    }
    return false;
}
Ejemplo n.º 14
0
bool RandomForests::deepCopyFrom(const Classifier *classifier){
    
    if( classifier == NULL ) return false;
    
    if( this->getClassifierType() == classifier->getClassifierType() ){
        
        RandomForests *ptr = (RandomForests*)classifier;
        
        //Clear this tree
        this->clear();
        
        if( ptr->getTrained() ){
            //Deep copy the forest
            for(UINT i=0; i<ptr->forest.size(); i++){
                this->forest.push_back( ptr->forest[i]->deepCopyTree() );
            }
        }
        
        this->forestSize = ptr->forestSize;
        this->numRandomSplits = ptr->numRandomSplits;
        this->minNumSamplesPerNode = ptr->minNumSamplesPerNode;
        this->maxDepth = ptr->maxDepth;
        
        //Copy the base classifier variables
        return copyBaseVariables( classifier );
    }
    return false;
}
Ejemplo n.º 15
0
bool SwipeDetector::deepCopyFrom(const Classifier *classifier) {

    if( classifier == NULL ) return false;

    if( this->getClassifierType() == classifier->getClassifierType() ) {

        SwipeDetector *ptr = (SwipeDetector*)classifier;

        this->firstSample = ptr->firstSample;
        this->swipeDetected = ptr->swipeDetected;
        this->contextInput = ptr->contextInput;
        this->swipeIndex = ptr->swipeIndex;
        this->swipeDirection = ptr->swipeDirection;
        this->contextFilterSize = ptr->contextFilterSize;
        this->swipeIntegrationCoeff = ptr->swipeIntegrationCoeff;
        this->movementIntegrationCoeff = ptr->movementIntegrationCoeff;
        this->swipeThreshold = ptr->swipeThreshold;
        this->hysteresisThreshold = ptr->hysteresisThreshold;
        this->swipeVelocity = ptr->swipeVelocity;
        this->movementVelocity = ptr->movementVelocity;
        this->movementThreshold = ptr->movementThreshold;
        this->contextFilteredValue = ptr->contextFilteredValue;
        this->lastX = ptr->lastX;
        this->thresholdDetector = ptr->thresholdDetector;
        this->contextFilter = ptr->contextFilter;

        //Classifier variables
        return copyBaseVariables( classifier );
    }

    return false;
}
Ejemplo n.º 16
0
SwipeDetector& SwipeDetector::operator=(const SwipeDetector &rhs) {
    if( this != &rhs ) {
        //SwipeDetector variables
        this->firstSample = rhs.firstSample;
        this->swipeDetected = rhs.swipeDetected;
        this->contextInput = rhs.contextInput;
        this->swipeIndex = rhs.swipeIndex;
        this->swipeDirection = rhs.swipeDirection;
        this->contextFilterSize = rhs.contextFilterSize;
        this->swipeIntegrationCoeff = rhs.swipeIntegrationCoeff;
        this->movementIntegrationCoeff = rhs.movementIntegrationCoeff;
        this->swipeThreshold = rhs.swipeThreshold;
        this->hysteresisThreshold = rhs.hysteresisThreshold;
        this->swipeVelocity = rhs.swipeVelocity;
        this->movementVelocity = rhs.movementVelocity;
        this->movementThreshold = rhs.movementThreshold;
        this->contextFilteredValue = rhs.contextFilteredValue;
        this->lastX = rhs.lastX;
        this->thresholdDetector = rhs.thresholdDetector;
        this->contextFilter = rhs.contextFilter;

        //Classifier variables
        copyBaseVariables( (Classifier*)&rhs );
    }
    return *this;
}
Ejemplo n.º 17
0
LeakyIntegrator& LeakyIntegrator::operator=(const LeakyIntegrator &rhs){
    if( this != &rhs ){
        this->leakRate = rhs.leakRate;
        this->y = rhs.y;
        copyBaseVariables( (PreProcessing*)&rhs );
    }
    return *this;
}
Ejemplo n.º 18
0
DeadZone& DeadZone::operator=(const DeadZone &rhs){
	if(this!=&rhs){
        this->lowerLimit = rhs.lowerLimit;
        this->upperLimit = rhs.upperLimit;
        copyBaseVariables( (PreProcessing*)&rhs );
	}
	return *this;
}
Ejemplo n.º 19
0
LowPassFilter& LowPassFilter::operator=(const LowPassFilter &rhs){
	if(this!=&rhs){
        this->filterFactor = rhs.filterFactor;
        this->gain = rhs.gain;
		this->yy = rhs.yy;
        copyBaseVariables( (PreProcessing*)&rhs );
	}
	return *this;
}
TimeseriesBuffer& TimeseriesBuffer::operator=(const TimeseriesBuffer &rhs){
    if(this!=&rhs){
        this->bufferSize = rhs.bufferSize;
        this->dataBuffer = rhs.dataBuffer;
        
        copyBaseVariables( (FeatureExtraction*)&rhs );
    }
    return *this;
}
LogisticRegression& LogisticRegression::operator=(const LogisticRegression &rhs){
	if( this != &rhs ){
        this->w0 = rhs.w0;
        this->w = rhs.w;
        
        //Copy the base variables
        copyBaseVariables( (Regressifier*)&rhs );
	}
	return *this;
}
Ejemplo n.º 22
0
Softmax& Softmax::operator=(const Softmax &rhs){
    if( this != &rhs ){
        this->batchSize = rhs.batchSize;
        this->models = rhs.models;
        
        //Copy the base classifier variables
        copyBaseVariables( (Classifier*)&rhs );
    }
    return *this;
}
Ejemplo n.º 23
0
Derivative::Derivative(const Derivative &rhs){
    this->derivativeOrder = rhs.derivativeOrder;
    this->filterSize = rhs.filterSize;
    this->delta = rhs.delta;
    this->filterData = rhs.filterData;
    this->filter = rhs.filter;
    this->yy = rhs.yy;
    this->yyy = rhs.yyy;
    copyBaseVariables( (PreProcessing*)&rhs );
}
Ejemplo n.º 24
0
KMeansFeatures& KMeansFeatures::operator=(const KMeansFeatures &rhs){
    if(this!=&rhs){
        //Here you should copy any class variables from the rhs instance to this instance
        this->numClustersPerLayer = rhs.numClustersPerLayer;
        
        //Copy the base variables
        copyBaseVariables( (FeatureExtraction*)&rhs );
    }
    return *this;
}
Ejemplo n.º 25
0
MovementIndex& MovementIndex::operator=(const MovementIndex &rhs) {
    if(this!=&rhs) {
        this->bufferLength = rhs.bufferLength;
        this->dataBuffer = rhs.dataBuffer;

        //Copy the base variables
        copyBaseVariables( (FeatureExtraction*)&rhs );
    }
    return *this;
}
Ejemplo n.º 26
0
DoubleMovingAverageFilter& DoubleMovingAverageFilter::operator=(const DoubleMovingAverageFilter &rhs){
    if(this!=&rhs){
        this->filterSize = rhs.filterSize;
        this->filter1 = rhs.filter1;
        this->filter2 = rhs.filter2;
        
        //Copy the base variables
        copyBaseVariables( (PreProcessing*)&rhs );
    }
    return *this;
}
Ejemplo n.º 27
0
MinDist& MinDist::operator=(const MinDist &rhs){
    if( this != &rhs ){
        //MinDist variables
        this->numClusters = rhs.numClusters;
        this->models = rhs.models;
        
        //Classifier variables
        copyBaseVariables( (Classifier*)&rhs );
    }
    return *this;
}
Ejemplo n.º 28
0
KMeansQuantizer& KMeansQuantizer::operator=(const KMeansQuantizer &rhs){
    if(this!=&rhs){
        //Copy any class variables from the rhs instance to this instance
        this->numClusters = rhs.numClusters;
        this->clusters = rhs.clusters;
        
        //Copy the base variables
        copyBaseVariables( (FeatureExtraction*)&rhs );
    }
    return *this;
}
Ejemplo n.º 29
0
Gate& Gate::operator=(const Gate &rhs)
{
    if( this != &rhs )
    {
        this->gateOpen = rhs.gateOpen;

        //Clone the context base variables
        copyBaseVariables( dynamic_cast<const Context*>( &rhs ) );
    }
    return *this;
}
Ejemplo n.º 30
0
RBMQuantizer& RBMQuantizer::operator=(const RBMQuantizer &rhs){
    if(this!=&rhs){
        this->numClusters = rhs.numClusters;
        this->rbm = rhs.rbm;
        this->quantizationDistances = rhs.quantizationDistances;
        
        //Copy the base variables
        copyBaseVariables( (FeatureExtraction*)&rhs );
    }
    return *this;
}