# -*- coding: utf-8 -*-"""Created on Thu Feb 16 14:22:16 2017@author: yunjinqiE-mail:yunjinqi@QQ.comDifferentiate yourself in the world from anyone else."""'''1. data1 是40名癌癥病人的一些生存資料,其中,X1表示生活行動能力評分(1~100),X2表示病人的年齡,X3表示由診斷到直入研究時間(月);X4表示腫瘤類型,X5把ISO兩種療法(“1”是常規,“0”是試驗新療法);Y表示病人生存時間(“0”表示生存時間小于200天,“1”表示生存時間大于或等于200天)試建立Y關于X1~X5的logistic回歸模型'''########################################################讀取整理數據import pandas as pdfrom sklearn.linear_model import LogisticRegression as LRfrom sklearn.linear_model import RandomizedLogisticRegression as RLR data=pd.read_table('data1.txt',encoding='gbk')datax=data.iloc[:,1:6].as_matrix()y=data.iloc[:,6].as_matrix()rlr = RLR() #建立隨機邏輯回歸模型,篩選變量rlr.fit(x, y) #訓練模型rlr.get_support() #獲取特征篩選結果,也可以通過.scores_方法獲取各個特征的分數
新聞熱點
疑難解答