Skip to content

Commit b20ac3f

Browse files
committed
sample house prediction
1 parent 6c99f48 commit b20ac3f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ function init(matrix) {
5151

5252
console.log('theta: ', theta);
5353
console.log('\n');
54+
55+
// Part 3: Predict Price of 1650 square meter and 3 bedroom house
56+
console.log('Part 3: Price Prediction ...\n');
57+
58+
let normalizedHouseVector = [1, ((1650 - mu[0]) / sigma[0]), ((3 - mu[1]) / sigma[1])];
59+
let price = math.eval('normalizedHouseVector * theta', {
60+
normalizedHouseVector,
61+
theta,
62+
});
63+
64+
console.log('Predicted price for a 1650 square meter and 3 bedroom house: ', price);
5465
}
5566

5667
function featureNormalize(X) {

0 commit comments

Comments
 (0)