
/*******************************************
****        JavaScript example          ****
**** (c) 2017-2019, Alessandro Pedretti ****
*******************************************/

/*
 * This example requires Node.js as JavaScript interpreter
 * https://nodejs.org/
 */


const financial_service = require('./financial_service.js');

const Model = new financial_service();


/**** Prediction example 1 ****/

Model.LifeStyle = Model.C_LIFESTYLE_SPENDGGSAVING;
Model.Type      = Model.C_TYPE_STUDENT;
Model.Vacation  = 6.0;
Model.eCredit   = 40.0;
Model.property  = 3.2804;
Model.salary    = 13.62;

console.log("\n* Example #1");
console.log("  Domain violations: %d (must be 0)", Model.DomCheck());
console.log("  Predicted class:   %d (real 0)", Model.Classify());


/**** Prediction example 2 ****/

Model.LifeStyle = Model.C_LIFESTYLE_SPENDGSAVING;
Model.Type      = Model.C_TYPE_LIBRARIAN;
Model.Vacation  = 7.0;
Model.eCredit   = 10.0;
Model.property  = 1.2225;
Model.salary    = 18.1751;

console.log("\n* Example #2");
console.log("  Domain violations: %d (must be 0)", Model.DomCheck());
console.log("  Predicted class:   %d (real 1)", Model.Classify());


/**** Prediction example 3 ****/

Model.LifeStyle = Model.C_LIFESTYLE_SPENDLSAVING;
Model.Type      = Model.C_TYPE_STUDENT;
Model.Vacation  = 6.0;
Model.eCredit   = 73.0;
Model.property  = 4.8256;
Model.salary    = 31.75;

console.log("\n* Example #3");
console.log("  Domain violations: %d (must be 0)", Model.DomCheck());
console.log("  Predicted class:   %d (real 2)", Model.Classify());


/**** Prediction example 4 ****/

Model.LifeStyle = Model.C_LIFESTYLE_SPENDLSAVING;
Model.Type      = Model.C_TYPE_DOCTOR;
Model.Vacation  = 47.0;
Model.eCredit   = 51.0;
Model.property  = 5.6494;
Model.salary    = 18.45;

console.log("\n* Example #4");
console.log("  Domain violations: %d (must be 0)", Model.DomCheck());
console.log("  Predicted class:   %d (real 3)", Model.Classify());


/**** Prediction example 5 ****/

Model.LifeStyle = Model.C_LIFESTYLE_SPENDGSAVING;
Model.Type      = Model.C_TYPE_PROFESSOR;
Model.Vacation  = 48.0;
Model.eCredit   = 5.0;
Model.property  = 1.7536;
Model.salary    = 20.39;

console.log("\n* Example #5");
console.log("  Domain violations: %d (must be 0)", Model.DomCheck());
console.log("  Predicted class:   %d (real 4)", Model.Classify());
