本文整理汇总了Python中feature.Feature类的典型用法代码示例。如果您正苦于以下问题:Python Feature类的具体用法?Python Feature怎么用?Python Feature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Feature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Initialize
def Initialize(credentials=None, opt_url=None):
"""Initialize the EE library.
If this hasn't been called by the time any object constructor is used,
it will be called then. If this is called a second time with a different
URL, this doesn't do an un-initialization of e.g.: the previously loaded
Algorithms, but will overwrite them and let point at alternate servers.
Args:
credentials: OAuth2 credentials.
opt_url: The base url for the EarthEngine REST API to connect to.
"""
data.initialize(credentials, (opt_url + '/api' if opt_url else None), opt_url)
# Initialize the dynamically loaded functions on the objects that want them.
ApiFunction.initialize()
Element.initialize()
Image.initialize()
Feature.initialize()
Collection.initialize()
ImageCollection.initialize()
FeatureCollection.initialize()
Filter.initialize()
Geometry.initialize()
List.initialize()
Number.initialize()
String.initialize()
Date.initialize()
Dictionary.initialize()
_InitializeGeneratedClasses()
_InitializeUnboundMethods()
示例2: get_score
def get_score(self, msg):
Feature.extract(msg)
score = 0.0
for (f, w) in self.feature_weight.items():
if f in msg.feature:
score += msg.feature[f] * w
return score
示例3: draw
def draw(self, renderer):
### FIXME this should be made faster (C++ Module? How to deal with C++ linkage problems?)
### Sticking the vtkPoints objects in a cache would help somewhat but not on the first view.
### - Jack
if not self.drawn:
vtk_points = vtkPoints()
points = self.visualiser.getQuantityPoints(self.quantityName, dynamic=self.dynamic)
nPoints = len(points)
vtk_points.SetNumberOfPoints(nPoints)
setPoint = vtkPoints.SetPoint
for i in xrange(nPoints):
z = points[i] * self.zScale + self.offset
setPoint(vtk_points, i, self.visualiser.xPoints[i], self.visualiser.yPoints[i], z)
polyData = vtkPolyData()
polyData.SetPoints(vtk_points)
polyData.SetPolys(self.visualiser.vtk_cells)
mapper = vtkPolyDataMapper()
mapper.SetInput(polyData)
setValue = vtkFloatArray.SetValue
if hasattr(self.colour[0], '__call__'):
scalars = self.colour[0](self.visualiser.getQuantityDict())
nScalars = len(scalars)
vtk_scalars = vtkFloatArray()
vtk_scalars.SetNumberOfValues(nScalars)
for i in xrange(nScalars):
setValue(vtk_scalars, i, scalars[i])
polyData.GetPointData().SetScalars(vtk_scalars)
mapper.SetScalarRange(self.colour[1:3])
mapper.Update()
self.actor.SetMapper(mapper)
Feature.draw(self, renderer)
示例4: extract
def extract(self, data_set_name, part_num=1, part_id=0):
"""
Extract the feature from original data set
:param data_set_name: name of data set
:param part_num: number of partitions of data
:param part_id: partition ID which will be extracted
:return:
"""
# load data set from disk
data = pd.read_csv('%s/%s.csv' % (self.config.get('DEFAULT', 'source_pt'), data_set_name)).fillna(value="")
begin_id = int(1. * len(data) / part_num * part_id)
end_id = int(1. * len(data) / part_num * (part_id + 1))
# set feature file path
feature_pt = self.config.get('DEFAULT', 'feature_pt')
if 1 == part_num:
self.data_feature_fp = '%s/%s.%s.smat' % (feature_pt, self.feature_name, data_set_name)
else:
self.data_feature_fp = '%s/%s.%s.smat.%03d_%03d' % (feature_pt,
self.feature_name,
data_set_name,
part_num,
part_id)
feature_file = open(self.data_feature_fp, 'w')
feature_file.write('%d %d\n' % (end_id - begin_id, int(self.get_feature_num())))
# extract feature
for index, row in data[begin_id:end_id].iterrows():
feature = self.extract_row(row)
Feature.save_feature(feature, feature_file)
feature_file.close()
LogUtil.log('INFO',
'save features (%s, %s, %d, %d) done' % (self.feature_name, data_set_name, part_num, part_id))
示例5: dryer_data2
def dryer_data2(*feature_names):
# data[area][genus][(feature_values)] = langauge_count
data = {}
# Languages that all features have
languages = set()
g = Genealogy()
feature = Feature(feature_names[0])
for language in feature.languages():
languages.add(language.code)
for feature_name in feature_names:
feature = Feature(feature_name)
this_set = set()
for language in feature.languages():
this_set.add(language.code)
languages &= this_set
for language_code in languages:
language = g.find_language_by_code(language_code)
area = language.area
genus = language.genus.name
value = ','.join(v['description'] for v in sorted(language.features.values()))
data.setdefault(area, {})
data[area].setdefault(genus, {})
data[area][genus].setdefault(value, 0)
data[area][genus][value] += 1
return data
示例6: Initialize
def Initialize(credentials="persistent", opt_url=None):
"""Initialize the EE library.
If this hasn't been called by the time any object constructor is used,
it will be called then. If this is called a second time with a different
URL, this doesn't do an un-initialization of e.g.: the previously loaded
Algorithms, but will overwrite them and let point at alternate servers.
Args:
credentials: OAuth2 credentials. 'persistent' (default) means use
credentials already stored in the filesystem, or raise an explanatory
exception guiding the user to create those credentials.
opt_url: The base url for the EarthEngine REST API to connect to.
"""
if credentials == "persistent":
credentials = _GetPersistentCredentials()
data.initialize(credentials, (opt_url + "/api" if opt_url else None), opt_url)
# Initialize the dynamically loaded functions on the objects that want them.
ApiFunction.initialize()
Element.initialize()
Image.initialize()
Feature.initialize()
Collection.initialize()
ImageCollection.initialize()
FeatureCollection.initialize()
Filter.initialize()
Geometry.initialize()
List.initialize()
Number.initialize()
String.initialize()
Date.initialize()
Dictionary.initialize()
Terrain.initialize()
_InitializeGeneratedClasses()
_InitializeUnboundMethods()
示例7: init_train_data
def init_train_data(fnames, topics):
print ('[ init_train_data ] =================')
# amap
# key : aid
# value : attr[0] preferance, attr[1] aid , attr[2] aname
train_rank = []
for QID in range(len(topics)):
fname = fnames[QID]
topic = topics[QID]
amap = filter_data(fname)
fea = Feature(topic)
ext_aids = ZC.get_raw_rank(topic, EXT_TRAIN_A_SIZE)
print '[ init_train_data ] amap_1 size = %d ' %(len(amap))
for tid in ext_aids :
if not (tid in amap) :
amap[tid] = (0, tid, '')
print '[ init_train_data ] amap_2 size = %d ' %(len(amap))
for tid in amap :
fv = fea.get_feature_vector(tid)
#print ('[ init_train_data ] %d get feature vector ok.' %(tid))
train_rank.append( (int(amap[tid][0]), reform_vector(fv), QID) )
print '[ init_train_data ] topic : %s ok , train_rank_size = %d' %(topic, len(train_rank))
ZC.dump_cache()
with open('train_rank.dat' , 'w') as f :
pprint.pprint(train_rank, f)
return train_rank
示例8: __init__
def __init__(self,**kwargs):
u"""
:param framefilter: selected framenumber where we will
compute histogram
:type: array
"""
Feature.__init__(self,**kwargs)
示例9: predict
def predict(test_dir, xpath):
feature = Feature(test_dir + '/oracle.png', test_dir + '/test.html', xpath)
feature.process()
vecter = feature.output_binary()
print vecter
score = rank_bayes(vecter)
sorted_score = sorted(score.iteritems(), key=operator.itemgetter(1))
return sorted_score
示例10: test_can_enable_two_features
def test_can_enable_two_features(self):
feature2 = Feature("second_test_feature")
request = fake_request()
self.feature.enable(request)
feature2.enable(request)
self.assertTrue(self.feature.is_enabled(request))
self.assertTrue(feature2.is_enabled(request))
示例11: _weight_feature
def _weight_feature(self, msg):
Feature.extract(msg)
score = 0.0
for i in range(len(self.feature_name)):
f = self.feature_name[i]
w = self.w[i]
if f in msg.feature:
score += msg.feature[f] * w
return score
示例12: init_rerank_data
def init_rerank_data(aids , topic):
QID = 1
fea = Feature(topic)
rerank_data = []
for tid in aids :
fv = fea.get_feature_vector(tid)
print ('[ init_rerank_data ] %d get feature vector ok.' %(tid))
rerank_data.append( (tid, reform_vector(fv), QID) )
return rerank_data
示例13: set_enabled
def set_enabled(request):
f = Feature(request.POST['name'])
enabled = request.POST['enabled'] == 'True'
if enabled:
f.enable(request)
else:
f.disable(request)
return redirect("/feature/")
示例14: _test_polynomial
def _test_polynomial(self, polynomial):
data = range(10)
data = [float(d) for d in data]
targets = [d**polynomial for d in data]
data = [[d] for d in data]
feature = Feature(Objective.MINIMIZE, log_level=logging.WARN)
feature.optimize(data, targets)
assert feature.polynomial == polynomial, "{0} != {1}".format(feature.polynomial, polynomial)
示例15: __init__
def __init__(self, biodb, step_size=5, levels=[], name_hier=[]):
Feature.__init__(self, biodb= biodb)
self.step_size= step_size
if levels == []:
levels=[None]*3
self.levels= levels
if name_hier == []:
name_hier= [""]*3
self.name_hier= name_hier
self.links=[]