Beispiel #1
0
 def __init__(self, numOfPop, numOfFea):
     self.filedata = FromDataFileMLR.DataFromFile()
     self.fitnessdata = FromFinessFileMLR.FitnessResults()
     self.NofIterations = 2000
     self.alpha = 0.5
     self.GlobalBestRow = ndarray(numOfFea)
     self.GlobalBestFitness = 10000
     self.VelocityM = ndarray((numOfPop, numOfFea))
     self.LocalBestM = ndarray((numOfPop, numOfFea))
     self.LocalBestM_Fit = ndarray(numOfPop)
Beispiel #2
0
 def __init__(self, numOfPop, numOfFea):
     # Acquires and formats data from Train, Validation, Test .csv files
     self.filedata = FromDataFileMLR.DataFromFile()
     # Performs data analysis on training, validation, and test data
     self.analyzer = FromFinessFileMLR.FitnessResults()
     self.NumIterations = 1000
     self.alpha = 0.5  # starting alpha value
     self.GlobalBestRow = ndarray(
         numOfFea)  # best-fitting population yet found
     self.GlobalBestFitness = 10000  # fitness of GlobalBestRow, initialized very high
     self.VelocityM = ndarray((numOfPop, numOfFea))  # Velocity matrix
     self.LocalBestM = ndarray((numOfPop, numOfFea))  # local best matrix
     self.LocalBestM_Fit = ndarray(numOfPop)  # local best matrix fitnesses
Beispiel #3
0
def main():
    # Number of descriptor should be 385 and number of population should be 50 or more
    numOfPop = 50
    numOfFea = 385

    # create an object of Multiple Linear Regression model.
    # The class is located in mlr file
    model = mlr.MLR()
    filedata = FromDataFileMLR.DataFromFile()
    fitnessdata = FromFinessFileMLR.FitnessResults()
    analyzer = Fitness(numOfPop, numOfFea)

    # create an output file. Name the object to be FileW
    fileW = analyzer.createAnOutputFile()

    # we continue exhancing the model; however if after 1000 iteration no
    # enhancement is done, we can quit
    unfit = 1000

    # Final model requirements: The following is used to evaluate each model. The minimum
    # values for R^2 of training should be 0.6, R^2 of Validation should be 0.5 and R^2 of
    # test should be 0.5
    R2req_train = .6
    R2req_validate = .5
    R2req_test = .5

    # getAllOfTheData is in FromDataFileMLR file. The following places the data
    # (training data, validation data, and test data) into associated matrices
    TrainX, TrainY, ValidateX, ValidateY, TestX, TestY = filedata.getAllOfTheData(
    )
    TrainX, ValidateX, TestX = filedata.rescaleTheData(TrainX, ValidateX,
                                                       TestX)

    fittingStatus = unfit
    population = analyzer.createInitialPopulation(numOfPop, numOfFea)
    fittingStatus, fitness = fitnessdata.validate_model(model,fileW, population, \
        TrainX, TrainY, ValidateX, ValidateY, TestX, TestY)

    analyzer.CreateInitialVelocity(numOfPop, numOfFea)
    copyto(analyzer.LocalBestM,
           population)  #initializing LocalBestMatrix as the initial population
    copyto(analyzer.LocalBestM_Fit, fitness)
    analyzer.FindGlobalBestRow()

    analyzer.PerformOneMillionIteration(numOfPop, numOfFea, population, fitness, model, fileW, \
                               TrainX, TrainY, ValidateX, ValidateY, TestX, TestY)
Beispiel #4
0
 def __init__(self):
     self.filedata = FromDataFileMLR.DataFromFile()
     self.fitnessdata = FromFinessFileMLR.FitnessResults()
Beispiel #5
0
 def __init__(self):
     self.fitnessdata = FromFinessFileMLR.FitnessResults()