Kaggle競賽題目之——Predicting a Biological Response,kagglepredicting
Predict a biological response of molecules from their chemical properties
從分子的化學屬性中預測其生物反應。
The objective of the competition is to help us build as good a model as possible so that we can, as optimally as this data allows, relate molecular information, to an actual biological response.
We have shared the data in the comma separated values (CSV) format. Each row in this data set represents a molecule. The first column contains experimental data describing an actual biological response; the molecule was seen to elicit this response (1), or not (0). The remaining columns represent molecular descriptors (d1 through d1776), these are calculated properties that can capture some of the characteristics of the molecule - for example size, shape, or elemental constitution. The descriptor matrix has been normalized.
簡述:給定CSV檔案,每行代表一個分子。第一列代表真實的生物反應,有反應(1),無反應(0)。第2列到第1777列代表分子的屬性,例如,大小、形狀或元素等。
這個題目的比賽早就結束了,但是仍然可以提交5次結果,查看自己的得分排名。只要提交一個csv格式的結果檔案就可以了。
看到0、1,可以確定這是一個二分類問題。
對於這樣一個二分類,多屬性的問題,首先想到用羅吉斯迴歸來試一下。
下面是使用Logistic Regression做預測的python代碼:
#!/usr/bin/env python#coding:utf-8'''Created on 2014年11月24日@author: zhaohf'''from sklearn.linear_model import LogisticRegressionfrom numpy import genfromtxt,savetxtdef main(): dataset = genfromtxt(open('../Data/train.csv','r'),delimiter=',',dtype='f8')[1:] test = genfromtxt(open('../Data/test.csv','r'),delimiter=',',dtype='f8')[1:] target = [x[0] for x in dataset] train = [x[1:] for x in dataset] lr = LogisticRegression() lr.fit(train, target) predicted_probs = [[index+1,x[1]] for index,x in enumerate(lr.predict_proba(test))] savetxt('../Submissions/lr_benchmark.csv',predicted_probs,delimiter=',',fmt='%d,%f',header='Molecule,PredictedProbability',comments='') if __name__ == '__main__': main()
通過損失函數檢驗,最後的public score是0.59425,這算是一個非常差的分數了。排名數百名開外。
下面使用SVM來試一下。代碼非常相似。
#!/usr/bin/env python#coding:utf-8'''Created on 2014年11月24日@author: zhaohf'''from sklearn import svmfrom numpy import genfromtxt,savetxtdef main(): dataset = genfromtxt(open('../Data/train.csv','r'),delimiter=',',dtype='f8')[1:] test = genfromtxt(open('../Data/test.csv','r'),delimiter=',',dtype='f8')[1:] target = [x[0] for x in dataset] train = [x[1:] for x in dataset] svc = svm.SVC(probability=True) svc.fit(train,target) predicted_probs = [[index+1,x[1]] for index,x in enumerate(svc.predict_proba(test))] savetxt('../Submissions/svm_benchmark.csv',predicted_probs,delimiter=',',fmt='%d,%f',header='MoleculeId,PredictedProbability',comments='') if __name__ == '__main__': main()
SVM的得分是0.52553。比起LR略好。
熱門排行榜上做到最好的分數是0.37356,要想參加比賽取得成績還是要做些努力的。