def getFeature(item): if item is None: return yr = item['year'] vec = fe.get(item['sentences1'],item['sentences2']) titles = ([item['title1'],item['title2']]) # print [vec,titles,yr] return ([vec,titles,yr,item['date1'],item['date2']])
def getFeature(item): if item is None: return yr = item['year'] vec = fe.get(item['sentences1'], item['sentences2']) titles = ([item['title1'], item['title2']]) # print [vec,titles,yr] return ([vec, titles, yr, item['date1'], item['date2']])
def train(doubleSets): bools = [] features = [] for item in doubleSets: bools.append(item['year']) vec = fe.get(item['sentences1'],item['sentences2']) features.append(vec) print "Training The Classifier." clf.fit(features,bools)
def test(doubleSets): bools = [] features = [] correct = 0 incorrect = 0 for item in doubleSets: bools.append(item['year']) vec = fe.get(item['sentences1'],item['sentences2']) titles.append([item['title1'],item['title2']]) features.append(vec) for feature in range(len(features)): predict = clf.predict(np.array9[features[feature]])) prob = clf.predict_proba(np.arrat([features[feature]])) probs.append([predict,prob, bools[feature]])
def getFeature(item): yr = item['year'] vec = fe.get(item['sentences1'], item['sentences2']) titles = ([item['title1'], item['title2']]) return ([vec, titles, yr])
def getFeature(item): yr = item['year'] vec = fe.get(item['sentences1'],item['sentences2']) titles = ([item['title1'],item['title2']]) return ([vec,titles,yr])