コード例 #1
0
	def export(self, _training, _model, _out, _discretize=False):
		FileHandler().createFolder("tmp")
		tmpId = "_" + str(uuid.uuid1())
		tmpFolder = "tmp/"
		tmpTraining = "train" + tmpId + ".arff"

		csv = CSV(_training)
		csv.convertToARFF(tmpFolder + tmpTraining, False)		
		d = None
		if _discretize:
			d = csv.discretizeData()

		attributes = csv.findAttributes(0)


		weka = WEKA()
		weka.folder = tmpFolder
		weka.train(_model, tmpFolder + tmpTraining, tmpId)
		data = "\n".join(FileHandler().read(tmpFolder + "raw" + tmpId + ".txt"))

		FileHandler().checkFolder(_out)
		weka.modelInterface.exportCode(data, csv, attributes, _out, _training, discretization=d)

		FileHandler().deleteFiles([tmpFolder + tmpTraining, tmpFolder + "raw" + tmpId + ".txt"])
コード例 #2
0
ファイル: ModelRecommender.py プロジェクト: falkenber9/LIMITS
	def run(self, _training, _models, _platforms):
		R = ResultMatrix()
		M = [];
		for model in _models:
			# run the cross validation to compute the model performance
			M.append(model.toString())
			e = Experiment(_training)
			header, result = e.regression([model], 10)
			R.add(header, result)

			# train with the global training data and export code
			training_arff = "tmp/recommend.arff"

			csv = CSV()
			csv.load(_training)
			csv.convertToARFF(training_arff, False)
			attributes = csv.findAttributes(0)
			lAtt = len(attributes)-1
			WEKA().train(model, training_arff, "0")
			
			data = "\n".join(FileHandler().read("tmp/raw0.txt"))
			codeFile = "recommend.c"

			model.exportCode(data, csv, attributes, codeFile)

			# complile platform-specific code
			for platform in _platforms:
				""





				#print(model.toString() + " : " + platform.toString())
		print(R.header, R.data)
		print(M)