์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- opencv
- ๋ฐ์ดํฐ๋ถ๊ท ํ
- ๊ตฐ์งํ
- ๋ฐ์ดํฐ๋ถ์์ค์ ๋ฌธ๊ฐ
- ๋ฐ์ดํฐ๋ถ์
- ์๋ํด๋ผ์ฐ๋
- ๋น ๋ฐ์ดํฐ๋ถ์๊ธฐ์ฌ
- Python
- ์ฃผ์ฑ๋ถ๋ถ์
- PCA
- iloc
- dataframe
- ๋ ๋ฆฝํ๋ณธ
- ํฌ๋กค๋ง
- ์ค๋ฒ์ํ๋ง
- Lambda
- ADP
- numpy
- LDA
- ํ์ด์ฌ
- t-test
- ํ ์คํธ๋ถ์
- ADsP
- pandas
- ์ธ๋์ํ๋ง
- ๋ฐ์ดํฐ๋ถ์์ ๋ฌธ๊ฐ
- ๋์ํ๋ณธ
- datascience
- DBSCAN
- ๋น ๋ฐ์ดํฐ
๋ชฉ๋ก๐ Python (45)
Data Science LAB
ํด๋์์ ์กด์ฌํ๋ ์ฌ๋ฌ ํ์ผ์ ํ๋ฒ์ ๋ถ๋ฌ์ค๊ธฐ import glob folders = glob.glob('ํด๋๊ฒฝ๋ก') ํด๋ ์์ ์กด์ฌํ๋ ๋ชจ๋ ํด๋์ ํ์ผ์ ํ๋ฒ์ ๋ถ๋ฌ์ค๊ธฐ folders = ('์ฒซ๋ฒ์งธ ํด๋ ๊ฒฝ๋ก\*') ํด๋ ์์ ํ์ผ ์ค json ํ์ผ๋ง ๋ถ๋ฌ์ค๊ธฐ json_folders = glob.glob('ํ์ผ ๊ฒฝ๋ก\.json') ํด๋ ์์ ํ์ผ ์ค csv ํ์ผ๋ง ๋ถ๋ฌ์ค๊ธฐ csv_folders = glob.glob('ํ์ผ ๊ฒฝ๋ก\*.csv')

1. Json ํ์ผ ์ฝ๊ธฐ import json with open('ํ์ผ ๊ฒฝ๋ก','r') as f: data = json.load(f) 2. Json ํ์ผ ์์ with open('ํ์ผ ๊ฒฝ๋ก', 'w') as make_file: json.dump(data,make_file) 3. Json ํ์ผ ์ฐ๊ธฐ with open('์ ์ฅ๊ฒฝ๋ก','w', encoding='utf-8) as make_file: json.dump([๋์ ๋๋ฆฌ ์ด๋ฆ] , make_file, indent='\t') ๋จผ์ , ํ์ด์ฌ ์ธ์ด๋ฅผ ์ฌ์ฉํ์ฌ ๋์ ๋๋ฆฌ๋ฅผ ์์ฑํ ํ , json ํ์์ ํ์ผ๋ก ์ ์ฅํ ์ ์๋ค.

df.columns.difference๋ ์ฃผ๋ก ๋ณ์์ y๊ฐ์ ๋ถ๋ฆฌํ๊ธฐ ์ํด ์ฌ์ฉํ๋ค. 1. ์๋ ๋ฐ์ดํฐ์ ์ ๋ณ์ ํ์ธ 2. ๋ ๋ฆฝ๋ณ์๋ก ์ฌ์ฉํ ๋ณ์๋ง ์ถ์ถ features = df.columns.difference(['price','CHAS']) ๋ณ์ 'price', 'CHAS'๊ฐ ์ฌ๋ผ์ง ๊ฒ์ ํ์ธํ ์ ์๋ค.

Error ์ฃผํผํฐ ๋ ธํธ๋ถ์์ SMOTE.fit_sample()๋ฅผ ์ด์ฉํด OverSampling ๋ฐ์ดํฐ ์์ฑ ์ค ๋ค์๊ณผ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํ์๋ค. AttributeError: 'SMOTE' object has no attribute 'fit_sample' ํด๊ฒฐ ๋ฐฉ๋ฒ ๋ชจ๋์ ๋ถ๋ฌ์ฌ ๋, ๋ค์์ ์ฝ๋๋ฅผ ์ฌ์ฉํ๋ค๋ฉด from imblearn.over_sampling import SMOTE X_train_over, y_train_over = smote.fit_resample(X_train, y_train) fit_resample()ํจ์๋ฅผ ์ฌ์ฉํ๋ฉด ํด๊ฒฐ๋๋ค.

1. ๋ ์ง ํ์์ผ๋ก ๋ฐ์ดํฐ ํ์ ๋ณํ df['Date'] = pd.to_datetime(df['Date']) pd.to_datetime()์ ์ฌ์ฉํ๋ฉด ๋ ์ง ํ์์ ๋ฐ์ดํฐ ํ์ ์ธ 'Datetime' ์ผ๋ก ๋ณํํ ์ ์๋ค. 2. ๋ , ์, ์ผ ์ถ์ถ df['๋ '] = df['Date'].dt.year df['์'] = df['Date'].dt.month df['์ผ'] = df['Date'].dt.day df['์์ผ'] = df['Date'].dt.day_name() 3. ํน์ ๋ ์ง ์ถ์ถ ex) 2์๋ฌ์ ๋ฐ์ดํฐ๋ง ์ถ์ถ df = df[df['Date'].dt.month == 2] ์ํฉ์ ๋ง์ถฐ ์กฐ๊ฑด์ ์ถ์ถํ๋ฉด ํด๋น ๋ , ์, ์ผ, ์์ผ์ ๋ง๋ ๋ฐ์ดํฐ๋ฅผ ์ถ์ถํ ์ ์๋ค. 4. ํ์ฌ ์๊ฐ, ๋ ์ง ๊ตฌํ๊ธฐ from dat..

์ฃผํผํฐ ๋ ธํธ๋ถ์์ networkx ํจํค์ง๋ฅผ ์ด์ฉํด ์ฐ๊ด ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ์๊ฐํ ํ๋ ๊ณผ์ ์์ ๋ค์๊ณผ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํ์๋ค. NetworkXError: random_state_index is incorrect ํด๊ฒฐ ๋ฐฉ๋ฒ !pip install decorator==4.3 ์์ ์ฝ๋๋ฅผ ์คํํ ๋ค, ์ปค๋์ ์ฌ์์ํด์ฃผ๋ฉด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๋ค!