시험지별로 특성을 추출해보자! #46
MignonDeveloper
started this conversation in
Tip
Replies: 3 comments 7 replies
-
for test_id, assesment_id in zip(train_df["testId"], train_df["assessmentItemID"]):
test_prob_count[test_id].add(assesment_id[-3:])1번만 실험해봤는데 27초였던 코드가 1초로 줄었어😊 필요한column만 가지고오면 시간을 줄일 수 있는 것 같아! |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
개멋있습니다.. |
Beta Was this translation helpful? Give feedback.
0 replies
-
row_number = df.shape[0]
new_feature = pd.Series(data=[0] * row_number, name="nth_test")
.
.
.
for i, (cur_user_id, cur_test_id) in tqdm(enumerate(zip(df["userID"], df["testId"]))):
.
.
.
new_feature[i] = how_many_times[cur_test_id]여기서 i를 쓰지않고, list로 만들어 append한 뒤에 dataFrame으로 변환해서 붙이면 어때?? row_number, i 등 변수를 사용하지 않고..! 너무 직관적이지 않아서 별로일까? ➕ if-else문에서 똑같이 new_feaure에 how_many_times[cur_test_id]를 넣어주는데 이 부분을 맨 뒤로 빼면 되지 않을까? |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
사용자를 기준으로, 시험지별로 특성을 추출해볼게요~!
1. 먼저 각 test_id 별로 어떤 문항들이 있는지 {"test_id": set()} 형태의 dict로 뽑아줍니다.
2. 각 test_id별로 가지고 있는 집합(set)의 원소 갯수를 파악하면, 해당 시험지가 가지고 있는 문항의 개수가 됩니다.
3. 이를 활용해서 해당 시험지가 사용자 기준으로 몇번째 나온 것인지 나타내는 categorical feature를 생성합니다.
4. 추가한 feature를 기존 df에 concat 해줍니다.
저는 근데 한바퀴 도는데 python file에서 대략 6분정도 걸려요,, tqdm으로 찍어보니까 ㅜㅜ 시간을 줄일 수 있는 방법을 코드에서 찾아주시면 너무 감사하겠습니다. 6분이면,,, 끄응아라누나의 도움으로
30초대4초!!로 끊었습니다@@ 대-박우선row_number를 작게 만들어서(10,000 정도) 어떤 구조인지 보셔도 좋을 것 같아요이해 안되거나, 궁금한게 있으시면 언제든지 질문주세요!!
Beta Was this translation helpful? Give feedback.
All reactions