hossam 0.3.16__tar.gz → 0.3.17__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hossam-0.3.17/PKG-INFO +205 -0
- hossam-0.3.17/README.md +167 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam/__init__.py +9 -5
- {hossam-0.3.16 → hossam-0.3.17}/hossam/hs_prep.py +3 -3
- {hossam-0.3.16 → hossam-0.3.17}/hossam/hs_stats.py +149 -13
- hossam-0.3.17/hossam/mcp/__init__.py +12 -0
- hossam-0.3.17/hossam/mcp/hs_classroom.py +22 -0
- hossam-0.3.17/hossam/mcp/hs_gis.py +30 -0
- hossam-0.3.17/hossam/mcp/hs_plot.py +53 -0
- hossam-0.3.17/hossam/mcp/hs_prep.py +61 -0
- hossam-0.3.17/hossam/mcp/hs_stats.py +25 -0
- hossam-0.3.17/hossam/mcp/hs_timeserise.py +22 -0
- hossam-0.3.17/hossam/mcp/hs_util.py +30 -0
- hossam-0.3.17/hossam/mcp/loader.py +29 -0
- hossam-0.3.17/hossam/mcp/server.py +675 -0
- hossam-0.3.17/hossam.egg-info/PKG-INFO +205 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam.egg-info/SOURCES.txt +12 -1
- hossam-0.3.17/hossam.egg-info/entry_points.txt +2 -0
- {hossam-0.3.16 → hossam-0.3.17}/pyproject.toml +4 -1
- hossam-0.3.16/PKG-INFO +0 -636
- hossam-0.3.16/README.md +0 -598
- hossam-0.3.16/hossam.egg-info/PKG-INFO +0 -636
- {hossam-0.3.16 → hossam-0.3.17}/LICENSE +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/MANIFEST.in +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam/NotoSansKR-Regular.ttf +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam/data_loader.py +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam/hs_classroom.py +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam/hs_gis.py +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam/hs_plot.py +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam/hs_timeserise.py +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam/hs_util.py +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam/leekh.png +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam.egg-info/dependency_links.txt +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam.egg-info/requires.txt +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/hossam.egg-info/top_level.txt +0 -0
- {hossam-0.3.16 → hossam-0.3.17}/setup.cfg +0 -0
hossam-0.3.17/PKG-INFO
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hossam
|
|
3
|
+
Version: 0.3.17
|
|
4
|
+
Summary: Hossam Data Helper
|
|
5
|
+
Author-email: Lee Kwang-Ho <leekh4232@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/leekh4232/hossam-py
|
|
8
|
+
Project-URL: Repository, https://github.com/leekh4232/hossam-py
|
|
9
|
+
Keywords: data,analysis,helper,hossam,tensorflow
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: tqdm
|
|
19
|
+
Requires-Dist: tabulate
|
|
20
|
+
Requires-Dist: pandas
|
|
21
|
+
Requires-Dist: matplotlib
|
|
22
|
+
Requires-Dist: seaborn
|
|
23
|
+
Requires-Dist: requests
|
|
24
|
+
Requires-Dist: openpyxl
|
|
25
|
+
Requires-Dist: xlrd
|
|
26
|
+
Requires-Dist: statsmodels
|
|
27
|
+
Requires-Dist: scipy
|
|
28
|
+
Requires-Dist: scikit-learn
|
|
29
|
+
Requires-Dist: pingouin
|
|
30
|
+
Requires-Dist: statannotations
|
|
31
|
+
Requires-Dist: joblib
|
|
32
|
+
Requires-Dist: geopandas
|
|
33
|
+
Requires-Dist: kmodes
|
|
34
|
+
Requires-Dist: pmdarima
|
|
35
|
+
Requires-Dist: prophet
|
|
36
|
+
Requires-Dist: plotly
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
title: 🎓 Hossam Data Helper
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
# 🎓 Hossam Data Helper
|
|
44
|
+
|
|
45
|
+
[](https://www.python.org/downloads/)
|
|
46
|
+
[](https://opensource.org/licenses/MIT)
|
|
47
|
+
[](https://pypi.org/project/hossam/)
|
|
48
|
+
[](https://py.hossam.kr)
|
|
49
|
+
|
|
50
|
+
**Hossam**은 데이터 분석, 시각화, 통계 처리를 위한 종합 헬퍼 라이브러리입니다.
|
|
51
|
+
|
|
52
|
+
아이티윌(ITWILL)에서 진행 중인 머신러닝 및 데이터 분석 수업을 위해 개발되었으며, 이광호 강사의 강의에서 활용됩니다.
|
|
53
|
+
|
|
54
|
+
## ✨ 주요 특징
|
|
55
|
+
|
|
56
|
+
- 📊 **풍부한 시각화**: 25+ 시각화 함수 (Seaborn/Matplotlib 기반)
|
|
57
|
+
- 🎯 **통계 분석**: 회귀, 분류, 시계열 분석 도구
|
|
58
|
+
- 📦 **샘플 데이터**: 학습용 데이터셋 즉시 로드
|
|
59
|
+
- 🔧 **데이터 전처리**: 결측치 처리, 이상치 탐지, 스케일링
|
|
60
|
+
- 🤖 **MCP 서버**: VSCode/Copilot과 통합 가능한 Model Context Protocol 지원
|
|
61
|
+
- 📈 **교육용 최적화**: 데이터 분석 교육에 특화된 설계
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 📦 설치
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install hossam
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**요구사항**: Python 3.8 이상
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 🚀 빠른 시작
|
|
76
|
+
|
|
77
|
+
### 샘플 데이터 로드
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from hossam import load_data, load_info
|
|
81
|
+
|
|
82
|
+
# 사용 가능한 데이터셋 확인
|
|
83
|
+
datasets = load_info()
|
|
84
|
+
|
|
85
|
+
# 데이터 로드
|
|
86
|
+
df = load_data('AD_SALES')
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 간단한 시각화
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from hossam import hs_plot
|
|
93
|
+
import pandas as pd
|
|
94
|
+
import numpy as np
|
|
95
|
+
|
|
96
|
+
df = pd.DataFrame({
|
|
97
|
+
'x': np.random.randn(100),
|
|
98
|
+
'y': np.random.randn(100),
|
|
99
|
+
'category': np.random.choice(['A', 'B', 'C'], 100)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
# 산점도
|
|
103
|
+
hs_plot.scatterplot(df=df, xname='x', yname='y', hue='category')
|
|
104
|
+
|
|
105
|
+
# 박스플롯
|
|
106
|
+
hs_plot.boxplot(df=df, xname='category', yname='x')
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 🤖 MCP Server
|
|
112
|
+
|
|
113
|
+
Hossam은 **Model Context Protocol(MCP)** 기반 서버로도 작동하며, VSCode Copilot/Cline과 통합하여 데이터 분석 코드를 자동 생성할 수 있습니다.
|
|
114
|
+
|
|
115
|
+
### 빠른 시작
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# 서버 시작
|
|
119
|
+
hossam-mcp
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### VSCode + Copilot 연동
|
|
123
|
+
|
|
124
|
+
VSCode에서 Copilot과 함께 사용하려면 `.vscode/settings.json` 설정이 필요합니다.
|
|
125
|
+
|
|
126
|
+
**Copilot Chat에서 사용:**
|
|
127
|
+
```
|
|
128
|
+
@hossam 이 DataFrame의 결측치를 분석하고 처리하는 코드 작성해줘
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**설정 가이드:**
|
|
132
|
+
- [`.vscode/settings.json` 완성형 샘플](https://py.hossam.kr/guides/vscode-settings-sample/) ⭐
|
|
133
|
+
- [VSCode + Copilot 연동 상세](https://py.hossam.kr/guides/vscode-copilot-integration/)
|
|
134
|
+
- [MCP 서버 사용법](https://py.hossam.kr/guides/mcp/)
|
|
135
|
+
- [Copilot Chat 프롬프트 예시](https://py.hossam.kr/guides/copilot-prompts/)
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 📚 전체 문서
|
|
140
|
+
|
|
141
|
+
**완전한 API 문서와 가이드는 [py.hossam.kr](https://py.hossam.kr)에서 확인하세요.**
|
|
142
|
+
|
|
143
|
+
### 주요 모듈
|
|
144
|
+
|
|
145
|
+
- **hs_plot**: 25+ 시각화 함수 (선 그래프, 산점도, 히스토그램, 박스플롯, 히트맵 등)
|
|
146
|
+
- **hs_stats**: 회귀/분류 분석, 교차검증, 정규성 검정, 상관분석 등
|
|
147
|
+
- **hs_prep**: 결측치 처리, 이상치 탐지, 스케일링, 인코딩
|
|
148
|
+
- **hs_gis**: GIS 데이터 로드 및 시각화 (대한민국 지도 지원)
|
|
149
|
+
- **hs_classroom**: 학습용 이진분류, 다중분류, 회귀 데이터 생성
|
|
150
|
+
- **hs_util**: 예쁜 테이블 출력, 그리드 서치 등
|
|
151
|
+
|
|
152
|
+
자세한 사용법은 [API 문서](https://py.hossam.kr/api/hossam/)를 참고하세요.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 🎓 예제
|
|
157
|
+
|
|
158
|
+
### 결측치 분석
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from hossam import hs_prep
|
|
162
|
+
|
|
163
|
+
# 결측치 정보 확인
|
|
164
|
+
hs_prep.hs_missing_values(df)
|
|
165
|
+
|
|
166
|
+
# 결측치 시각화
|
|
167
|
+
hs_prep.hs_missing_values_barplot(df)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 회귀 분석
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from hossam import hs_stats
|
|
174
|
+
|
|
175
|
+
# 단순 선형 회귀
|
|
176
|
+
result = hs_stats.hs_simple_regression(df, xname='x', yname='y', plot=True)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 상관분석 히트맵
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from hossam import hs_plot
|
|
183
|
+
|
|
184
|
+
hs_plot.heatmap(df=df, annot=True, cmap='coolwarm')
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
더 많은 예제는 [문서 사이트](https://py.hossam.kr)를 참고하세요.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 📄 라이선스
|
|
192
|
+
|
|
193
|
+
이 프로젝트는 MIT 라이선스를 따릅니다. 자유롭게 사용, 수정, 배포할 수 있습니다.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 🔗 링크
|
|
198
|
+
|
|
199
|
+
- **문서**: [py.hossam.kr](https://py.hossam.kr)
|
|
200
|
+
- **PyPI**: [pypi.org/project/hossam](https://pypi.org/project/hossam/)
|
|
201
|
+
- **강사**: 이광호 (ITWILL 머신러닝 및 데이터 분석)
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
**Made with ❤️ for Data Science Education**
|
hossam-0.3.17/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 🎓 Hossam Data Helper
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 🎓 Hossam Data Helper
|
|
6
|
+
|
|
7
|
+
[](https://www.python.org/downloads/)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://pypi.org/project/hossam/)
|
|
10
|
+
[](https://py.hossam.kr)
|
|
11
|
+
|
|
12
|
+
**Hossam**은 데이터 분석, 시각화, 통계 처리를 위한 종합 헬퍼 라이브러리입니다.
|
|
13
|
+
|
|
14
|
+
아이티윌(ITWILL)에서 진행 중인 머신러닝 및 데이터 분석 수업을 위해 개발되었으며, 이광호 강사의 강의에서 활용됩니다.
|
|
15
|
+
|
|
16
|
+
## ✨ 주요 특징
|
|
17
|
+
|
|
18
|
+
- 📊 **풍부한 시각화**: 25+ 시각화 함수 (Seaborn/Matplotlib 기반)
|
|
19
|
+
- 🎯 **통계 분석**: 회귀, 분류, 시계열 분석 도구
|
|
20
|
+
- 📦 **샘플 데이터**: 학습용 데이터셋 즉시 로드
|
|
21
|
+
- 🔧 **데이터 전처리**: 결측치 처리, 이상치 탐지, 스케일링
|
|
22
|
+
- 🤖 **MCP 서버**: VSCode/Copilot과 통합 가능한 Model Context Protocol 지원
|
|
23
|
+
- 📈 **교육용 최적화**: 데이터 분석 교육에 특화된 설계
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 📦 설치
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install hossam
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**요구사항**: Python 3.8 이상
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🚀 빠른 시작
|
|
38
|
+
|
|
39
|
+
### 샘플 데이터 로드
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from hossam import load_data, load_info
|
|
43
|
+
|
|
44
|
+
# 사용 가능한 데이터셋 확인
|
|
45
|
+
datasets = load_info()
|
|
46
|
+
|
|
47
|
+
# 데이터 로드
|
|
48
|
+
df = load_data('AD_SALES')
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 간단한 시각화
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from hossam import hs_plot
|
|
55
|
+
import pandas as pd
|
|
56
|
+
import numpy as np
|
|
57
|
+
|
|
58
|
+
df = pd.DataFrame({
|
|
59
|
+
'x': np.random.randn(100),
|
|
60
|
+
'y': np.random.randn(100),
|
|
61
|
+
'category': np.random.choice(['A', 'B', 'C'], 100)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
# 산점도
|
|
65
|
+
hs_plot.scatterplot(df=df, xname='x', yname='y', hue='category')
|
|
66
|
+
|
|
67
|
+
# 박스플롯
|
|
68
|
+
hs_plot.boxplot(df=df, xname='category', yname='x')
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 🤖 MCP Server
|
|
74
|
+
|
|
75
|
+
Hossam은 **Model Context Protocol(MCP)** 기반 서버로도 작동하며, VSCode Copilot/Cline과 통합하여 데이터 분석 코드를 자동 생성할 수 있습니다.
|
|
76
|
+
|
|
77
|
+
### 빠른 시작
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# 서버 시작
|
|
81
|
+
hossam-mcp
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### VSCode + Copilot 연동
|
|
85
|
+
|
|
86
|
+
VSCode에서 Copilot과 함께 사용하려면 `.vscode/settings.json` 설정이 필요합니다.
|
|
87
|
+
|
|
88
|
+
**Copilot Chat에서 사용:**
|
|
89
|
+
```
|
|
90
|
+
@hossam 이 DataFrame의 결측치를 분석하고 처리하는 코드 작성해줘
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**설정 가이드:**
|
|
94
|
+
- [`.vscode/settings.json` 완성형 샘플](https://py.hossam.kr/guides/vscode-settings-sample/) ⭐
|
|
95
|
+
- [VSCode + Copilot 연동 상세](https://py.hossam.kr/guides/vscode-copilot-integration/)
|
|
96
|
+
- [MCP 서버 사용법](https://py.hossam.kr/guides/mcp/)
|
|
97
|
+
- [Copilot Chat 프롬프트 예시](https://py.hossam.kr/guides/copilot-prompts/)
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 📚 전체 문서
|
|
102
|
+
|
|
103
|
+
**완전한 API 문서와 가이드는 [py.hossam.kr](https://py.hossam.kr)에서 확인하세요.**
|
|
104
|
+
|
|
105
|
+
### 주요 모듈
|
|
106
|
+
|
|
107
|
+
- **hs_plot**: 25+ 시각화 함수 (선 그래프, 산점도, 히스토그램, 박스플롯, 히트맵 등)
|
|
108
|
+
- **hs_stats**: 회귀/분류 분석, 교차검증, 정규성 검정, 상관분석 등
|
|
109
|
+
- **hs_prep**: 결측치 처리, 이상치 탐지, 스케일링, 인코딩
|
|
110
|
+
- **hs_gis**: GIS 데이터 로드 및 시각화 (대한민국 지도 지원)
|
|
111
|
+
- **hs_classroom**: 학습용 이진분류, 다중분류, 회귀 데이터 생성
|
|
112
|
+
- **hs_util**: 예쁜 테이블 출력, 그리드 서치 등
|
|
113
|
+
|
|
114
|
+
자세한 사용법은 [API 문서](https://py.hossam.kr/api/hossam/)를 참고하세요.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 🎓 예제
|
|
119
|
+
|
|
120
|
+
### 결측치 분석
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from hossam import hs_prep
|
|
124
|
+
|
|
125
|
+
# 결측치 정보 확인
|
|
126
|
+
hs_prep.hs_missing_values(df)
|
|
127
|
+
|
|
128
|
+
# 결측치 시각화
|
|
129
|
+
hs_prep.hs_missing_values_barplot(df)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 회귀 분석
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from hossam import hs_stats
|
|
136
|
+
|
|
137
|
+
# 단순 선형 회귀
|
|
138
|
+
result = hs_stats.hs_simple_regression(df, xname='x', yname='y', plot=True)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 상관분석 히트맵
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from hossam import hs_plot
|
|
145
|
+
|
|
146
|
+
hs_plot.heatmap(df=df, annot=True, cmap='coolwarm')
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
더 많은 예제는 [문서 사이트](https://py.hossam.kr)를 참고하세요.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 📄 라이선스
|
|
154
|
+
|
|
155
|
+
이 프로젝트는 MIT 라이선스를 따릅니다. 자유롭게 사용, 수정, 배포할 수 있습니다.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 🔗 링크
|
|
160
|
+
|
|
161
|
+
- **문서**: [py.hossam.kr](https://py.hossam.kr)
|
|
162
|
+
- **PyPI**: [pypi.org/project/hossam](https://pypi.org/project/hossam/)
|
|
163
|
+
- **강사**: 이광호 (ITWILL 머신러닝 및 데이터 분석)
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
**Made with ❤️ for Data Science Education**
|
|
@@ -5,6 +5,7 @@ from matplotlib import font_manager as fm
|
|
|
5
5
|
from importlib.resources import files, as_file
|
|
6
6
|
from importlib.metadata import version
|
|
7
7
|
from types import SimpleNamespace
|
|
8
|
+
import sys
|
|
8
9
|
import warnings
|
|
9
10
|
|
|
10
11
|
try:
|
|
@@ -56,9 +57,10 @@ def _init_korean_font():
|
|
|
56
57
|
"pdf.fonttype": 42,
|
|
57
58
|
"ps.fonttype": 42,
|
|
58
59
|
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if sys.stdout.isatty():
|
|
61
|
+
print(
|
|
62
|
+
"\n✅ 시각화를 위한 한글 글꼴(NotoSansKR-Regular)이 자동 적용되었습니다."
|
|
63
|
+
)
|
|
62
64
|
return
|
|
63
65
|
except Exception as e:
|
|
64
66
|
warnings.warn(f"\n한글 폰트 초기화: 패키지 폰트 사용 실패 ({e}).")
|
|
@@ -76,8 +78,10 @@ def _init():
|
|
|
76
78
|
f"🔖 Version: {__version__}",
|
|
77
79
|
]
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
# MCP/stdio 환경에서는 배너를 출력하지 않음 (stdout TTY일 때만 출력)
|
|
82
|
+
if sys.stdout.isatty():
|
|
83
|
+
for msg in messages:
|
|
84
|
+
print(f"{msg}")
|
|
81
85
|
|
|
82
86
|
_init_korean_font()
|
|
83
87
|
|
|
@@ -440,11 +440,11 @@ def bin_continuous(
|
|
|
440
440
|
|
|
441
441
|
지원 방법:
|
|
442
442
|
- "natural_breaks"(기본): Jenks 자연 구간화. jenkspy 미사용 시 quantile로 대체
|
|
443
|
-
기본 라벨: "X
|
|
443
|
+
기본 라벨: "X-Y" 형식 (예: "18-30", "30-40")
|
|
444
444
|
- "quantile"/"qcut"/"equal_freq": 분위수 기반 동빈도
|
|
445
|
-
기본 라벨: "X
|
|
445
|
+
기본 라벨: "X-Y" 형식
|
|
446
446
|
- "equal_width"/"uniform": 동일 간격
|
|
447
|
-
기본 라벨: "X
|
|
447
|
+
기본 라벨: "X-Y" 형식
|
|
448
448
|
- "std": 평균±표준편차를 경계로 4구간 생성
|
|
449
449
|
라벨: "low", "mid_low", "mid_high", "high"
|
|
450
450
|
- "lifecourse"/"life_stage": 생애주기 5단계
|
|
@@ -6,7 +6,7 @@ import numpy as np
|
|
|
6
6
|
from typing import Tuple
|
|
7
7
|
from itertools import combinations
|
|
8
8
|
from pandas import DataFrame, Series, concat
|
|
9
|
-
from pandas.api.types import is_bool_dtype
|
|
9
|
+
from pandas.api.types import is_bool_dtype, is_numeric_dtype
|
|
10
10
|
|
|
11
11
|
from sklearn.metrics import (
|
|
12
12
|
confusion_matrix,
|
|
@@ -274,7 +274,7 @@ def category_table(data: DataFrame, *fields: str):
|
|
|
274
274
|
# ===================================================================
|
|
275
275
|
# 범주형 변수 요약 (Categorical Variable Summary)
|
|
276
276
|
# ===================================================================
|
|
277
|
-
def
|
|
277
|
+
def category_describe(data: DataFrame, *fields: str):
|
|
278
278
|
"""데이터프레임의 명목형(범주형) 변수에 대한 분포 편향을 요약한다.
|
|
279
279
|
|
|
280
280
|
각 명목형 컬럼의 최다 범주와 최소 범주의 정보를 요약하여 데이터프레임으로 반환한다.
|
|
@@ -296,19 +296,19 @@ def category_summary(data: DataFrame, *fields: str):
|
|
|
296
296
|
Examples:
|
|
297
297
|
전체 명목형 컬럼에 대한 분포 편향 요약:
|
|
298
298
|
|
|
299
|
-
>>> from hossam import
|
|
299
|
+
>>> from hossam import category_describe
|
|
300
300
|
>>> import pandas as pd
|
|
301
301
|
>>> df = pd.DataFrame({
|
|
302
302
|
... 'cut': ['Ideal', 'Premium', 'Good', 'Ideal', 'Premium'],
|
|
303
303
|
... 'color': ['E', 'F', 'G', 'E', 'F'],
|
|
304
304
|
... 'price': [100, 200, 150, 300, 120]
|
|
305
305
|
... })
|
|
306
|
-
>>> result =
|
|
306
|
+
>>> result = category_describe(df)
|
|
307
307
|
>>> print(result)
|
|
308
308
|
|
|
309
309
|
특정 컬럼만 분석:
|
|
310
310
|
|
|
311
|
-
>>> result =
|
|
311
|
+
>>> result = category_describe(df, 'cut', 'color')
|
|
312
312
|
>>> print(result)
|
|
313
313
|
|
|
314
314
|
Notes:
|
|
@@ -360,6 +360,16 @@ def category_summary(data: DataFrame, *fields: str):
|
|
|
360
360
|
|
|
361
361
|
return DataFrame(result)
|
|
362
362
|
|
|
363
|
+
# -------------------------------------------------------------------
|
|
364
|
+
# Backward-compatibility alias for categorical summary
|
|
365
|
+
# 기존 함수명(category_summary)을 계속 지원합니다.
|
|
366
|
+
def category_summary(data: DataFrame, *fields: str):
|
|
367
|
+
"""Deprecated alias for category_describe.
|
|
368
|
+
|
|
369
|
+
기존 코드 호환을 위해 유지됩니다. 내부적으로 category_describe를 호출합니다.
|
|
370
|
+
"""
|
|
371
|
+
return category_describe(data, *fields)
|
|
372
|
+
|
|
363
373
|
# ===================================================================
|
|
364
374
|
# 정규성 검정 (Normal Test)
|
|
365
375
|
# ===================================================================
|
|
@@ -443,7 +453,7 @@ def normal_test(data: DataFrame, columns: list | str | None = None, method: str
|
|
|
443
453
|
if method == "n":
|
|
444
454
|
method_name = "normaltest"
|
|
445
455
|
s, p = normaltest(col_data)
|
|
446
|
-
else:
|
|
456
|
+
else:
|
|
447
457
|
method_name = "shapiro"
|
|
448
458
|
s, p = shapiro(col_data)
|
|
449
459
|
|
|
@@ -1028,6 +1038,16 @@ def vif_filter(
|
|
|
1028
1038
|
|
|
1029
1039
|
return result
|
|
1030
1040
|
|
|
1041
|
+
# -------------------------------------------------------------------
|
|
1042
|
+
# Backward-compatibility alias for describe (typo support)
|
|
1043
|
+
# 오타(discribe)로 사용된 경우를 지원하여 혼란을 줄입니다.
|
|
1044
|
+
def discribe(data: DataFrame, *fields: str, columns: list = None):
|
|
1045
|
+
"""Deprecated alias for describe.
|
|
1046
|
+
|
|
1047
|
+
내부적으로 describe를 호출합니다.
|
|
1048
|
+
"""
|
|
1049
|
+
return describe(data, *fields, columns=columns)
|
|
1050
|
+
|
|
1031
1051
|
|
|
1032
1052
|
# ===================================================================
|
|
1033
1053
|
# x, y 데이터에 대한 추세선을 구한다.
|
|
@@ -1298,14 +1318,14 @@ def ols(df: DataFrame, yname: str, report=False):
|
|
|
1298
1318
|
... 'x2': np.random.normal(0, 1, 100)
|
|
1299
1319
|
... })
|
|
1300
1320
|
>>> # 적합 결과만 반환
|
|
1301
|
-
>>> fit =
|
|
1321
|
+
>>> fit = hs_ols(df, 'target')
|
|
1302
1322
|
>>> print(fit.summary())
|
|
1303
1323
|
|
|
1304
1324
|
>>> # 요약 리포트 반환
|
|
1305
|
-
>>> fit,
|
|
1325
|
+
>>> fit, result, features = hs_ols(df, 'target', report=1)
|
|
1306
1326
|
|
|
1307
1327
|
>>> # 풀 리포트 반환
|
|
1308
|
-
>>> fit, pdf, rdf, result_report, model_report, var_reports, eq =
|
|
1328
|
+
>>> fit, pdf, rdf, result_report, model_report, var_reports, eq = hs_ols(df, 'target', report=2)
|
|
1309
1329
|
"""
|
|
1310
1330
|
x = df.drop(yname, axis=1)
|
|
1311
1331
|
y = df[yname]
|
|
@@ -1320,8 +1340,8 @@ def ols(df: DataFrame, yname: str, report=False):
|
|
|
1320
1340
|
return linear_fit
|
|
1321
1341
|
elif report == 1 or report == 'summary':
|
|
1322
1342
|
# 요약 리포트 (full=False)
|
|
1323
|
-
|
|
1324
|
-
return linear_fit,
|
|
1343
|
+
pdf, rdf, result_report, model_report, variable_reports, equation_text = ols_report(linear_fit, df, full=True, alpha=0.05)
|
|
1344
|
+
return linear_fit, pdf, rdf
|
|
1325
1345
|
elif report == 2 or report == 'full' or report is True:
|
|
1326
1346
|
# 풀 리포트 (full=True)
|
|
1327
1347
|
pdf, rdf, result_report, model_report, variable_reports, equation_text = ols_report(linear_fit, df, full=True, alpha=0.05)
|
|
@@ -2094,7 +2114,7 @@ def corr_pairwise(
|
|
|
2094
2114
|
cols = data.select_dtypes(include=[np.number]).columns.tolist()
|
|
2095
2115
|
else:
|
|
2096
2116
|
# fields 리스트에서 데이터에 있는 것만 선택하되, 숫자형만 필터링
|
|
2097
|
-
cols = [c for c in fields if c in data.columns and
|
|
2117
|
+
cols = [c for c in fields if c in data.columns and is_numeric_dtype(data[c])]
|
|
2098
2118
|
|
|
2099
2119
|
# 사용 가능한 컬럼이 2개 미만이면 상관분석 불가능
|
|
2100
2120
|
if len(cols) < 2:
|
|
@@ -2707,7 +2727,7 @@ def predict(fit, data: DataFrame | Series) -> DataFrame | Series | float:
|
|
|
2707
2727
|
# ===================================================================
|
|
2708
2728
|
# 확장된 기술통계량 (Extended Descriptive Statistics)
|
|
2709
2729
|
# ===================================================================
|
|
2710
|
-
def
|
|
2730
|
+
def describe(data: DataFrame, *fields: str, columns: list = None):
|
|
2711
2731
|
"""데이터프레임의 연속형 변수에 대한 확장된 기술통계량을 반환한다.
|
|
2712
2732
|
|
|
2713
2733
|
각 연속형(숫자형) 컬럼의 기술통계량(describe)을 구하고, 이에 사분위수 범위(IQR),
|
|
@@ -2854,3 +2874,119 @@ def summary(data: DataFrame, *fields: str, columns: list = None):
|
|
|
2854
2874
|
result = result[columns]
|
|
2855
2875
|
|
|
2856
2876
|
return result
|
|
2877
|
+
|
|
2878
|
+
|
|
2879
|
+
# ===================================================================
|
|
2880
|
+
# 상관계수 및 효과크기 분석 (Correlation & Effect Size)
|
|
2881
|
+
# ===================================================================
|
|
2882
|
+
def corr_effect_size(data: DataFrame, dv: str, *fields: str, alpha: float = 0.05) -> DataFrame:
|
|
2883
|
+
"""종속변수와의 편상관계수 및 효과크기를 계산한다.
|
|
2884
|
+
|
|
2885
|
+
각 독립변수와 종속변수 간의 상관계수를 계산하되, 정규성과 선형성을 검사하여
|
|
2886
|
+
Pearson 또는 Spearman 상관계수를 적절히 선택한다.
|
|
2887
|
+
Cohen's d (효과크기)를 계산하여 상관 강도를 정량화한다.
|
|
2888
|
+
|
|
2889
|
+
Args:
|
|
2890
|
+
data (DataFrame): 분석 대상 데이터프레임.
|
|
2891
|
+
dv (str): 종속변수 컬럼 이름.
|
|
2892
|
+
*fields (str): 독립변수 컬럼 이름들. 지정하지 않으면 수치형 컬럼 중 dv 제외 모두 사용.
|
|
2893
|
+
alpha (float, optional): 유의수준. 기본 0.05.
|
|
2894
|
+
|
|
2895
|
+
Returns:
|
|
2896
|
+
DataFrame: 다음 컬럼을 포함한 데이터프레임:
|
|
2897
|
+
- Variable (str): 독립변수 이름
|
|
2898
|
+
- Correlation (float): 상관계수 (Pearson 또는 Spearman)
|
|
2899
|
+
- Corr_Type (str): 선택된 상관계수 종류 ('Pearson' 또는 'Spearman')
|
|
2900
|
+
- P-value (float): 상관계수의 유의확률
|
|
2901
|
+
- Cohens_d (float): 표준화된 효과크기
|
|
2902
|
+
- Effect_Size (str): 효과크기 분류 ('Large', 'Medium', 'Small', 'Negligible')
|
|
2903
|
+
|
|
2904
|
+
Examples:
|
|
2905
|
+
>>> from hossam import hs_stats
|
|
2906
|
+
>>> import pandas as pd
|
|
2907
|
+
>>> df = pd.DataFrame({'age': [20, 30, 40, 50],
|
|
2908
|
+
... 'bmi': [22, 25, 28, 30],
|
|
2909
|
+
... 'charges': [1000, 2000, 3000, 4000]})
|
|
2910
|
+
>>> result = hs_stats.corr_effect_size(df, 'charges', 'age', 'bmi')
|
|
2911
|
+
>>> print(result)
|
|
2912
|
+
"""
|
|
2913
|
+
|
|
2914
|
+
# fields가 지정되지 않으면 수치형 컬럼 중 dv 제외 모두 사용
|
|
2915
|
+
if not fields:
|
|
2916
|
+
fields = [col for col in data.columns
|
|
2917
|
+
if is_numeric_dtype(data[col]) and col != dv]
|
|
2918
|
+
|
|
2919
|
+
# dv가 수치형인지 확인
|
|
2920
|
+
if not is_numeric_dtype(data[dv]):
|
|
2921
|
+
raise ValueError(f"Dependent variable '{dv}' must be numeric type")
|
|
2922
|
+
|
|
2923
|
+
results = []
|
|
2924
|
+
|
|
2925
|
+
for var in fields:
|
|
2926
|
+
if not is_numeric_dtype(data[var]):
|
|
2927
|
+
continue
|
|
2928
|
+
|
|
2929
|
+
# 결측치 제거
|
|
2930
|
+
valid_idx = data[[var, dv]].notna().all(axis=1)
|
|
2931
|
+
x = data.loc[valid_idx, var].values
|
|
2932
|
+
y = data.loc[valid_idx, dv].values
|
|
2933
|
+
|
|
2934
|
+
if len(x) < 3:
|
|
2935
|
+
continue
|
|
2936
|
+
|
|
2937
|
+
# 정규성 검사 (Shapiro-Wilk: n <= 5000 권장, 그 외 D'Agostino)
|
|
2938
|
+
method_x = 's' if len(x) <= 5000 else 'n'
|
|
2939
|
+
method_y = 's' if len(y) <= 5000 else 'n'
|
|
2940
|
+
|
|
2941
|
+
normal_x_result = normal_test(data[[var]], columns=[var], method=method_x)
|
|
2942
|
+
normal_y_result = normal_test(data[[dv]], columns=[dv], method=method_y)
|
|
2943
|
+
|
|
2944
|
+
# 정규성 판정 (p > alpha면 정규분포 가정)
|
|
2945
|
+
normal_x = normal_x_result.loc[var, 'p-val'] > alpha if var in normal_x_result.index else False
|
|
2946
|
+
normal_y = normal_y_result.loc[dv, 'p-val'] > alpha if dv in normal_y_result.index else False
|
|
2947
|
+
|
|
2948
|
+
# Pearson (모두 정규) vs Spearman (하나라도 비정규)
|
|
2949
|
+
if normal_x and normal_y:
|
|
2950
|
+
r, p = pearsonr(x, y)
|
|
2951
|
+
corr_type = 'Pearson'
|
|
2952
|
+
else:
|
|
2953
|
+
r, p = spearmanr(x, y)
|
|
2954
|
+
corr_type = 'Spearman'
|
|
2955
|
+
|
|
2956
|
+
# Cohen's d 계산 (상관계수에서 효과크기로 변환)
|
|
2957
|
+
# d = 2*r / sqrt(1-r^2)
|
|
2958
|
+
if r**2 < 1:
|
|
2959
|
+
d = (2 * r) / np.sqrt(1 - r**2)
|
|
2960
|
+
else:
|
|
2961
|
+
d = 0
|
|
2962
|
+
|
|
2963
|
+
# 효과크기 분류 (Cohen's d 기준)
|
|
2964
|
+
# Small: 0.2 < |d| <= 0.5
|
|
2965
|
+
# Medium: 0.5 < |d| <= 0.8
|
|
2966
|
+
# Large: |d| > 0.8
|
|
2967
|
+
abs_d = abs(d)
|
|
2968
|
+
if abs_d > 0.8:
|
|
2969
|
+
effect_size = 'Large'
|
|
2970
|
+
elif abs_d > 0.5:
|
|
2971
|
+
effect_size = 'Medium'
|
|
2972
|
+
elif abs_d > 0.2:
|
|
2973
|
+
effect_size = 'Small'
|
|
2974
|
+
else:
|
|
2975
|
+
effect_size = 'Negligible'
|
|
2976
|
+
|
|
2977
|
+
results.append({
|
|
2978
|
+
'Variable': var,
|
|
2979
|
+
'Correlation': r,
|
|
2980
|
+
'Corr_Type': corr_type,
|
|
2981
|
+
'P-value': p,
|
|
2982
|
+
'Cohens_d': d,
|
|
2983
|
+
'Effect_Size': effect_size
|
|
2984
|
+
})
|
|
2985
|
+
|
|
2986
|
+
result_df = DataFrame(results)
|
|
2987
|
+
|
|
2988
|
+
# 상관계수로 정렬 (절댓값 기준 내림차순)
|
|
2989
|
+
if len(result_df) > 0:
|
|
2990
|
+
result_df = result_df.sort_values('Correlation', key=lambda x: x.abs(), ascending=False).reset_index(drop=True)
|
|
2991
|
+
|
|
2992
|
+
return result_df
|