本文整理汇总了Python中experiment.Experiment类的典型用法代码示例。如果您正苦于以下问题:Python Experiment类的具体用法?Python Experiment怎么用?Python Experiment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Experiment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test
def test(self):
""" Test that every image is correctly recognized. """
Experiment.test(self)
start = time.time()
num_confused = 0.0
classifier = self.network.get_classifier()
i = 0
while self.image_iterator.has_next():
image, category, img_idx = self.image_iterator.next()
recognized = self.network.do_inference(numpy.array(image), category)
if not recognized:
active_cats = classifier.get_winning_category()
#print colored("Failed: " + category + " recognized as "+active_cats, 'red')
num_confused += 1
i += 1
if i % self.PRINT_INCR == 0: print "Iter:", i
confusion_rate = num_confused / float(i)
elapsed = (time.time() - start)
print "Testing time:", elapsed
print "Time per category:", (elapsed / i)
print colored("Testing complete", "green")
print colored("\nConfusion rate: " + str(confusion_rate), 'cyan')
开发者ID:kkansky,项目名称:and_or_images,代码行数:26,代码来源:kmeans_compression.py
示例2: run_experiment
def run_experiment(args):
""" Parallelizable method for computing experiments.
This method is used in parallel computation for running experiments in
parallel. Due to the nature of pickling, it must be declared globally,
because instance methods cannot be pickled.
"""
# args is a tuple, so that we can map over an array of tuples.
# see run_parallel_experiments()
params, param_name, val = args
params = params.copy()
params[param_name] = val
while True:
try:
start_time = time.clock()
exp = Experiment(**params)
exp.compute_informativeness()
break
except Exception:
traceback.print_exc()
elapsed_time = time.clock() - start_time
print "Experiment with val %s added in %0.2f seconds" % \
(str(val), elapsed_time)
return val, exp
开发者ID:thenovices,项目名称:transitive-trust-models,代码行数:28,代码来源:experiment_sets.py
示例3: train
def train(self):
""" Store a copy of every image in the iterator. """
Experiment.train(self)
start = time.time()
gabor = GaborRegion((144, 192), rotations=3,
initial_wavelength=3,
num_wavelengths=2)
# Regions = [ GaborRegion, AndRegion, OrRegion (classifier) ]
self.network = AndOrNetwork((144,192), num_regions=1,
input_region = gabor)
and_region = self.network.regions[1]
classifier = self.network.get_classifier()
i = 0
while self.image_iterator.has_next():
image, category, img_idx = self.image_iterator.next()
gabor.do_inference(numpy.array(image))
active_nodes = gabor.get_active_nodes()
pos = and_region.create_node((0,0), cxns = active_nodes)
classifier.create_node(category, pos)
i += 1
if i % self.PRINT_INCR == 0: print "Iter:", i
and_region.prepare_for_inference()
classifier.prepare_for_inference()
num_cxns = and_region.get_num_cxns() + classifier.get_num_cxns()
print "Number of connections:", num_cxns
elapsed = (time.time() - start)
print "Training time:", elapsed
print "Time per category:", (elapsed / i)
print colored("Training complete", "green")
开发者ID:kkansky,项目名称:and_or_images,代码行数:34,代码来源:brute_force.py
示例4: __init__
def __init__(self):
Experiment.__init__(self)
persistance.Dommable.__init__(self)
self.amplifiers = {'None':'bridge', 'Prana':'Prana', 'Milmega 1':'Milmega', 'Milmega 2':'Milmega'}
self.amplifier = EnumerateProperty('None',['Automatic'] + self.amplifiers.keys())
self.amplifier.changedTo.connect(self.setAmplifier)
开发者ID:houssem21,项目名称:emctestbench,代码行数:7,代码来源:transmittedpower.py
示例5: individualStrategies
def individualStrategies():
#allxVals = {1: range(4, 10, 5), 2: range(100, 111, 10)}
allxVals = {1: range(4, 101, 5), 2: range(100, 1001, 10)}
allPlayerTypes = {'Random Play': players.RandomPlayer,
'Honest Play': players.HonestPlayer,
'Minimum Guessing': players.MinimumGuessingPlayer,
'Constant Guessing': players.ConstantGuessPlayer,
'Mean Guessing': players.MeanGuessPlayer,
'Quantile Guessing': players.QuantileGuessPlayer,
}
allExperimentTypes = [2]
allStatistics = [2]
for statistic in allStatistics:
for experimentType in allExperimentTypes:
xVals = allxVals[experimentType]
for title, playerType in allPlayerTypes.items():
playerTypes = {playerType: 1.0}
savefile = title.replace(' ', '_')+str(experimentType)+str(statistic)+'.png'
print "Running "+savefile
exp = Experiment(xVals, playerTypes, experimentType, statistic)
yVals = exp.run()
print yVals
plotResults(exp, yVals, title, savefile)
print
开发者ID:tomsilver,项目名称:thesis,代码行数:27,代码来源:main.py
示例6: testQValueNetwork
def testQValueNetwork(startTurn=0, loopNum=1000, type=''):
agents = []
win_nums = {}
test_name = PLAYER_LIST[type][0]
test_filename = TEST[type]
if os.path.isfile(test_filename):
with open(test_filename, 'r') as f:
win_nums = pickle.load(f)
for i in range(0, 3):
playerName = PLAYER_LIST[type][i]
nw = NETWORK[type](playerName)
if playerName == test_name:
nw.loadNet(playerName, startTurn)
rfa = AGENT[type](playerName, nw)
agents.append(rfa)
env = RunFastEnvironment()
exp = Experiment(env, agents)
for i in range(loopNum):
if not win_nums.get(startTurn):
win_nums[startTurn] = {}
testHistory = exp.doTest(test_name)
for j in range(0,3):
playerName = PLAYER_LIST[type][j]
if not win_nums[startTurn].get(playerName):
win_nums[startTurn][playerName] = {'point': 0, 'win': 0}
win_nums[startTurn][playerName]['point'] += testHistory[playerName]
if testHistory['name'] == playerName:
win_nums[startTurn][playerName]['win'] += 1
with open(test_filename, 'w') as f:
pickle.dump(win_nums, f)
开发者ID:zydmayday,项目名称:runfast,代码行数:33,代码来源:main.py
示例7: altruism
def altruism(self, altruisticProbability, selfishProbability, altruismCost,
altruismBenefit, disease, harshness, numTicks):
"""
Runs an experiment of the Biology/Evolution/Altruism model.
:returns: The table output of the experiment.
"""
job = uuid4()
exp_path = '/tmp/%s/experiment.xml' % job
out_path = '/tmp/%s/out.csv' % job
params = {
'altruistic-probability': altruisticProbability,
'selfish-probability': selfishProbability,
'cost-of-altruism': altruismCost,
'benefit-from-altruism': altruismBenefit,
'disease': disease,
'harshness': harshness,
}
exp = Experiment(steps=numTicks, params=params)
exp.add_metric(color='pink').add_metric(color='green')
exp.write_xml(exp_path)
model = '%s/models/Sample Models/Biology/Evolution/Altruism.nlogo' % NETLOGO_HOME
self.call_experiment(model, exp_path, exp.name, out_path)
with open(out_path, 'r') as out_file:
return out_file.read()
开发者ID:similitude,项目名称:netlogo-sample-simmer,代码行数:29,代码来源:handler.py
示例8: train
def train(self):
""" Store a copy of every image in the iterator. """
Experiment.train(self)
start = time.time()
self.image_shape = (144, 192)
gabor = GaborRegion(self.image_shape, rotations=3,
initial_wavelength=3,
num_wavelengths=2)
# Regions = [ GaborRegion, AndRegion, OrRegion (classifier) ]
self.network = AndOrNetwork((144,192), num_regions=2,
input_region = gabor)
f1 = self.network.regions[1]
f2 = self.network.regions[2]
classifier = self.network.get_classifier()
self.gabor_acts = gabor.precompute_image_activations(self.image_iter)
windows = self.get_windows()
for window in windows:
self.network.prepare_for_inference(1)
elapsed = (time.time() - start)
total_cxns = 0
for i, r in enumerate(self.network.regions[1:]):
num_cxns = r.get_num_cxns()
print "Region %s cxns: %s" % (i, num_cxns)
total_cxns += num_cxns
print "Total connections:", total_cxns
print "Training time:", elapsed
print "Time per category:", (elapsed / i)
print colored("Training complete", "green")
def test(self):
""" Test that every image is correctly recognized. """
Experiment.test(self)
start = time.time()
classifier = self.network.get_classifier()
i = 0
while self.image_iterator.has_next():
image, category = self.image_iterator.next()
recognized = self.network.do_inference(numpy.array(image), category)
if not recognized:
active_cats = classifier.get_active_categories()
print colored("Failed: " + category + " recognized as "+repr(active_cats), 'red')
i += 1
if i % self.PRINT_INCR == 0: print "Iter:", i
elapsed = (time.time() - start)
print "Testing time:", elapsed
print "Time per category:", (elapsed / i)
print colored("Testing complete", "green")
开发者ID:kkansky,项目名称:and_or_images,代码行数:59,代码来源:window_grid.py
示例9: __init__
def __init__(self, output_path=None, linewidth=1.5):
e = Experiment(output_path)
self.linewidth = linewidth
if output_path is None:
self.output_path = os.path.join(e.final_output_path, self.default_plots_path_addon)
else:
self.output_path = output_path
e.makedir(self.output_path)
开发者ID:kevinbache,项目名称:caffe_cluster_experiments,代码行数:8,代码来源:plotters.py
示例10: __init__
def __init__(self):
Experiment.__init__(self)
self.passCriterion = ExperimentSlot(parent=self,defaultValue='VoltageCriterion')
self.transmittedPower = ExperimentSlot(parent=self,defaultValue='TransmittedPower')
self.powerMinimum = Property(Power(-30.,'dBm'),changedSignal=self.settingsChanged)
self.powerMaximum = Property(Power(+15.,'dBm'),changedSignal=self.settingsChanged)
self.frequencies = SweepRange(Frequency(150e3),Frequency(1500e6),21,changedSignal=self.settingsChanged)
开发者ID:houssem21,项目名称:emctestbench,代码行数:8,代码来源:dpi.py
示例11: load_code_from_file
def load_code_from_file(self, filename):
experiment = Experiment()
experiment.load_code_from_file(filename)
self.project.experiments.append(experiment)
self.project.active_experiment = experiment
self.update_functions_UI(self.project.active_experiment.exec_model.statements)
self.update_functions_context(self.project.active_experiment,
self.project.active_experiment.exec_model.statements)
开发者ID:eraldop,项目名称:blockcanvas,代码行数:8,代码来源:app.py
示例12: main
def main():
try:
folder_name = sys.argv[1]
experiment = Experiment(folder_name)
except IndexError:
experiment = Experiment()
experiment.retrieve_data()
parser = FeatureParser()
parser.initialize_matrix(experiment.raw_data_set)
parser.print_global_names()
开发者ID:RishiSadhir,项目名称:Email_Classification,代码行数:10,代码来源:test_driver.py
示例13: quantileStrategy
def quantileStrategy():
xVals = [10]
playerTypes = {players.QuantileGuessPlayer: 1.0}
experimentType = 2
statistic = 1
title = "Quantile Guessing"
exp = Experiment(xVals, playerTypes, experimentType, statistic)
yVals = exp.run()
print yVals
开发者ID:tomsilver,项目名称:thesis,代码行数:10,代码来源:main.py
示例14: main
def main():
data = Experiment()
data.retrieve_data()
emails = []
for example in data.raw_data_set:
emails.append(Email(example[1]))
i = 1
with open("dates.csv", "w") as dates_file:
for email in emails:
dates_file.write(str(i) + ","+str(email.get_hour()) + "\n")
开发者ID:RishiSadhir,项目名称:Email_Classification,代码行数:11,代码来源:generate_dates.py
示例15: runExperiment
def runExperiment(self):
try:
e = Experiment(int(self.sampleEntry.get()), int(self.populationEntry.get()),
int(self.numSuccessesEntry.get()))
e.perform(int(self.numTrialsEntry.get()))
self.drawResult(e.results, 0)
except AssertionError as error:
tkMessageBox.showerror('Data Entry Error', error.args[0])
except ValueError as error:
tkMessageBox.showerror('Data Entry Error', 'Please make sure each field is filled out'
+ ' and only contains numbers')
开发者ID:Gordon-C,项目名称:Hypergeometric-Simulator,代码行数:11,代码来源:hypergeom.py
示例16: run_model
def run_model():
experiment = Experiment(model = "../experiments/model-guthrie.json",
task = "../experiments/task-guthrie.json",
result = "data/test-experiment-guthrie.npy",
report = "data/test-experiment-guthrie.txt",
n_session = 8, n_block = 1, seed = 1,
rootdir=os.path.dirname(__file__)) # for unittest and nosetests.
records = experiment.run(session, save=True, force=True, parse=False)
records = np.squeeze(records)
mean = np.mean(records["best"], axis=0)[-1]
assert mean >= 0.85
开发者ID:rougier,项目名称:basal-ganglia,代码行数:11,代码来源:test_reproduce.py
示例17: main
def main():
if len(sys.argv) < 2:
sys.stderr.write("Need to pass user folder name\n")
return
folder_name = sys.argv[1]
experiment = Experiment(folder_name)
experiment.retrieve_data()
parser = FeatureParser(experiment.raw_data_set)
(names, secondary_names, body_text) = parser.get_mail_elements("data/beck-s/moscoso__mike/4.")
print names
print secondary_names
print body_text
开发者ID:RishiSadhir,项目名称:Email_Classification,代码行数:13,代码来源:test_experiment.py
示例18: load
def load(self, dirname):
""" Loads the project from the given directory. The existing state
of the project is completely modified.
"""
# TODO: We should formalize this dependency at some point and move
# this import to the top level
from configobj import ConfigObj
if dirname == "":
raise IOError("Cannot load project from empty path.")
elif not os.path.isdir(dirname):
raise IOError("Cannot find directory: " + dirname)
filename = abspath(join(dirname, self.PROJECT_FILE_NAME))
if not os.path.isfile(filename):
raise IOError('Cannot load %s from project directory "%s".' % \
(self.PROJECT_FILE_NAME, dirname))
# Every project is saved as a text ConfigObj file that describes
# the name and location of the real data files.
configspec = ConfigObj(self.CONFIG_SPEC, list_values=False)
config = ConfigObj(filename, configspec=configspec)
contexts = []
for context_config in config["Contexts"].values():
ctx = DataContext.load(join(dirname, context_config["file"]))
ctx.name = context_config["name"]
contexts.append(ctx)
self.contexts = contexts
experiments = []
if hasattr(scripting, "app"):
app = scripting.app
else:
app = None
for exp_config in config["Experiments"].values():
experiment = Experiment()
exp_dir = join(dirname, exp_config["save_dir"])
experiment.load_from_config(exp_config, exp_dir, project=self)
experiments.append(experiment)
self.experiments = experiments
proj_config = config["Project"]
if proj_config.has_key("active_experiment"):
self.active_experiment = self.find_experiment(proj_config["active_experiment"])
# Update Project Save Path
self.project_save_path = dirname
return
开发者ID:enthought,项目名称:blockcanvas,代码行数:50,代码来源:project.py
示例19: run
def run(agent_count, duration):
for s in STRATEGIES:
test = None
if 'mixed' in s:
test = Experiment(agent_count, s, duration, mixed_strategies=(s.split(' ')[1], s.split(' ')[2]))
elif 'random-tsp' in s:
test = Experiment(agent_count, s, duration, s.split(' ')[1])
else:
test = Experiment(agent_count, s, duration)
test.start_game()
average_idle_results[s].append(test.average_idle)
max_idle_results[s].append(test.max_idle)
exploration_time_results[s].append(test.exploration_time)
alerts_detected_results[s].append(test.normalized_alerts)
开发者ID:butterfieldj,项目名称:patrol_simulator,代码行数:14,代码来源:run_all_sequential.py
示例20: __init__
def __init__(self):
Experiment.__init__(self)
self.transmittedPower = ExperimentSlot(parent=self,defaultValue='TransmittedPower')
self.measurement = ExperimentSlot(parent=self,defaultValue='ReceivedPower') #,defaultValue='VoltageCriterion')
self.generatorPower = Property(Power(+10,'dBm'),changedSignal=self.settingsChanged)
self.generatorFrequency = ScalarProperty(Frequency(1,'GHz'),changedSignal=self.settingsChanged,minimum=Frequency(1,'Hz'))
self.startPosition = ScalarProperty(Position(22,'mm'),changedSignal=self.settingsChanged)
self.stopPosition = ScalarProperty(Position(-24,'mm'),changedSignal=self.settingsChanged)
self.xPosition = ScalarProperty(Position(122,'mm'),changedSignal=self.settingsChanged)
self.zPosition = ScalarProperty(Position(84,'mm'),changedSignal=self.settingsChanged)
self.numberOfSteps = ScalarProperty(Integer(11),minimum=Integer(1),maximum=Integer(10001),changedSignal=self.settingsChanged)
开发者ID:eseo-emc,项目名称:emctestbench,代码行数:14,代码来源:nearfieldscan.py
注:本文中的experiment.Experiment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论