@Before public void setUp() { amazonEC2Client = EasyMock.createMock(AmazonEC2Client.class); describeInstancesResult = EasyMock.createMock(DescribeInstancesResult.class); reservation = EasyMock.createMock(Reservation.class); instance = new Instance() .withInstanceId(INSTANCE_ID) .withLaunchTime(new Date()) .withImageId(AMI_ID) .withPrivateIpAddress(IP); managementConfig = new SimpleWorkerProvisioningConfig().setWorkerPort(8080).setWorkerVersion(""); }
public Instance unmarshall(StaxUnmarshallerContext context) throws Exception { Instance instance = new Instance(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1;
Instance[] a = new Instance[5]; for (int i == 0; i < a.length; i++) { // first create your instance a[i] = new Instance(); // don't know if this is a valid constructor // and only *then* can you use it a[i].setAttribute(i); a[i].setLabel(i % 2 == 0); }
synchronized (instanceMutex) { final Instance no = new Instance(); while (no.getInstances() > 0) { // this check will need to be synchronized as well instanceMutex.wait(); } // and only increment `no` once you've made a successful check. no.incrementInstance(); }
if(instance == null){ instance = new Instance(); } return instance
synchronized (instanceMutex) { // each thread will make its own instance here final Instance no = new Instance();
private static Instance INSTANCE = new Instance();
synchronized (instanceMutex) { final Instance no = new Instance(); if (no.getInstances() > 0) { instanceMutex.wait(); } else { no.incrementInstance(); } try { // do something } finally { if (no.Instances() > 0) { no.decementInstance(); } instanceMutex.notify(); } }
String str="123/false" String[] ss = str.split("/"); Object[] value = new Object[ss.length]; // Conversion String to int, first parameter value[0] = Integer.parseInt(ss[0]); // Conversion String to boolean, second parameter value[1] = Boolean.parseBoolean(ss[1]); method.invoke(new Instance(), value);
//assuming we already have arff loaded in a variable called dataset Instance newInstance = new Instance(); for(int i = 0 ; i < dataset.numAttributes() ; i++) { newInstance.setValue(i , value); //i is the index of attribute //value is the value that you want to set } //add the new instance to the main dataset at the last position dataset.add(newInstance); //repeat as necessary
Instance retrieve = new Instance() method doSomething() { retrievedVal = retrieve.retrieveFromDB(something) return transform(retrievedVal) }
//assuming we already have arff loaded in a variable called dataset Instance newInstance = new Instance(); for(int i = 0 ; i < dataset.numAttributes() ; i++) { newInstance.setValue(i , value); //i is the index of attribute //value is the value that you want to set } //add the new instance to the main dataset at the last position dataset.add(newInstance); //repeat as necessary
Instance instance = new Instance("https://blah.service-now.com", "username", "password"); GlideFilter filter = new GlideFilter("category=network^active=true"); GlideRecordIterator iter = instance.table("incident"). bulkFetcher().setFilter(filter).getAllRecords().iterator(); while (iter.hasNext()) { GlideRecord rec = iter.next(); System.out.println( rec.getField("number") + " " + rec.getField("short_description")); }
int numAttributes = trainHeader.numAttributes(); double[] vals = new double[numAttributes]; for (int i = 0; i < numAttributes - 1; i++) { Attribute attribute = trainHeader.attribute(i); //If your attribute is nominal or string: double value = attribute.indexOfValue(myStrVal); //get myStrVal from your source //If your attribute is numeric double value = myNumericVal; //get myNumericVal from your source vals[i] = value; } vals[numAttributes] = Instance.missingValue(); Instance instance = new Instance(1.0, vals); instance.setDataset(trainHeader); return instance;
Instance inst = new Instance(4); <-- Adjust number of instances you want to add. inst.setValue(trainData.attribute(0), age); inst.setValue(trainData.attribute(1), administrativeGenderCode); inst.setValue(trainData.attribute(2), zipCode); inst.setValue(trainData.attribute(3), race); // inst.setValue(trainData.attribute(4), "H2034"); <-- Do not add the instance you want to classify.
private Instance makeInstance(Instance i) { Instance instance = new Instance(2); // two attributes Attribute messageAttribute = dataset.attribute("Msg"); instance.setValue(messageAttribute, messageAttribute.addStringValue(getMsg(i))); instance.setDataset(this.dataset); instance.setClassValue(getClassValue(i)); return instance }
// Msg: String, Class: String private Instance makeInstance(String text, String classValue) { Instance instance = new Instance(2); // two attributes Attribute messageAttribute = data.attribute("Msg"); instance.setValue(messageAttribute, messageAttribute.addStringValue(text)); instance.setClassValue(classValue); instance.setDataset(this.dataset); return instance; }
@Test public void testEc2Instance() throws IOException { Instance instance = new Instance(); instance.setInstanceId("i-123456"); instance.setTags(Lists.newArrayList(new Tag("foo", "bar"), new Tag("fizz", "buzz"))); JsonNode n = new JsonConverter().toJson(instance); Assertions.assertThat(n.path("aws_instanceId").asText()).isEqualTo("i-123456"); Assertions.assertThat(n.path("aws_tag_foo").asText()).isEqualTo("bar"); Assertions.assertThat(n.path("aws_tag_fizz").asText()).isEqualTo("buzz"); logger.info("{}", mapper.writerWithDefaultPrettyPrinter().writeValueAsString(n)); }
public Instance unmarshall(StaxUnmarshallerContext context) throws Exception { Instance instance = new Instance(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1;