In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
For more information on big data's analysis and modeling, please follow the official account "bigdatamodeling".
After dividing the variable into boxes, you need to calculate the importance of the variable. IV is one of the statistics to evaluate the differentiation or importance of the variable. The code for python to calculate the IV value is as follows:
Def CalcIV (Xvar Yvar): np.sum (Yvar==0) Numb1 = np.sum (Yvar==1) N_0_group = np.zeros (np.unique (Xvar) .shape) N_1_group = np.zeros (np.unique (Xvar) .shape) for i in range (len (np.unique (Xvar): N_0_group [I] = Yvar [(Xvar = = np.unique (Xvar) [I]) & (Yvar==0)]. Count () Numb1Group [I] = Yvar [(Xvar = = np.unique (Xvar) [I]) & (Yvar = = 1)] .count () iv = np.sum ((N_0_group/N_0-N_1_group/N_1) * np.log ((N_0_group/N_0) / (N_1_group/N_1)) return iv def caliv_batch (df) Kvar, Yvar): df_Xvar = df.drop ([Kvar, Yvar], axis=1) ivlist = [] for col in df_Xvar.columns: iv = CalcIV (df [col], df [Yvar]) ivlist.append (iv) names = list (df_Xvar.columns) iv_df = pd.DataFrame ({'Var': names,' Iv': ivlist}, columns= ['Var',' Iv']) return iv_df
Where df is the dataset after the box, Kvar is the primary key, and Yvar is the y variable (0 is good, 1 is bad). The running result of the code is as follows:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.