Skip to content

Commit

Permalink
Update feature_engineering.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dlrgy22 authored Jun 8, 2021
1 parent 6c2fe04 commit f4f940e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions feature_engineering.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
tqdm.pandas()


def userID_elapsed_cate(df, max_time=600):
df.sort_values(by=["userID", "Timestamp"], inplace=True)

# sample별 elapsed time
diff = df.loc[:, ['userID', 'Timestamp']].groupby('userID').diff().shift(-1)
elapsed = diff['Timestamp'].apply(lambda x: int(x.total_seconds() // 10 * 10) if max_time > x.total_seconds() else 1)
df['userID_elapsed_cate'] = elapsed

return df

def userID_testid_experience(df):
# userID별 시간 순으로 정렬
df = df.sort_values(by=['userID', 'Timestamp']).reset_index(drop=True)
Expand Down

0 comments on commit f4f940e

Please sign in to comment.