本文整理汇总了Python中Features.features方法的典型用法代码示例。如果您正苦于以下问题:Python Features.features方法的具体用法?Python Features.features怎么用?Python Features.features使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Features
的用法示例。
在下文中一共展示了Features.features方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: train
# 需要导入模块: import Features [as 别名]
# 或者: from Features import features [as 别名]
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)
示例2: classifyExpression
# 需要导入模块: import Features [as 别名]
# 或者: from Features import features [as 别名]
def classifyExpression(expression, keys, model, pca, renormalize=True):
symbs = expression.symbols
if renormalize:
symbs = SymbolData.normalize(symbs, 99)
f = Features.features(symbs)
if (len (symbs) == 0):
print(expression.name, " has no valid symbols!")
return ([], [])
if (pca != None):
f = pca.transform(f)
pred = model.predict(f)
assert (max(pred) < len(keys))
f = (lambda p: keys[p])
expression.classes = map (f, pred)
return (NP.array(SymbolData.classNumbers(symbs, keys)), pred)
示例3: main
# 需要导入模块: import Features [as 别名]
# 或者: from Features import features [as 别名]
def main(argv=None):
if argv is None:
argv = sys.argv[1:] #dirty trick to make this convenient in the interpreter.
if (len (argv) < 3 or len (argv) > 4):
print(("bad number of args:" , len(argv)))
print (usage)
else:
if (len ( argv ) == 3):
exprs, keys = SymbolData.unpickleSymbols(argv[2])
else:
exprs = SymbolData.readInkmlDirectory(argv[2], argv[3])
keys = SymbolData.defaultClasses
if (argv[0] == "-nn" ):
model = Classification.OneNN()
elif (argv[0] == "-rf" ):
model = Classification.makeRF()
elif (argv[0] == "-et" ):
model = Classification.makeET()
else:
with open(argv[0], 'rb') as f:
model = pickle.load(f)
#this had better actually be a sklearn model or the equivelent.
#things will break in ways that are hard for me to test for if it isn't.
symbs = SymbolData.allSymbols(exprs)
trained, pca = Classification.train(model, symbs, keys)
print ("Done training.")
if False:
f = Features.features(symbs)
if (pca != None):
f = pca.transform(f)
pred = model.predict(f)
print( "Accuracy on training set : ", accuracy_score(SymbolData.classNumbers(symbs, keys), pred))
#joblib.dump((trained, pca), argv[2])
with open(argv[1], 'wb') as f:
pickle.dump((trained, pca, keys), f, pickle.HIGHEST_PROTOCOL)
示例4: print
# 需要导入模块: import Features [as 别名]
# 或者: from Features import features [as 别名]
# I = Features.features(symbol)
# i+=1
#7989,12287,12288,23126,23127 test.dat
# 2467,3121,22071,22072,22731,46263 train.dat
# Without vertical repositioning
#6432,6433
i=0
for symbol in symbols[0:]:
print(i)
I = Features.symbolFeatures(symbol)
i+=1
### Save FKI Testing features
#f = Features.features(symbols)
#Features.pickleFeatures(f,"FKIFeat_Test.dat")
### Save FKI Training features
#f = Features.features(symbols)
#Features.pickleFeatures(f,"FKIFeat_Train.dat")
#feat = Features.unpickleFeatures("FKIFeat_Train.dat")
### Save RWTH features
f = Features.features(symbols)
Features.pickleFeatures(f,"RWTHFeat_Train.dat")
### Save Statisticla features
#f = Features.features(symbols)
#Features.pickleFeatures(f,"StatFeat_Test.dat")