nyxtom/salient · linear_regression_spec.js
javascript logo
function () {
        var regression = new LinearRegression();
        regression.addExample([1,2,3], 4);
        regression.addExample([4,5,6], 4);
        var normalizedMatrix = regression.normalize();
        expect(normalizedMatrix.eql($M([[1,-1,-1,-1],[1,1,1,1]]))).toBeTruthy();
    }
Similar code snippets
1.
nyxtom/salient · linear_regression_spec.js
Match rating: 78.03% · See similar code snippets
javascript logo
function () {

    it('should be able to add examples and normalize them', function () {
        var regression = new LinearRegression();
        regression.addExample([1,2,3], 4);
        regression.addExample([4,5,6], 4);
        var normalizedMatrix = regression.normalize();
        expect(normalizedMatrix.eql($M([[1,-1,-1,-1],[1,1,1,1]]))).toBeTruthy();
    });

    it('should be able to load training, normalize and normalize input', function () {
        var regression = new LinearRegression();
        regression.load('./spec/regression/ex1data2.txt');
        regression.normalize();
        var result = regression.train();
        var normalInput = regression.normalizeInput([1650,3]);
        expect(regression.calculate(result.theta, normalInput).e(1)).toEqual(293081.46436300856);
    });

    it('should be able to perform regularization', function () {
        var regression = new LinearRegression({ lambda: 1, regularization: true });
        regression.load('./spec/regression/ex1data2.txt');
        regression.normalize();
        var result = regression.train();
        var normalInput = regression.normalizeInput([1650,3]);
        expect(regression.calculate(result.theta, normalInput).e(1)).toEqual(294135.15996768116);
    });

}
2.
Match rating: 47.57% · See similar code snippets
javascript logo
function () {

    var LinearRegressionSummary = require(EclairJS_Globals.NAMESPACE + '/ml/regression/LinearRegressionSummary');
    var Logger = require(EclairJS_Globals.NAMESPACE + '/Logger');
    var Utils = require(EclairJS_Globals.NAMESPACE + '/Utils');


    /**
     * @classdesc
     * Linear regression training results. Currently, the training summary ignores the
     * training coefficients except for the objective trace.
     * @class
     * @memberof module:eclairjs/ml/regression
     * @extends module:eclairjs/ml/regression.LinearRegressionSummary
     */


    var LinearRegressionTrainingSummary = function (jvmObject) {

        this.logger = Logger.getLogger("ml_regression_LinearRegressionTrainingSummary_js");
        LinearRegressionSummary.call(this, jvmObject);

    };

    LinearRegressionTrainingSummary.prototype = Object.create(LinearRegressionSummary.prototype);

    LinearRegressionTrainingSummary.prototype.constructor = LinearRegressionTrainingSummary;

    /**
     *
     * @returns {string}
     */
    LinearRegressionTrainingSummary.prototype.featuresCol = function () {
        return this.getJavaObject().featuresCol();
    };

    /**
     *
     * @returns {float[]}
     */
    LinearRegressionTrainingSummary.prototype.objectiveHistory = function () {
        return Utils.javaToJs(this.getJavaObject().objectiveHistory());
    };

    /**
     *
     * @returns {integer}
     */
    LinearRegressionTrainingSummary.prototype.totalIterations = function () {
        return this.getJavaObject().totalIterations();
    };

    module.exports = LinearRegressionTrainingSummary;
}
3.
fex-team/yog-devtools · rewrite.js
Match rating: 46.65% · See similar code snippets
javascript logo
function Ruler(type, reg, to) {
        return {
            type: type,
            reg: reg,
            to: to
        }
    }
4.
EclairJS/eclairjs · LinearRegressionWithSGD.js
Match rating: 44.1% · See similar code snippets
javascript logo
function(rdd, numIterations, miniBatchFraction, initialWeights) {
      var args = {
        target: LinearRegressionWithSGD,
        method: 'train',
        args: Utils.wrapArguments(arguments),
        static: true,
        kernelP: gKernelP,
        returnType: LinearRegressionModel
      };

      return Utils.generate(args);
    }
5.
gedbac/di4js · di.spec.js
Match rating: 42.76% · See similar code snippets
javascript logo
function () {
    var engine = new DieselEngine();
    di
      .register('car')
        .as(Car)
        .withConstructor()
          .param().val(engine)
          .param().val(1976);
    var instance = di.resolve('car');
    expect(instance).not.toBeNull();
    expect(instance.engine).toBe(engine);
    expect(instance.year).toBe(1976);
  }
6.
angular/jasminewd · maybePromiseSpec.js
Match rating: 41.65% · See similar code snippets
javascript logo
function() {
      expect(maybePromise(num, idFun)).toBe(num);
      expect(maybePromise(str, idFun)).toBe(str);
      expect(maybePromise(obj, idFun)).toBe(obj);
    }
7.
centro/transis · array_spec.js
Match rating: 41.12% · See similar code snippets
javascript logo
function() {
      var a1 = [{name: 'foo'}, {name: 'bar'}];
      var a2 = TransisArray.from(a1, x => x.name);

      expect(a2 instanceof TransisArray).toBe(true);
      expect(a2.length).toBe(2);
      expect(a2.at(0)).toBe('foo');
      expect(a2.at(1)).toBe('bar');
    }
8.
akashic-games/akashic-engine · PathUtilSpec.js
Match rating: 40.87% · See similar code snippets
javascript logo
function() {
		expect(g.PathUtil.addExtname("file", "ext")).toBe("file.ext");
		expect(g.PathUtil.addExtname("http://example/file?query", "ext")).toBe("http://example/file.ext?query");
		expect(g.PathUtil.addExtname("http://example/?query", "ext")).toBe("http://example/.ext?query");
	}
9.
alanrsoares/prelude-js · sortBy.js
Match rating: 40.7% · See similar code snippets
javascript logo
function (x, y) {
    return fn(x) > fn(y) ? 1 : fn(x) < fn(y) ? -1 : 0;
  }
10.
apache/cordova-windows · Version.spec.js
Match rating: 40.62% · See similar code snippets
javascript logo
function () {
        var version = Version.fromString('1.2.4.7');
        expect(version.major).toBe(1);
        expect(version.minor).toBe(2);
        expect(version.build).toBe(4);
        expect(version.qfe).toBe(7);
    }