def corr_analysis(data): col = list(data.columns) col.remove("CreationTime") col.remove( "InBandwidth") target_attribute = "InBandwidth" cor = [] for i in col: corval = abs(st.pearsonr(data[target_attribute],data[i])[0]) cor.append(corval) return cor
def print_corr(data): col = list(data.columns) col.remove("CreationTime") col.remove( "InBandwidth") target_attribute = "InBandwidth" cor = [] print("\nCorrelation Coefficient of 'InBandwidth' with ") for i in col: corval = abs(st.pearsonr(data[target_attribute],data[i])[0]) cor.append(corval) print(i," = ",corval)
def corr_column(df): col = list(df.columns) #col.remove("CreationTime") col.remove("InBandwidth") val = [] for i in col: val.append(abs(st.pearsonr(df["InBandwidth"], df[i])[0])) x = sorted(val, reverse=True) col1 = col[val.index(x[0])] #maximum correalatio coefficient col2 = col[val.index(x[1])] print(col1, col2) return col1, col2
def corr_analysis(data): col = list(data.columns) #col.remove("CreationTime") col.remove("InBandwidth") target_attribute = "InBandwidth" CORRs = [] print( "\nCorrelation Coefficient of 'InBandwidth' with other attributes:\n") for i in col: cor = abs(st.pearsonr(data[target_attribute], data[i])[0]) CORRs.append(cor) print(i, ": ", cor) return CORRs
def loss_corr(x1, x2, y1, y2, criterion, model, corr_lambda): loss1 = criterion(y1, x2) loss2 = criterion(y2, x1) corr_term = corr_lambda * stats.pearsonr(model.encoder1(x1), model.encoder2(x2)) return loss1 + loss2 - corr_term