본문 바로가기

전체 글

(66)
mlxtend 연관성 분석 from mlxtend.preprocessing import TransactionEncoder from mlxtend.frequent_patterns import apriori, association_rules https://rasbt.github.io/mlxtend/user_guide/preprocessing/TransactionEncoder/ TransactionEncoder - mlxtend From here you can search these documents. Enter your search terms below. rasbt.github.io https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/apriori/ Apriori - mlxte..
from statsmodels.stats import multicomp : Tukey 사후검정 from statsmodels.stats import multicomp result = multicomp.pairwise_tukeyhsd(df["x"], df["y"], alpha=0.05) result.summary()
from scipy.stats import f_oneway : 분산분석(ANOVA) from scipy.stats import f_oneway f_value, p_value = f_oneway(df.loc[df["x"]=="Type1","y"], df.loc[df["x"]=="Type2","y"], df.loc[df["x"]=="Type3","y"])
df['score'].rank(method='min', ascending=False) : score 순위 구할 때 사용 df['score'].rank(ascending=False) # default (method='average') #동점 관측치 그룹 내 평균 부여 df['score'].rank(method='min', ascending=False) #동점 관측치 그룹 내 최소 순위 부여 df['score'].rank(method='max', ascending=False) #동점 관측치 그룹 내 최대 순위 부여 df['score'].rank(method='first', ascending=False) #동점 관측치 중에서 데이터 상에서 먼저 나타나는 관측치부터 순위 부여 df['score'].rank(method='dense', ascending=False) #최소값('min')과 같은 방법으로 순위부여하나, 순위가 '1'..
df.drop_duplicates(subset=['a'], keep='last') : a 중복값 중 마지막 남기고 다 제거 df.drop_duplicates(subset=['a'], keep='last') #a 중복값 중 마지막 남기고 다 제거 df.drop_duplicates(subset=['a'], keep='first') # default #a 중복값 중 맨 앞 남기고 다 제거 df.drop_duplicates(subset=['a'], keep=False) #a 중복값 모두 제거 ------------------------------ df.duplicated(['a']) # 중복 데이터 여부 확인은 duplicated
df.sort_values(by=['a','b']) : a, b 기준으로 sorting (사용예시) df.sort_values(by=['a','b'], ascending=[True,True])
from sklearn.linear_model import LinearRegression : Linear 리그레션 (사용예시) from sklearn.linear_model import LinearRegression lr = LinearRegression() lr_pre = lr.fit(df_x, df_y) lr_result = lr_pre.predict(df_test_x)
df.loc[:,'a':'b'], df.iloc[:,1:3] : loc는 문자열, iloc는 숫자 (사용예시) df.loc[:, 'a':'b'] #df의 'a' 이름을 가진 열부터 'b' 이름을 가진 열까지 모든 행 출력 df.iloc[:, 1:3] #df의 1열부터 3열까지 모든 행 출력