Ejemplo n.º 1
0
def trainModel(unitsInHiddenLayer = -1, debug = True):
	if debug:
		print("Reading Training Data RBF Model (Currency Exchange problem)")
	# Reading Training data
	trainData = utl.readDataSetAsMatrix(\
		utl.CURRENCY_EXCHANGE_TRAINING_FILE(\
			utl.SAMPLING_TYPE.HOURLY
		)
	)

	width = utl.HOURLY_WIDTH
	inputs = utl.createPattern(trainData[:-1, 2:], width)
	outputs = trainData[(width+1):, 2:].astype(np.float64)
	
	if debug:
		print("Training Model RBF Model (Currency Exchange problem)")
		
	configuration = utl.RBFTrainProcessConfiguration()
	configuration.outputLayer = LinearLayer
	if unitsInHiddenLayer <= 0:
		configuration.performClustering = False
	else:
		configuration.unitsInHiddenLayer = unitsInHiddenLayer
		configuration.performClustering = True

	configuration.maxEpochs = 1000
	configuration.learningrate = 0.001

	return utl.trainRBFNetwork(\
		inputs,
		outputs,
		configuration
	)
Ejemplo n.º 2
0
def trainModel(unitsInHiddenLayer=8, debug=True):

    if debug:
        print("Reading Training Data MLP Model (Currency Exchange problem)")
    # Reading Training data
    trainData = utl.readDataSetAsMatrix(\
     utl.CURRENCY_EXCHANGE_TRAINING_FILE(\
      utl.SAMPLING_TYPE.HOURLY
     )
    )

    width = utl.HOURLY_WIDTH
    inputs = utl.createPattern(trainData[:-1, 2:], width)
    outputs = trainData[(width + 1):, 2:]

    if debug:
        print("Training Model MLP Model (Currency Exchange problem)")

    configuration = utl.MLPTrainProcessConfiguration()
    configuration.unitsInHiddenLayer = unitsInHiddenLayer
    configuration.outputLayer = LinearLayer
    configuration.maxEpochs = 1000
    configuration.learningrate = 0.001

    return utl.trainMLPNetwork(\
     inputs,
     outputs,
     configuration
    )
Ejemplo n.º 3
0
def getTestData():
    testingData = utl.readDataSetAsMatrix(\
     utl.CURRENCY_EXCHANGE_TESTING_FILE(\
      utl.SAMPLING_TYPE.HOURLY
     )
    )

    width = utl.HOURLY_WIDTH
    inputs = utl.createPattern(testingData[:-1, 2:], width)
    outputs = testingData[(width + 1):, 2:]

    return inputs, outputs
Ejemplo n.º 4
0
def evaluate(model, debug = True, inputs = None, outputs = None):
	
	if inputs is None or outputs is None:
		# Reading testing data
		testingData = utl.readDataSetAsMatrix(\
			utl.CURRENCY_EXCHANGE_TESTING_FILE(\
				utl.SAMPLING_TYPE.HOURLY
			)
		)

		width = utl.HOURLY_WIDTH
		inputs = utl.createPattern(testingData[:-1, 2:], width)
		outputs = testingData[(width+1):, 2:]
	
	return utl.evaluateRegressionModel(\
		model,
		inputs,
		outputs,
		"MLP : Currency exchange problem 'hourly'",
		debug
	)