def quantize(self): city = self.inputVars['縣市'][:3] region = self.inputVars['鄉鎮市區'] reg = Regression() self.quantizedVars['縣市'] = city self.quantizedVars['鄉鎮市區'] = region self.quantizedVars['variables'] = numpy.array(reg.quantizeForRec(self.inputVars, city)) return self
def outputRegressions(parameters, path="regression_output"): os.makedirs(path, exist_ok=True) outputReport(path) outputDict(path, parameters) def outputReport(path): pass def outputDict(path, parameters): f = open(path+"/.regressions", "wb") pickle.dump(parameters, f) f.close() if __name__ == '__main__': data = parseData() if len(sys.argv) == 1 else parseData(sys.argv[1]) ac = AddressClassifier() ac.classify(data) rawData = ac.getClassifiedData() print ("regression_generator start") reg = Regression() reg.quantize(rawData) parameters = reg.getTotalParams() outputRegressions(parameters) print ("regression_generator finish")