Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Linear Regression - Cannot read property 'e' of nul #2

Closed
FMGordillo opened this issue Dec 16, 2018 · 1 comment
Closed

Multiple Linear Regression - Cannot read property 'e' of nul #2

FMGordillo opened this issue Dec 16, 2018 · 1 comment

Comments

@FMGordillo
Copy link

FMGordillo commented Dec 16, 2018

First of all, thank you for this awesome lib!

Dataset (without null values)

,TV,radio,newspaper,sales
1,230.1,37.8,69.2,22.1
2,44.5,39.3,45.1,10.4
3,17.2,45.9,69.3,9.3
4,151.5,41.3,58.5,18.5
5,180.8,10.8,58.4,12.9
6,8.7,48.9,75,7.2
7,57.5,32.8,23.5,11.8

Then gathering X and Y to analyze later:

function dressData(csvData) {
	let X = [],
		Y = []
	csvData.forEach(row => {
		let k = []
		k.push(f(row['TV']))
		k.push(f(row['radio']))
		k.push(f(row['newspaper']))
		X.push(k)
		Y.push(f(row['sales']))
	})

	return [X, Y]
}

When I train the model, everything seems OK:

const ml = require('shaman')

function performRegression(X, Y) {
	const lr = new ml.LinearRegression(X, Y, {
		debug: true,
		algorithm: 'NormalEquation'
	})
	lr.train(err => {
		if (err) console.log(err)
		else predictOutput(lr)
	})
}

The prediction works when I use Linear Regression, but with Multiple Linear Regression it fails with the error in the title: Cannot read property 'e' of null.

Stack trace: at LinearRegression.predict (C:\Users\facun\xxxxx\node_modules\shaman\lib\linear_regression.js:263:17)

@FMGordillo
Copy link
Author

Sorry, theory error. I was giving to predict only one parameter, when I had to give 3 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant