Skip to content

Commit

Permalink
multiple-regression(): first arg is now a list of N-tuples (each N-tuple
Browse files Browse the repository at this point in the history
representing one input (setting of indep vars to values). The returned
predictor fn also takes an N-tuple brownplt#1732
  • Loading branch information
ds26gte committed May 17, 2024
1 parent bcdfd0e commit 7cf32b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/js/trove/multiple-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
let Y = new Array(num_mappings);
let x_s_len = false;
js_x_s_s.forEach(function(x_s, i) {
runtime.checkList(x_s);
let js_x_s = runtime.ffi.toArray(x_s);
runtime.checkTuple(x_s);
let js_x_s = x_s.vals;
let x_s_n = js_x_s.length;
if (x_s_len === false) {
x_s_len = x_s_n;
Expand All @@ -156,8 +156,8 @@
let XT = matrixTranspose(X);
let B = matrixMultiply2(matrixInverse(matrixMultiply2(XT, X)), matrixMultiply2(XT, Y));
let Bfunc = function(x_s) {
runtime.checkList(x_s);
let js_x_s = runtime.ffi.toArray(x_s);
runtime.checkTuple(x_s);
let js_x_s = x_s.vals;
if (js_x_s.length !== x_s_len) {
throw runtime.ffi.throwMessageException("predictor: wrong number of arguments");
}
Expand Down
4 changes: 2 additions & 2 deletions tests/pyret/tests/test-statistics.arr
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ check "linear regression":
end

check "multiple regression":
x-s-s = [list: [list: 4], [list: 4.5], [list: 5], [list: 5.5], [list: 6], [list: 6.5], [list: 7]]
x-s-s = [list: {4}, {4.5}, {5}, {5.5}, {6}, {6.5}, {7}]
y-s = [list: 33, 42, 45, 51, 53, 61, 62]
pf = multiple-regression(x-s-s, y-s)
pf([list: 8]) is%(within-abs(0.001)) 73.3214
pf({8}) is%(within-abs(0.001)) 73.3214
end


Expand Down

0 comments on commit 7cf32b9

Please sign in to comment.