weka.core.ProtectedProperties Java Examples

The following examples show how to use weka.core.ProtectedProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LHSSampler.java    From bestconf with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args){
	ArrayList<Attribute> atts = new ArrayList<Attribute>();
	
	/*Properties p1 = new Properties();
	p1.setProperty("range", "[0,1]");
	ProtectedProperties prop1 = new ProtectedProperties(p1);*/
	
	Properties p2 = new Properties();
	p2.setProperty("range", "[321,1E9]");
	ProtectedProperties prop2 = new ProtectedProperties(p2);
	
	ArrayList<String> attVals = new ArrayList<String>();
	for (int i = 0; i < 5; i++)
	      attVals.add("val" + (i+1));
	
	//atts.add(new Attribute("att1", prop1));
	atts.add(new Attribute("att2", prop2));
	//atts.add(new Attribute("att3", attVals));
	//Instances data = LHSInitializer.getMultiDimContinuous(atts, 10, false);
	//Instances data = LHSInitializer.getMultiDim(atts, 10, false);
	LHSSampler sampler = new LHSSampler();
	Instances data = sampler.sampleMultiDimContinuous(atts, 1, false);
	
	System.out.println(data);
}
 
Example #2
Source File: LHSInitializer.java    From bestconf with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args){
	ArrayList<Attribute> atts = new ArrayList<Attribute>();
	
	/*Properties p1 = new Properties();
	p1.setProperty("range", "[0,1]");
	ProtectedProperties prop1 = new ProtectedProperties(p1);*/
	
	Properties p2 = new Properties();
	p2.setProperty("range", "[321,1E9]");
	ProtectedProperties prop2 = new ProtectedProperties(p2);
	
	ArrayList<String> attVals = new ArrayList<String>();
	for (int i = 0; i < 5; i++)
	      attVals.add("val" + (i+1));
	
	//atts.add(new Attribute("att1", prop1));
	atts.add(new Attribute("att2", prop2));
	//atts.add(new Attribute("att3", attVals));
	//Instances data = LHSInitializer.getMultiDimContinuous(atts, 10, false);
	//Instances data = LHSInitializer.getMultiDim(atts, 10, false);
	Instances data = LHSInitializer.getMultiDimContinuous(atts, 1, false);
	
	System.out.println(data);
}
 
Example #3
Source File: PerformanceKnowledgeBase.java    From AILibs with GNU Affero General Public License v3.0 6 votes vote down vote up
private Attribute getAttribute(final ComponentInstance ci, final Parameter parameter) {
	IParameterDomain domain = parameter.getDefaultDomain();
	if (domain instanceof CategoricalParameterDomain) {
		CategoricalParameterDomain catDomain = (CategoricalParameterDomain) domain;
		return new Attribute(ci.getComponent().getName() + "::" + parameter.getName(), Arrays.asList(catDomain.getValues()));
	} else if (domain instanceof NumericParameterDomain) {
		NumericParameterDomain numDomain = (NumericParameterDomain) domain;
		String range = "[" + numDomain.getMin() + "," + numDomain.getMax() + "]";
		Properties prop = new Properties();
		prop.setProperty("range", range);
		ProtectedProperties metaInfo = new ProtectedProperties(prop);
		return new Attribute(ci.getComponent().getName() + "::" + parameter.getName(), metaInfo);
	} else {
		return null;
	}
}
 
Example #4
Source File: DDSSampler.java    From bestconf with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args){
	ArrayList<Attribute> atts = new ArrayList<Attribute>();
	
	Properties p1 = new Properties();
	p1.setProperty("range", "[0,1]");
	ProtectedProperties prop1 = new ProtectedProperties(p1);
	
	Properties p2 = new Properties();
	p2.setProperty("range", "[321,1E9]");
	ProtectedProperties prop2 = new ProtectedProperties(p2);
	
	Properties p3 = new Properties();
	p3.setProperty("range", "[1,30]");
	ProtectedProperties prop3 = new ProtectedProperties(p3);
	
	ArrayList<String> attVals = new ArrayList<String>();
	for (int i = 0; i < 5; i++)
	      attVals.add("val" + (i+1));
	
	atts.add(new Attribute("att1", prop1));
	atts.add(new Attribute("att2", prop2));
	atts.add(new Attribute("att3", prop3));
	//atts.add(new Attribute("att4", attVals));
	//Instances data = LHSInitializer.getMultiDimContinuous(atts, 10, false);
	//Instances data = LHSInitializer.getMultiDim(atts, 10, false);
	DDSSampler sampler = new DDSSampler(3);
	
	sampler.setCurrentRound(0);
	Instances data = sampler.sampleMultiDimContinuous(atts, 2, false);
	System.out.println(data);
	
	sampler.setCurrentRound(01);
	data = sampler.sampleMultiDimContinuous(atts, 2, false);
	System.out.println(data);
	
	sampler.setCurrentRound(2);
	data = sampler.sampleMultiDimContinuous(atts, 2, false);
	System.out.println(data);
}
 
Example #5
Source File: ConfigSampler.java    From bestconf with Apache License 2.0 4 votes vote down vote up
private static ArrayList<Attribute> scaleDownNeighbordists(Instances previousSet, Instance center){
	ArrayList<Attribute> localAtts = new ArrayList<Attribute>();
	int attNum = center.numAttributes();
	
	int pos = -1;
	if(previousSet.attribute(PerformanceAttName)!=null)
		pos = previousSet.attribute(PerformanceAttName).index();
	
	//traverse each dimension
	Enumeration<Instance> enu;
	double[] minDists = new double[2];
	double val;
	for(int i=0;i<attNum;i++){
		if(i==pos)
			continue;
		
		enu = previousSet.enumerateInstances();
		minDists[0] = 1-Double.MAX_VALUE;
		minDists[1] = Double.MAX_VALUE;
		
		while(enu.hasMoreElements()){
			Instance ins = enu.nextElement();
			if(!ins.equals(center)){
				val = ins.value(i)-center.value(i);
				if(val<0)
					minDists[0] = Math.max((double)((int)((ins.value(i)-center.value(i))*1000))/1000.0, minDists[0]);
				else
					minDists[1] = Math.min((double)((int)((ins.value(i)-center.value(i))*1000))/1000.0, minDists[1]);
			}
		}
		
		//now we set the range
		Properties p1 = new Properties();
		double upper = center.value(i)+minDists[1], lower=center.value(i)+minDists[0];
		
		TreeSet<Double> detourSet = new TreeSet<Double>();
		detourSet.add(upper);
		detourSet.add(lower);
		detourSet.add(previousSet.attribute(i).getUpperNumericBound());
		detourSet.add(previousSet.attribute(i).getLowerNumericBound());
		switch(detourSet.size()){
		case 1:
			upper=lower=detourSet.first();
			break;
		case 2:
			upper = detourSet.last();
			lower = detourSet.first();
			break;
		case 3:
			upper=lower=detourSet.higher(detourSet.first());
			break;
		default://case 4:
			upper=detourSet.lower(detourSet.last());
			lower=detourSet.higher(detourSet.first());
			break;
		}
		
		p1.setProperty("range", "["+String.valueOf(lower)+","+String.valueOf(upper)+"]");
		ProtectedProperties prop1 = new ProtectedProperties(p1);
		
		localAtts.add(new Attribute(previousSet.attribute(i).name(), prop1));
	}
	
	return localAtts;
}
 
Example #6
Source File: ConfigSampler.java    From bestconf with Apache License 2.0 4 votes vote down vote up
private static ArrayList<Attribute> scaleDownMindists(Instances previousSet, Instance center){
	ArrayList<Attribute> localAtts = new ArrayList<Attribute>();
	int attNum = center.numAttributes();
	
	int pos = previousSet.attribute(PerformanceAttName).index();
	
	//traverse each dimension
	Enumeration<Instance> enu;
	double minDis;
	for(int i=0;i<attNum;i++){
		if(i==pos)
			continue;
		
		enu = previousSet.enumerateInstances();
		minDis = Double.MAX_VALUE;
		
		while(enu.hasMoreElements()){
			Instance ins = enu.nextElement();
			if(!ins.equals(center))
				minDis = Math.min((double)((int)(Math.abs(ins.value(i)-center.value(i))*1000))/1000.0, minDis);
		}
		
		//now we set the range
		Properties p1 = new Properties();
		double upper = center.value(i)+minDis, lower=center.value(i)-minDis;
		
		TreeSet<Double> detourSet = new TreeSet<Double>();
		detourSet.add(upper);
		detourSet.add(lower);
		detourSet.add(previousSet.attribute(i).getUpperNumericBound());
		detourSet.add(previousSet.attribute(i).getLowerNumericBound());
		switch(detourSet.size()){
		case 1:
			upper=lower=detourSet.first();
			break;
		case 2:
			upper = detourSet.last();
			lower = detourSet.first();
			break;
		case 3:
			upper=lower=detourSet.higher(detourSet.first());
			break;
		default://case 4:
			upper=detourSet.lower(detourSet.last());
			lower=detourSet.higher(detourSet.first());
			break;
		}
		
		p1.setProperty("range", "["+String.valueOf(lower)+","+String.valueOf(upper)+"]");
		ProtectedProperties prop1 = new ProtectedProperties(p1);
		
		localAtts.add(new Attribute(previousSet.attribute(i).name(), prop1));
	}
	
	return localAtts;
}
 
Example #7
Source File: BestConf.java    From bestconf with Apache License 2.0 4 votes vote down vote up
public static ArrayList<Attribute> scaleDownDetour(Instances previousSet, Instance center){
	ArrayList<Attribute> localAtts = new ArrayList<Attribute>();
	int attNum = center.numAttributes();
	
	int pos = previousSet.attribute(PerformanceAttName).index();
	
	//traverse each dimension
	Enumeration<Instance> enu;
	double minDis;
	for(int i=0;i<attNum;i++){
		if(i==pos)
			continue;
		
		enu = previousSet.enumerateInstances();
		minDis = Double.MAX_VALUE;
		
		while(enu.hasMoreElements()){
			Instance ins = enu.nextElement();
			if(!ins.equals(center))
				minDis = Math.min((double)((int)(Math.abs(ins.value(i)-center.value(i))*100))/100.0, minDis);
		}
		
		//now we set the range
		Properties p1 = new Properties();
		double upper = center.value(i)+minDis, lower=center.value(i)-minDis;
		
		TreeSet<Double> detourSet = new TreeSet<Double>();
		detourSet.add(upper);
		detourSet.add(lower);
		detourSet.add(previousSet.attribute(i).getUpperNumericBound());
		detourSet.add(previousSet.attribute(i).getLowerNumericBound());
		switch(detourSet.size()){
		case 1:
			upper=lower=detourSet.first();
			break;
		case 2:
			upper = detourSet.last();
			lower = detourSet.first();
			break;
		case 3:
			upper=lower=detourSet.higher(detourSet.first());
			break;
		default://case 4:
			upper=detourSet.lower(detourSet.last());
			lower=detourSet.higher(detourSet.first());
			break;
		}
		
		p1.setProperty("range", "["+String.valueOf(lower)+","+String.valueOf(upper)+"]");
		ProtectedProperties prop1 = new ProtectedProperties(p1);
		
		localAtts.add(new Attribute(previousSet.attribute(i).name(), prop1));
	}
	
	return localAtts;
}