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

Perf matrix #6

Merged
merged 11 commits into from
Aug 1, 2017
Merged

Perf matrix #6

merged 11 commits into from
Aug 1, 2017

Conversation

JeffersonH44
Copy link
Member

src/index.js Outdated
export default {
RandomForestClassifier,
RandomForestRegression
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous export was correct

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some problems using rollup because it only exports the first one, this one works for me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the default. We don't want to export an object. Just two separate things

@JeffersonH44
Copy link
Member Author

it's ok now @targos?

Copy link
Member

@maasencioh maasencioh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said in one comment below, I prefer the use of setters and getters for matrices, because they work with views and have the same performance.

for (i = 0; i < predictionValues.length; ++i) {
predictions[i] = this.selection(predictionValues[i]);
predictionValues = new Matrix(predictionValues).transposeView();
var predictions = new Array(predictionValues.rows);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is what you need

src/utils.js Outdated
for (var i = 0; i < indexes.length; ++i) {
toRet.setColumn(i, X.getColumn(indexes[i]));
toRet[i] = X.getColumn(indexes[i]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the setters and getters, they work with views and the performance is the same

package.json Outdated
@@ -47,7 +49,7 @@
"dependencies": {
"ml-array-mean": "^1.0.0",
"ml-array-median": "^1.0.0",
"ml-cart": "1.0.1",
"ml-cart": "^1.0.7",
"ml-matrix": "^3.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be the version 5

@JeffersonH44
Copy link
Member Author

ok, I made those changes @maasencioh, it's ok for you?

var predictions = new Array(predictionValues.length);
for (i = 0; i < predictionValues.length; ++i) {
predictions[i] = this.selection(predictionValues[i]);
predictionValues = new Matrix(predictionValues).transposeView();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the use of a WrapperMatrix1D would be faster

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only "problem" is that this will force you to use the setters and getters

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that I cannot use that class because predictionValues is a 2D matrix, the other one is to use WrapMatrix2D but is the same as Matrix, I have to use tranposeView

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transposeView works on WrapMatrix2D (that was a typo indeed)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I made this change

predictionValues = new Matrix(predictionValues).transposeView();
var predictions = new Array(predictionValues.rows);
for (i = 0; i < predictionValues.rows; ++i) {
predictions[i] = this.selection(predictionValues.getRow(i));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is related with mljs/matrix#65, because is safer to use setters and getters ml-matrix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this one, lol.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

predictions[i] should be replaced by predictions.setRow but I think that currently is not possible

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but predictions is currently an array, do you think that I should use WrapMatrix1D or something, I think that's adding more complexity, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, I was confused, I'm sorry 😝

src/index.js Outdated
import {default as RandomForestClassifier} from './RandomForestClassifier';
import {default as RandomForestRegression} from './RandomForestRegression';

export {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should always avoid this, use this as inspiration of how to fix it
mljs/decision-tree-cart@4ceff09

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmmm ok, I think that I should avoid that default because that cause problems with rollup, thank you

@JeffersonH44
Copy link
Member Author

so, this is ready, right? @maasencioh @targos

@JeffersonH44 JeffersonH44 merged commit 699eaf3 into master Aug 1, 2017
@JeffersonH44 JeffersonH44 deleted the perf-matrix branch August 1, 2017 16:58
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

Successfully merging this pull request may close these issues.

3 participants