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

Implementing PartOfDay primitive #2128

Merged
merged 34 commits into from
Jun 29, 2022
Merged

Implementing PartOfDay primitive #2128

merged 34 commits into from
Jun 29, 2022

Conversation

sbadithe
Copy link
Contributor

fixes #2059

@@ -0,0 +1,6 @@
from featuretools.primitives import *
Copy link
Contributor

Choose a reason for hiding this comment

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

remove?

@codecov
Copy link

codecov bot commented Jun 21, 2022

Codecov Report

Merging #2128 (bb2d489) into main (cb7462f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #2128   +/-   ##
=======================================
  Coverage   99.21%   99.21%           
=======================================
  Files         143      143           
  Lines       16869    16907   +38     
=======================================
+ Hits        16737    16775   +38     
  Misses        132      132           
Impacted Files Coverage Δ
...imitives/standard/datetime_transform_primitives.py 100.00% <100.00%> (ø)
.../tests/primitive_tests/test_transform_primitive.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb7462f...bb2d489. Read the comment docs.


def get_function(self):
def part_of_day(vals):
return vals.apply(lambda x: self.get_part_of_day(x.hour))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we see if there is a faster way to implement this primitive? Can we vectorize it or look for a faster approach? Perhaps a pd.merge?

Copy link
Contributor

Choose a reason for hiding this comment

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

It also might be worth doing performance checking and using the fastest approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I will look into it right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm still trying to get it to work -- haven't been able to find a way that doesn't involve a map of some kind (because the output is not boolean). Does anyone have any tips? Right now it's about 4x slower than something like IsWeekend().

@sbadithe sbadithe marked this pull request as ready for review June 28, 2022 00:27

v1.10.0 June 23, 2022
=====================
* Enhancements
* Add ``DayOfYear``, ``DaysInMonth``, ``Quarter``, ``IsLeapYear``, ``IsQuarterEnd``, ``IsQuarterStart`` transform primitives (:pr:`2110`, :pr:`2117`)
* Add ``IsMonthEnd``, ``IsMonthStart`` transform primitives (:pr:`2121`)
* Add ``IsMonthEnd``, ``IsMonthStart`` transform primitives (:pr:`2121`, :pr:`2128`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't there be a new line with PartOfDay and this PR # ?

)
answer = [i if not pd.isna(i) else None for i in answer]
correct_answer = [i if not pd.isna(i) else None for i in correct_answer]
np.testing.assert_array_equal(answer, correct_answer)
Copy link
Contributor

@dvreed77 dvreed77 Jun 28, 2022

Choose a reason for hiding this comment

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

a nit, but convention is to compare expected and actual, not answer and correct_answer

@@ -515,6 +515,53 @@ def month(vals):
return month


class PartOfDay(TransformPrimitive):
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, just thought of this, but can you add boundaries of all different types in the doc string?

Copy link
Contributor

@dvreed77 dvreed77 left a comment

Choose a reason for hiding this comment

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

lgtm

@sbadithe sbadithe merged commit 09815ef into main Jun 29, 2022
@sbadithe sbadithe deleted the part-of-day branch June 29, 2022 22:32
@ozzieD ozzieD mentioned this pull request Jun 30, 2022
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.

Add PartOfDay primitive
3 participants