Added normalization feature for matrices and fixed issue where ValueArraySlice could not be converted property to a ValueArray #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm currently working on an implementation of Lasso Regression for a machine learning framework I'm working on and I stumbled upon an issue where UpSurge didn't have the ability to normalize my feature vectors. So I added the ability to normalize an entire matrix. I had stumbled upon an issue recently where whenever I tried to convert a ValueArraySlice to a ValueArray, the ValueArray class automatically adopts it's own step field rather than utilizing the original step field of the ValueArraySlice.
Here is an example:
Now if I were to do the following I would get [3,5] instead of a ValueArray that has the elements 3,4 like the slice originally had:
let vectorSlice = ValueArray(inputMatrix .column(i)) // [3,5]
This is becuase within the ValueArray class the step size provided within the class, which is set to 1, is always adopted by this method:
Line 37 of ValueArray class:
Problematic area (Line 88):
Above you see that in this line here, we are only using the step provided by the class. Instead we need the step provided by the ValueArraySlice (which in my example originally had a step of 3):
Original:
mutablePointer[i] = pointer[values.startIndex + i * step]
To fix this I use the 'values' parameters step field.
mutablePointer[i] = pointer[values.startIndex + i * values.step]
The normalize functions I implemented work as expected and have been tested.