[ENH] Feature constructor optimization#5975
Merged
VesnaT merged 3 commits intobiolab:masterfrom May 23, 2022
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5975 +/- ##
==========================================
+ Coverage 86.40% 86.43% +0.02%
==========================================
Files 315 315
Lines 67155 67218 +63
==========================================
+ Hits 58025 58097 +72
+ Misses 9130 9121 -9 |
Contributor
Author
|
Benchmarked using import statistics
import timeit
import numpy as np
from Orange.data import ContinuousVariable, Domain, Table
from Orange.widgets.data.owfeatureconstructor import ContinuousDescriptor, \
construct_variables
N = 100_000
table = new_domain = None
def setup():
global table, new_domain
var_names = ['Var' + str(i) for i in range(100)]
variables = [ContinuousVariable(name=var_name) for var_name in var_names]
domain = Domain(variables)
test_data = np.random.rand(N, len(variables))
table = Table.from_numpy(domain, test_data)
expr = 'Var0 + Var1'
desc = ContinuousDescriptor(expr, expr, number_of_decimals=None)
constr_vars = construct_variables([desc], table)
new_domain = Domain(table.domain.attributes + tuple(constr_vars))
def run():
table.transform(new_domain)
res = timeit.repeat(
"run()", setup="setup()", globals=globals(), repeat=10, number=1
)
print(f"Avg: {statistics.mean(res):.4f}, Min: {min(res):.4f}, Std: {statistics.stdev(res):.4f}")Before: Avg: 0.9430, Min: 0.9309, Std: 0.0086 |
Member
|
Wow, 20x speedup! |
2 tasks
9424cfe to
d133f43
Compare
d133f43 to
ad56f9f
Compare
df02626 to
92b2864
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue
Ref: #5911
Parallel (or alternative) to #5949
Description of changes
Avoid iteration over table rows, checks in inner loops, construction of
Valueinstances.Includes