本文整理汇总了Python中Features类的典型用法代码示例。如果您正苦于以下问题:Python Features类的具体用法?Python Features怎么用?Python Features使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Features类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feat6_generic
def feat6_generic(train, test, train_pos, test_pos):
train_f5, test_f5 = feat5(train, test)
cter, train_cts = Features.keyPOSNGrams(train_pos, ["jj.*", "vb.*"], tf_idf = True)
_, test_cts = Features.keyPOSNGrams(test_pos, ["jj.*", "vb.*"], vectorizer = cter, tf_idf= True)
train_matrix = Features.append_features([train_f5, train_cts])
test_matrix = Features.append_features([test_f5, test_cts])
return train_matrix, test_matrix
示例2: feat5
def feat5(train, test):
train_valence, test_valence = feat1(train, test)
puncter, train_punct = Features.punctuation(train)
_, test_punct = Features.punctuation(test, vectorizer = puncter)
train_matrix = Features.append_features([train_valence, train_punct])
test_matrix = Features.append_features([test_valence, test_punct])
return train_matrix, test_matrix
示例3: display_data
def display_data(self):
logging.info('DISPLAYING TEXELS')
Features.show_texel_list(self.texel_features)
self.mytimer.tick()
logging.info('DISPLAYING DONE')
示例4: feat6
def feat6(train, test):
normal_train, train_pos = map(list, zip(*train))
normal_test, test_pos = map(list, zip(*test))
train_f5, test_f5 = feat5(normal_train, normal_test)
cter, train_cts = Features.keyPOSNGrams(train_pos, ["jj.*", "vb.*"], tf_idf = True)
_, test_cts = Features.keyPOSNGrams(test_pos, ["jj.*", "vb.*"], vectorizer = cter, tf_idf= True)
train_matrix = Features.append_features([train_f5, train_cts])
test_matrix = Features.append_features([test_f5, test_cts])
return train_matrix, test_matrix
示例5: feat4
def feat4(train, test):
# feature set 3
train_f3, test_f3 = feat3(train, test)
# punctuation
puncter, train_punct = Features.punctuation(train)
_, test_punct = Features.punctuation(test, vectorizer = puncter)
train_matrix = Features.append_features([train_f3, train_punct])
test_matrix = Features.append_features([test_f3, test_punct])
return train_matrix, test_matrix
示例6: feat3
def feat3(train, test):
# valence info
train_valence, test_valence = feat1(train, test)
# tf idf info
train_cts, test_cts = feat2(train, test)
# combined info
train_matrix = Features.append_features([train_valence, train_cts])
test_matrix = Features.append_features([test_valence, test_cts])
return train_matrix, test_matrix
示例7: feat7
def feat7(train, test):
normal_train, train_pos = map(list, zip(*train))
normal_test, test_pos = map(list, zip(*test))
train_f5, test_f5 = feat5(normal_train, normal_test)
cter, train_cts = Features.keyPOSNGrams(train_pos, ["jj.*", "vb.*"], tf_idf = True, ngram_range = (1, 2), stop_words = 'english')
_, test_cts = Features.keyPOSNGrams(test_pos, ["jj.*", "vb.*"], vectorizer = cter, tf_idf= True, ngram_range = (1, 2), stop_words = 'english')
train_matrix = Features.append_features([train_f5, train_cts])
test_matrix = Features.append_features([test_f5, test_cts])
return train_matrix, test_matrix
示例8: feat7
def feat7(train, test):
# feature set 3
train_f5, test_f5 = feat5(train, test)
# punctuation
puncter, train_punct = Features.bagOfWordsSkLearn(train)
_, test_punct = Features.bagOfWordsSkLearn(test, vectorizer = puncter)
train_matrix = Features.append_features([train_f5, train_punct])
test_matrix = Features.append_features([test_f5, test_punct])
return train_matrix, test_matrix
示例9: count_labels
def count_labels(outpath):
tw_cts = Counter(Features.getY(tw))
blog_cts = Counter(Features.getY(blog))
cts = zip(["twitter+wiki", "blog"], [tw_cts, blog_cts])
# Write out to csv
with open(outpath, 'w') as labels_histo_file:
for src, counter in cts:
for k, v in counter.iteritems():
labels_histo_file.write("%s,%s,%d\n" % (src, k, v))
return 0
示例10: extra_features
def extra_features(train, test):
# uni and bigrams
state_info, train_ngrams = Features.wordCountsSkLearn(train, ngram_range = (1, 2), stop_words = 'english')
_, test_ngrams = Features.wordCountsSkLearn(test, vectorizer = state_info, ngram_range = (1, 2), stop_words = 'english')
# valence and punctuation
train_valence_punct, test_valence_punct = feat5(train, test)
# train matrix
train_matrix = Features.append_features([train_ngrams, train_valence_punct])
test_matrix = Features.append_features([test_ngrams, test_valence_punct])
return train_matrix, test_matrix
示例11: createDataLine
def createDataLine(context, block, leaveout=-1):
dataLine = [str(block[0].shotId) + "_" + str(block[0].beatId), str(block[0].shot)]
featureClassList = Features.getAllFeatureClasses()
context = Features.createBeatList(context, block)
for featureClass in featureClassList:
feature = featureClass(context, block)
dataLine += feature.getNumbers()
# activate to generate a human readable featureLine
#dataLine.append(feature.getText())
if leaveout >= 0:
dataLine.pop(leaveout)
return dataLine
示例12: getSingleFeatureLineFromFile
def getSingleFeatureLineFromFile(file, decisions, shot, leave_out_class=None):
"""
This is a less troublesome but slow method to get a featureLine.
"""
beatList, context = getContextAndBeatListFromFile(file)
blockList = coalesceBeats(beatList)
Features.initializeContextVars(context)
lastShotId, context, blockList = applyDecisionsToBeatscript(context, blockList,
decisions)
featureLine = getFeatureLine(context, blockList[len(decisions)], shot, lastShotId,
leave_out_class)
return featureLine
示例13: classify
def classify(data, weights, featureSet, algorithm):
length = Features.getLength(featureSet)
results = np.zeros(data.shape[0])
for i in range(data.shape[0]):
if algorithm == 1:
vector = Features.getVector(data[i,0], featureSet)
vector.append(length)
results[i] = predict_one(weights, vector, 0)
else:
vector = Features.getVector(data[i,0], featureSet)
results[i] = predict_one(weights, vector, length)
return results
示例14: train
def train(model, training, keys, pca_num=None):
if model == "1nn":
model = OneNN()
elif model == "rf":
model = makeRF()
training = SymbolData.normalize(training, 99)
f = Features.features(training)
pca = None
if (pca_num != None):
pca = sklearn.decomposition.PCA(n_components=pca_num)
pca.fit(f)
f = pca.transform(f)
model.fit(Features.features(training), SymbolData.classNumbers(training, keys))
return (model, pca)
示例15: createFeatureLines
def createFeatureLines(context, beatList, shot, leave_out_class=None):
"""
Returns the list of featureLines converted from the Beats in beatList
"""
featureLines = []
blockList = coalesceBeats(beatList)
Features.initializeContextVars(context)
lastShotId = -1
for block in blockList:
featureLines.append(
getFeatureLine(context, block, shot, lastShotId, leave_out_class))
context["BygoneBlocks"].append(block)
lastShotId = block[-1].shotId
return featureLines