SQLitebroswer 설치 (Windows 11)
개요
- SQLitebroswer 설치를 진행해본다.
설치
- 주소 : https://sqlitebrowser.org/
- Download 버튼을 클릭한다.

- 자신의 OS에 맞는 버전을 선택해 다운로드 후 설치
- 필자는 Standard installer for 64-bit Windows 다운로드 받았다.

- 설치 프로그램을 실행한 후, 아래와 같이 순차적으로 실행한다.






끝.








끝.





import statsmodels
import seaborn as sns
import pandas as pd
print(statsmodels.__version__)
print(sns.__version__)
print(pd.__version__)
0.14.1
0.12.2
1.5.3
tips = sns.load_dataset('tips')
tips.head()

conda create -n virtualTest python=3.10

conda activate virtualTest

name: virtualTest
channels:
- defaults
dependencies:
- python=3.10
- numpy
- pandas
- pip:
- streamlit
conda env create -f environment.yml
conda install matplotlib
conda env export > env_file.yml

7월 유럽여행을 다녀온 이후, 쉴새없이 후반기를 달려왔습니다. 첫번째 멀티캠퍼스에서 강의를 마친 후, 중간 중간 저녁강의 및 토요일 강의를 병행하면서, 어떤 날은 일주일에 70시간 가깝게 소화한 날도 있었습니다. 그래서 약간의 휴가를 줄겸 하던차에 나트랑 여행을 떠나기로 하였습니다. (12월 8일까지 강의를 계속 했지요!). 그러던 찰나에 제가 가진 카드 중 라운지 연 2회 무료 이용권이 있음을 알게 되었습니다. 그래서 가족 여행을 떠나면서 라운지를 꼭 이용하고자 다짐했습니다. 보통 일요일에는 교회를 갑니다. 교회 근처에서 간단한 점심을 먹는데, 이번에는 교회에서 간단한 샌드위치와 아이스 아메리카노만 먹고 공항으로 출발했습니다.
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
years = [2007, 2008]
months = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']
np.random.seed(0) # For reproducibility
data = {
'year': np.repeat(years, 12),
'month': months * 2,
'house_prices': np.random.randint(100, 500, 24)
}
df_random = pd.DataFrame(data)
df_random.head()

import pandas as pd
data = {
'Name': ['Evan', 'Bob', 'Evan', 'Bob'],
'City': ['New York', 'Los Angeles', 'New York', 'SF'],
'Job': ['Engineer', 'Engineer', 'Engineer', 'Artist'],
'num1' : [1, 2, 3, 4]
}
df = pd.DataFrame(data)
print(df)
Name City Job num1
0 Evan New York Engineer 1
1 Bob Los Angeles Engineer 2
2 Evan New York Engineer 3
3 Bob SF Artist 4
# object 컬럼명 도출
object_cols = df.select_dtypes(include=['object'])
print(object_cols)
Name City Job
0 Evan New York Engineer
1 Bob Los Angeles Engineer
2 Evan New York Engineer
3 Bob SF Artist
object_cols.columns는 고유값을 찾고자 하는 열들의 이름을 포함하는 리스트이다.for col in object_cols.columns: 이 반복문은 object_cols.columns에 있는 각 열 이름에 대해 반복한다.df[col].unique(): 이 부분은 DataFrame df에서 col 열의 고유값들을 추출합니다. unique() 함수는 해당 열에서 중복을 제거한 값들의 배열을 반환한다.# 각 컬럼별 고유값만 추출한다.
unique_values = {col: df[col].unique() for col in object_cols.columns}
unique_values
{'Name': array(['Evan', 'Bob'], dtype=object),
'City': array(['New York', 'Los Angeles', 'SF'], dtype=object),
'Job': array(['Engineer', 'Artist'], dtype=object)}
구독과 좋아요)from google.colab import drive
drive.mount("/content/drive")
Mounted at /content/drive
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
## from sklearn.metrics import make_scorer, mean_squared_error
## from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import roc_auc_score
from sklearn.ensemble import RandomForestClassifier
DATA_PATH = '/content/drive/MyDrive/Colab Notebooks/2024/빅분기/[Dataset] 작업형 제2유형/'
X_test = pd.read_csv(DATA_PATH + "X_test.csv", encoding='cp949')
X_train = pd.read_csv(DATA_PATH + "X_train.csv", encoding='cp949')
y_train = pd.read_csv(DATA_PATH + "y_train.csv", encoding='cp949')
print(X_test.shape, X_train.shape, y_train.shape)
(2482, 10) (3500, 10) (3500, 2)
print(y_train.head(3))
cust_id gender
0 0 0
1 1 0
2 2 1
print(X_train.head(3))
cust_id 총구매액 최대구매액 환불금액 주구매상품 주구매지점 내점일수 내점당구매건수 \
0 0 68282840 11264000 6860000.0 기타 강남점 19 3.894737
1 1 2136000 2136000 300000.0 스포츠 잠실점 2 1.500000
2 2 3197000 1639000 NaN 남성 캐주얼 관악점 2 2.000000
주말방문비율 구매주기
0 0.527027 17
1 0.000000 1
2 0.000000 1
print(X_train.info())
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3500 entries, 0 to 3499
Data columns (total 10 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 cust_id 3500 non-null int64
1 총구매액 3500 non-null int64
2 최대구매액 3500 non-null int64
3 환불금액 1205 non-null float64
4 주구매상품 3500 non-null object
5 주구매지점 3500 non-null object
6 내점일수 3500 non-null int64
7 내점당구매건수 3500 non-null float64
8 주말방문비율 3500 non-null float64
9 구매주기 3500 non-null int64
dtypes: float64(3), int64(5), object(2)
memory usage: 273.6+ KB
None
print(y_train.info())
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3500 entries, 0 to 3499
Data columns (total 2 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 cust_id 3500 non-null int64
1 gender 3500 non-null int64
dtypes: int64(2)
memory usage: 54.8 KB
None
fillna() 메서드를 사용한다.X_train.isnull().sum()
cust_id 0
총구매액 0
최대구매액 0
환불금액 2295
주구매상품 0
주구매지점 0
내점일수 0
내점당구매건수 0
주말방문비율 0
구매주기 0
dtype: int64
X_train = X_train.drop("환불금액", axis=1)
X_train.isnull().sum()
cust_id 0
총구매액 0
최대구매액 0
주구매상품 0
주구매지점 0
내점일수 0
내점당구매건수 0
주말방문비율 0
구매주기 0
dtype: int64
X_train['주구매상품'].value_counts()
기타 595
가공식품 546
농산물 339
화장품 264
시티웨어 213
디자이너 193
수산품 153
캐주얼 101
명품 100
섬유잡화 98
골프 82
스포츠 69
일용잡화 64
모피/피혁 57
육류 57
남성 캐주얼 55
구두 54
건강식품 47
차/커피 44
피혁잡화 40
아동 40
축산가공 35
주방용품 32
셔츠 30
젓갈/반찬 29
주방가전 26
트래디셔널 23
남성정장 22
생활잡화 15
주류 14
가구 10
커리어 9
대형가전 8
란제리/내의 8
식기 7
액세서리 5
침구/수예 4
통신/컴퓨터 3
보석 3
남성 트랜디 2
소형가전 2
악기 2
Name: 주구매상품, dtype: int64
X_train['주구매지점'].value_counts()
본 점 1077
잠실점 474
분당점 436
부산본점 245
영등포점 241
일산점 198
강남점 145
광주점 114
노원점 90
청량리점 86
대전점 70
미아점 69
부평점 57
동래점 49
관악점 46
인천점 34
안양점 29
포항점 11
대구점 7
센텀시티점 6
울산점 6
전주점 5
창원점 4
상인점 1
Name: 주구매지점, dtype: int64
X_train_id = X_train.pop("cust_id")
print(X_train.info())
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3500 entries, 0 to 3499
Data columns (total 8 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 총구매액 3500 non-null int64
1 최대구매액 3500 non-null int64
2 주구매상품 3500 non-null object
3 주구매지점 3500 non-null object
4 내점일수 3500 non-null int64
5 내점당구매건수 3500 non-null float64
6 주말방문비율 3500 non-null float64
7 구매주기 3500 non-null int64
dtypes: float64(2), int64(4), object(2)
memory usage: 218.9+ KB
None
X_test_id = X_test.pop("cust_id")
print(X_test.info())
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2482 entries, 0 to 2481
Data columns (total 9 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 총구매액 2482 non-null int64
1 최대구매액 2482 non-null int64
2 환불금액 871 non-null float64
3 주구매상품 2482 non-null object
4 주구매지점 2482 non-null object
5 내점일수 2482 non-null int64
6 내점당구매건수 2482 non-null float64
7 주말방문비율 2482 non-null float64
8 구매주기 2482 non-null int64
dtypes: float64(3), int64(4), object(2)
memory usage: 174.6+ KB
None
cat_cols = X_train.select_dtypes(exclude = np.number).columns.tolist()
num_cols = X_train.select_dtypes(include = np.number).columns.tolist()
print(cat_cols)
print(num_cols)
['주구매상품', '주구매지점']
['총구매액', '최대구매액', '내점일수', '내점당구매건수', '주말방문비율', '구매주기']
X_tr, X_val, y_tr, y_val = train_test_split(
X_train, y_train['gender'],
stratify = y_train['gender'],
test_size=0.3,
random_state=42
)
X_tr.shape, X_val.shape, y_tr.shape, y_val.shape
((2450, 8), (1050, 8), (2450,), (1050,))
column_transformer = ColumnTransformer([
("scaler", StandardScaler(), num_cols),
("ohd_encoder", OneHotEncoder(handle_unknown='ignore'), cat_cols)
], remainder="passthrough")
pipeline = Pipeline([
("preprocessing", column_transformer),
("clf", RandomForestClassifier(random_state=42))
])
pipeline.fit(X_tr, y_tr)







매일로 선택한다.
