Example #1
0
	def generate_d3_JSON_ParallelCoords(self, hndl_Res):
		# Historical Line Graph
		# Historical Line Graph / Get History Line
		(history_dates, history_values) = hndl_Res.get_resp_word_raw_values()
		json_history = [DATA_SERIES_TO_JSON(d,v) for (d,v) in zip(history_dates, history_values)]
		# Historical Line Graph / Write History Line
		filePath = get_json_history_path(hndl_Res.file_name)
		save_to_JSON(filePath, json_history)
		# Parallel Coordinates
		# Parallel Coordinates / Get Parallel Coords Points
		models = {}
		preds = []
		for dt in hndl_Res.get_prediction_dates():
			(model_idxs, pred_values) = hndl_Res.get_values_by_row(dt)
			models.update(dict.fromkeys(model_idxs))
			for (md, vl) in zip(model_idxs, pred_values):
				preds.append({
					JSON_MODEL_ID: md,
					JSON_DATE_KEY: dt_epoch_to_str_Y_M_D(dt),
					JSON_VALUE_KEY: vl
				})
		# Parallel Coordinates / Write Parallel Coords Points
		filePath = get_json_predictions_path(hndl_Res.file_name)
		save_to_JSON(filePath, preds)
		# Metadata
		# Metadata / Get Model Metadata
		for md in models.keys():
			models[md] = hndl_Res.get_model_metadata(md)
		# Metadata / Write Model Metadata
		filePath = get_json_model_path(hndl_Res.file_name)
		save_to_JSON(filePath, models)
		
Example #2
0
# EMF 		From...Import
from	util_TimeSet	import dt_epoch_to_str_Y_M_D
from 	lib_EMF 		import HomeDirectory

JSONRepository = HomeDirectory + 'json/'
JSONSuffix = '.json'

JSON_MODEL_METADATA_SUFFIX  = 'metadata'
JSON_MODEL_PREDICTIONS_SUFFIX  = 'predictions'
JSON_MODEL_HISTORY_SUFFIX  = 'history'


JSON_DATE_KEY = 'dt'
JSON_VALUE_KEY = 'vl'

JSON_MODEL_ID = 'm_id'
JSON_MODEL_CONFIDENCE = 'm_cn'
JSON_MODEL_DESC = 'm_dsc'
JSON_MODEL_CATS = 'm_cat'

# LAMBDAS
DATA_SERIES_TO_JSON = lambda d, v: {JSON_DATE_KEY: dt_epoch_to_str_Y_M_D(d), JSON_VALUE_KEY: float(v)}
# WORD_SERIES_TO_JSON = lambda (dt, data_vl, word_vl): {'dt': dt_epoch_to_str_Y_M_D(dt), 'raw_val': float(data_vl), 'proc_val': float(word_vl)}