コード例 #1
0
ファイル: fanns.py プロジェクト: curme/stock-NeuralNetworks
        def __init__(self):

            print "Info: ", "Create empty function agent"

            self.dataManager = DataManager()
            self.machines    = MachinesManager()
コード例 #2
0
ファイル: fanns.py プロジェクト: curme/stock-NeuralNetworks
    class FunctionAgent:

        def __init__(self):

            print "Info: ", "Create empty function agent"

            self.dataManager = DataManager()
            self.machines    = MachinesManager()

        def setAgent(self):

            print "Info: ", "Set function agent from configure file"

            # read config file
            config = None
            with file('./FANNS/system.config', 'r') as f: config = json.load(f)
            accounts = config['accounts']
            filepath = config['filepath']
            stash    = config['stash'   ]

            # set data manager
            data_manager_path = filepath['root'] + filepath['data']
            mysql_host = "localhost"
            mysql_localhost_root= accounts['databases']["mysql_localhost_root"]
            self.dataManager.setManager(data_manager_path, mysql_host,
                                        mysql_localhost_root["username"],
                                        mysql_localhost_root["password"])

            # set machine Manager
            self.machines.setManager(self.dataManager, stash['machines'])

        def saveConfig(self):

            print "Info: ", "Save function agent configure file"

            with file('./FANNS/system.config', 'r') as f: config = json.load(f)

            # save machines config
            atol = lambda array: list([list(item) for item in array])
            dtos = lambda date : date.strftime('%Y-%m-%d')
            # save HSIDailyTrendNN config
            config["stash"]["machines"]["HSIDailyTrendNN"]["status"] = \
                self.machines.HSIDailyTrendNNSubManager.status
            config["stash"]["machines"]["HSIDailyTrendNN"]["labels"] = \
                self.machines.HSIDailyTrendNNSubManager.labels
            config["stash"]["machines"]["HSIDailyTrendNN"]["Xtrain"] = \
                atol(self.machines.HSIDailyTrendNNSubManager.Xtrain)
            config["stash"]["machines"]["HSIDailyTrendNN"]["ytrain"] = \
                atol(self.machines.HSIDailyTrendNNSubManager.ytrain)
            config["stash"]["machines"]["HSIDailyTrendNN"]["Xval"]   = \
                atol(self.machines.HSIDailyTrendNNSubManager.Xval)
            config["stash"]["machines"]["HSIDailyTrendNN"]["yval"]   = \
                atol(self.machines.HSIDailyTrendNNSubManager.yval)
            config["stash"]["machines"]["HSIDailyTrendNN"]["Xtest"]  = \
                atol(self.machines.HSIDailyTrendNNSubManager.Xtest)
            config["stash"]["machines"]["HSIDailyTrendNN"]["ytest"]  = \
                atol(self.machines.HSIDailyTrendNNSubManager.ytest)
            config["stash"]["machines"]["HSIDailyTrendNN"]["model"]  = \
                self.machines.HSIDailyTrendNNSubManager.model
            config["stash"]["machines"]["HSIDailyTrendNN"]["modelSDate"]  = \
                dtos(self.machines.HSIDailyTrendNNSubManager.modelSDate)
            config["stash"]["machines"]["HSIDailyTrendNN"]["modelEDate"]  = \
                dtos(self.machines.HSIDailyTrendNNSubManager.modelEDate)

            json.dump(config, file('./FANNS/system.config', 'w+'))