"Feature filtering methods for logistic regression"

Source: Internet
Author: User

The data features are as follows

Stability selection using logistic regression

ImportPandas as PDImportNumPy as NPImportPyechartsImportxlrd#with open (R ' f:\ data analysis dedicated \ Data analysis and machine learning \bankloan.xls ', ' RB ') as F:File = R'f:\ data analysis dedicated \ Data analysis and machine learning \bankloan.xls'Data=pd.read_excel (file)#print (Data.head ())x = data.iloc[:,: 8].values#print (x)y = data.iloc[:, 8].values#print (y) fromSklearn.linear_modelImportLogisticregression as LR fromSklearn.linear_modelImportRandomizedlogisticregression as Rlrrlr=RLR () rlr.fit (x, y) rlr.get_support () validate_feature= data.iloc[:,: 8]Print(U'valid feature is:%s'%','. Join (Validate_feature.columns[rlr.get_support () )) x=data[validate_feature.columns[rlr.get_support ()]].VALUESLR=LR () lr.fit (x, y)Print(U'average correct rate of the model:%s'% Lr.score (x, y))
View Code

"Feature filtering methods for logistic regression"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.