SVM.prototype._restore = function (model) { var self = this; this._baseSvm = BaseSVM.restore(model); _o.forOwn(model.params, function(val, key){ self._config[key] = val; }); };
.spread(function (model, report) { var template; switch (config.svmType){ case svmTypes.C_SVC: case svmTypes.NU_SVC: case svmTypes.ONE_CLASS: template = 'classification-report'; break; case svmTypes.EPSILON_SVR: case svmTypes.NU_SVR: template = 'regression-report'; break; } logger.info('template', 'report', { template: template, json: report }); var bestConf = _o.mixIn({}, config, model.params); // reformat conf a bit _o.forOwn(bestConf, function(value, key){ if (key === 'svmType'){ bestConf.svmType = svmTypesString[value]; } else if (key === 'kernelType'){ bestConf.kernelType = kernelTypesString[value]; } else { var cKey = _s.camelCase('render-' + key.replace(/_/g, '-')); bestConf[cKey] = req(key, config); } }); logger.info('template', 'configuration', { template: 'configuration', json: bestConf }); return [model, report]; })
function askConfirmation(logger, config){ var cleanConfig = _o.merge({}, config); // Cleanup empty props (null values, empty strings, objects and arrays) _o.forOwn(cleanConfig, function (value, key) { if (key === 'svmType'){ cleanConfig.svmType = svmTypesString[value]; } else if (key === 'kernelType'){ cleanConfig.kernelType = kernelTypesString[value]; } else if (key === 'cwd' || key === 'argv' || key === 'interactive' || key === 'color'){ delete cleanConfig[key]; } else if (value === null || _l.isEmpty(value) && !_l.isNumber(value) && !_l.isBoolean(value)) { delete cleanConfig[key]; } }); if (!cleanConfig.reduce){ delete cleanConfig.retainedVariance; } logger.info('json', 'Configuration', { json: cleanConfig }); // Confirm the json with the user return Q.nfcall(logger.prompt.bind(logger), { name: 'confirmation', type: 'confirm', message: 'Looks good?', default: true }).then(function(answer){ if (_l.isBoolean(answer)){ return answer; } return _s.typecast(answer); }); }