hossam.hs_classroom¶
hossam.hs_classroom ¶
cluster_students ¶
cluster_students(
df,
n_groups,
score_cols=None,
interest_col=None,
interest_ignore=None,
max_iter=200,
score_metric="total",
)
학생들을 균형잡힌 조로 편성하는 함수.
관심사 기반 1차 군집과 점수/인원 균형 조정을 통해 동질성 있고 균형잡힌 조를 구성합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame | str
|
학생 정보를 담은 데이터프레임 또는 엑셀/CSV 파일 경로. 데이터프레임의 경우: 반드시 '학생번호' 컬럼 포함. 파일 경로의 경우: 자동으로 hs_load_data 함수를 사용하여 로드. interest_col이 지정된 경우 해당 컬럼 필수. score_cols이 지정된 경우 해당 컬럼들 필수. |
required |
n_groups
|
int
|
목표 조의 개수. |
required |
score_cols
|
list | None
|
성적 계산에 사용할 점수 컬럼명 리스트. 예: ['과목1점수', '과목2점수', '과목3점수'] None일 경우 점수 기반 균형 조정을 하지 않습니다. 기본값: None |
None
|
interest_col
|
str | None
|
관심사 정보가 있는 컬럼명. None일 경우 관심사 기반 군집화를 하지 않습니다. 기본값: None |
None
|
interest_ignore
|
str | None
|
관심사 군집화에서 제외할 값. 지정된 값은 별도 군집에서 제외됩니다. 기본값: None |
None
|
max_iter
|
int
|
균형 조정 최대 반복 횟수. 기본값: 200 |
200
|
score_metric
|
str
|
점수 기준 선택 ('total' 또는 'average'). 'total'이면 총점, 'average'이면 평균점수 기준. 기본값: 'total' |
'total'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
'조' 컬럼이 추가된 데이터프레임. 관심사와 점수로 균형잡힌 조 배치 완료. |
Raises:
| Type | Description |
|---|---|
ValueError
|
필수 컬럼이 없거나 입력값이 유효하지 않은 경우. |
Examples:
df = read_csv('students.csv')
from hossam import *
result = hs_classroom.cluster_students(
df=df,
n_groups=5,
score_cols=['국어', '영어', '수학'],
interest_col='관심사')
Source code in hossam/hs_classroom.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
report_summary ¶
report_summary(
df,
interest_col=None,
width=config.width,
height=config.height,
)
조 편성 결과의 요약 통계를 시각화합니다.
조별 인원 분포, 관심사 분포, 평균점수 분포를 나타냅니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
cluster_students 함수의 반환 결과 데이터프레임. |
required |
interest_col
|
str | None
|
관심사 컬럼명 |
None
|
width
|
int
|
그래프 넓이. 기본값: config.width |
width
|
height
|
int
|
그래프 높이. 기본값: config.height |
height
|
Examples:
from hossam import *
df_result = hs_classroom.cluster_students(df, n_groups=5, score_cols=['국어', '영어', '수학'])
hs_classroom.report_summary(df_result)
Source code in hossam/hs_classroom.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
report_kde ¶
report_kde(
df,
metric="average",
width=config.width,
height=config.height,
)
조별 점수 분포를 KDE(Kernel Density Estimation)로 시각화합니다.
각 조의 점수 분포를 커널 밀도 추정으로 표시하고 평균 및 95% 신뢰구간을 나타냅니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame | str
|
cluster_students 함수의 반환 결과 데이터프레임. |
required |
metric
|
str
|
점수 기준 선택 ('total' 또는 'average'). 'total'이면 총점, 'average'이면 평균점수. 기본값: 'average' |
'average'
|
width
|
int
|
그래프 넓이. 기본값: config.width |
width
|
height
|
int
|
그래프 높이. 기본값: config.height |
height
|
Examples:
from hossam import *
df_result = hs_classroom.cluster_students(df, n_groups=5, score_cols=['국어', '영어', '수학'])
hs_classroom.report_kde(df_result, metric='average')
Source code in hossam/hs_classroom.py
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
group_summary ¶
group_summary(df, name_col='학생이름')
조별로 학생 목록과 평균 점수를 요약합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
cluster_students 함수의 반환 결과 데이터프레임. '조' 컬럼이 필수로 포함되어야 함. |
required |
name_col
|
str
|
학생 이름이 들어있는 컬럼명. 기본값: '학생이름' |
'학생이름'
|
Returns:
| Name | Type | Description |
|---|---|---|
DataFrame
|
조별 요약 정보가 담긴 데이터프레임. |
|
컬럼 |
DataFrame
|
'조', '학생', '총점평균', '평균점수평균' |
Examples:
from hossam import *
df_result = hs_classroom.cluster_students(df, n_groups=5, score_cols=['국어', '영어', '수학'])
summary = hs_classroom.group_summary(df_result, name_col='이름')
print(summary)
Source code in hossam/hs_classroom.py
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 | |
analyze_classroom ¶
analyze_classroom(
df,
n_groups,
score_cols=None,
interest_col=None,
interest_ignore=None,
max_iter=200,
score_metric="average",
name_col="학생이름",
show_summary=True,
show_kde=True,
)
학생 조 편성부터 시각화까지 전체 프로세스를 일괄 실행합니다.
다음 순서로 실행됩니다: 1. cluster_students: 학생들을 균형잡힌 조로 편성 2. group_summary: 조별 학생 목록과 평균 점수 요약 3. report_summary: 조 편성 결과 요약 시각화 (선택적) 4. report_kde: 조별 점수 분포 KDE 시각화 (선택적)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame | str
|
학생 정보를 담은 데이터프레임 또는 파일 경로. |
required |
n_groups
|
int
|
목표 조의 개수. |
required |
score_cols
|
list | None
|
성적 계산에 사용할 점수 컬럼명 리스트. 기본값: None |
None
|
interest_col
|
str | None
|
관심사 정보가 있는 컬럼명. 기본값: None |
None
|
interest_ignore
|
str | None
|
관심사 군집화에서 제외할 값. 기본값: None |
None
|
max_iter
|
int
|
균형 조정 최대 반복 횟수. 기본값: 200 |
200
|
score_metric
|
str
|
점수 기준 선택 ('total' 또는 'average'). 기본값: 'average' |
'average'
|
name_col
|
str
|
학생 이름 컬럼명. 기본값: '학생이름' |
'학생이름'
|
show_summary
|
bool
|
요약 시각화 표시 여부. 기본값: True |
True
|
show_kde
|
bool
|
KDE 시각화 표시 여부. 기본값: True |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
조별 요약 정보 (group_summary의 결과). |
Examples:
from hossam import *
summary = hs_classroom.analyze_classroom(df='students.csv',
n_groups=5,
score_cols=['국어', '영어', '수학'],
interest_col='관심사',
name_col='이름')
print(summary)
Source code in hossam/hs_classroom.py
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 | |