本文整理汇总了Java中weka.core.Attribute.getLowerNumericBound方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.getLowerNumericBound方法的具体用法?Java Attribute.getLowerNumericBound怎么用?Java Attribute.getLowerNumericBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.core.Attribute
的用法示例。
在下文中一共展示了Attribute.getLowerNumericBound方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uniBoundsGeneration
import weka.core.Attribute; //导入方法依赖的package包/类
private static void uniBoundsGeneration(double[] bounds, Attribute crntAttr, int sampleSetSize){
bounds[0] = crntAttr.getLowerNumericBound();
bounds[sampleSetSize] = crntAttr.getUpperNumericBound();
double pace = (bounds[sampleSetSize] - bounds[0])/sampleSetSize;
for(int j=1;j<sampleSetSize;j++){
bounds[j] = bounds[j-1] + pace;
}
}
示例2: getMultiDim
import weka.core.Attribute; //导入方法依赖的package包/类
/**
* Assumptions:(1)Numberic is continuous and has lower/upper bounds; (2) Nominals have domains permutable
*
* @param useMid true if to use the middle point of a subdomain, false if to use a random point within a subdomain
*/
private static Instances getMultiDim(ArrayList<Attribute> atts, int sampleSetSize, boolean useMid){
int L = Math.min(7, Math.max(sampleSetSize, atts.size()));//7 is chosen for no special reason
double maxMinDist = 0, crntMinDist;//work as the threshold to select the sample set
ArrayList<Integer>[] setWithMaxMinDist=null;
//generate L sets of sampleSetSize points
for(int i=0; i<L; i++){
ArrayList<Integer>[] setPerm = generateOneSampleSet(sampleSetSize, atts.size());
//compute the minimum distance minDist between any sample pair for each set
crntMinDist = minDistForSet(setPerm);
//select the set with the maximum minDist
if(crntMinDist>maxMinDist){
setWithMaxMinDist = setPerm;
maxMinDist = crntMinDist;
}
}
//generate and output the set with the maximum minDist as the result
//first, divide the domain of each attribute into sampleSetSize equal subdomain
double[][] bounds = new double[atts.size()][sampleSetSize+1];//sampleSetSize+1 to include the lower and upper bounds
Iterator<Attribute> itr = atts.iterator();
Attribute crntAttr;
double pace;
for(int i=0;i<bounds.length;i++){
crntAttr = itr.next();
if(crntAttr.isNumeric()){
bounds[i][0] = crntAttr.getLowerNumericBound();
bounds[i][sampleSetSize] = crntAttr.getUpperNumericBound();
pace = (crntAttr.getUpperNumericBound() - crntAttr.getLowerNumericBound())/sampleSetSize;
for(int j=1;j<sampleSetSize;j++){
bounds[i][j] = bounds[i][j-1] + pace;
}
}else{//crntAttr.isNominal()
if(crntAttr.numValues()>=sampleSetSize){
//randomly select among the set
for(int j=0;j<=sampleSetSize;j++)
bounds[i][j] = uniRand.nextInt(crntAttr.numValues());//the position of one of the nominal values
}else{
//first round-robin
int lastPart = sampleSetSize%crntAttr.numValues();
for(int j=0;j<sampleSetSize-lastPart;j++)
bounds[i][j] = j%crntAttr.numValues();
//then randomly select
for(int j=sampleSetSize-lastPart;j<=sampleSetSize;j++)
bounds[i][j] = uniRand.nextInt(crntAttr.numValues());
}
}//nominal attribute
}//get all subdomains
//second, generate the set according to setWithMaxMinDist
Instances data = new Instances("InitialSetByLHS", atts, sampleSetSize);
for(int i=0;i<sampleSetSize;i++){
double[] vals = new double[atts.size()];
for(int j=0;j<vals.length;j++){
if(atts.get(j).isNumeric()){
vals[j] = useMid?
(bounds[j][setWithMaxMinDist[j].get(i)]+bounds[j][setWithMaxMinDist[j].get(i)+1])/2:
bounds[j][setWithMaxMinDist[j].get(i)]+
(
(bounds[j][setWithMaxMinDist[j].get(i)+1]-bounds[j][setWithMaxMinDist[j].get(i)])*uniRand.nextDouble()
);
}else{//isNominal()
vals[j] = bounds[j][setWithMaxMinDist[j].get(i)];
}
}
data.add(new DenseInstance(1.0, vals));
}
//third, return the generated points
return data;
}
示例3: flexibleBoundsGeneration
import weka.core.Attribute; //导入方法依赖的package包/类
private static void flexibleBoundsGeneration(double[] bounds, Attribute crntAttr, int sampleSetSize){
int howGen = 0;//div
int step, crntStep;
double pace;
bounds[0] = crntAttr.getLowerNumericBound();
bounds[sampleSetSize] = crntAttr.getUpperNumericBound();
pace = (bounds[sampleSetSize] - bounds[0])/sampleSetSize;
crntStep = bounds[0]>1?(int)Math.log10(bounds[sampleSetSize] / bounds[0]):(int)Math.log10(bounds[sampleSetSize]);
if(crntStep>0)
step = sampleSetSize/crntStep;//num of points drawn after the multiplication of 10
else
step = 11;//anything larger than 10
if(sampleSetSize<crntStep){
howGen = 3;
}else if(0<step && step <10)//each hierarchy has fewer than 10 points
howGen = 1;
else if((bounds[0]>1 && (int)Math.log10(pace/bounds[0])> BigStepPower) ||
(bounds[0]<1 && (int)Math.log10(pace)> BigStepPower) )//a big first step
howGen = 2;
else
howGen = 0;
switch (howGen) {
case 1://use log
int left = sampleSetSize%crntStep;
while(bounds[0]==0)
bounds[0]=uniRand.nextInt(10);
crntStep = 1;
double theBound = bounds[sampleSetSize]/10;
for(int j=1;j<sampleSetSize;j++){
//step是每轮的个数
if(crntStep>=step && bounds[j-1]<=theBound)
crntStep=0;
if(crntStep==0)
bounds[j] = bounds[j-step] * 10;
else if(crntStep<step)
bounds[j] = bounds[j-crntStep] * ((double)crntStep*10./((double)step+1.));
else//(crntStep>=step)
bounds[j] = bounds[j-crntStep] * ((double)crntStep*10./(double)(left+step+1));
if(bounds[j]>=bounds[sampleSetSize]){
bounds[j] = bounds[sampleSetSize]-Math.random()*pace;
System.err.println("============Be careful!!!!=============");
}
crntStep++;
}
break;
case 2://first log, then pace
//for smaller than pace
int count = 0;
while(bounds[count]<pace && count<sampleSetSize-1){
count++;
bounds[count] = bounds[count-1]*10;
}
//for larger than pace
pace = (bounds[sampleSetSize] - bounds[count])/(sampleSetSize-count);
for(int j=count;j<sampleSetSize;j++){
bounds[j] = bounds[j-1] + pace;
}
break;
case 3://randomly choices
pace = bounds[sampleSetSize] - bounds[0];
for(int j=1;j<sampleSetSize;j++){
bounds[j] = bounds[0] + Math.random() * pace;
}
break;
default:
for(int j=1;j<sampleSetSize;j++){
bounds[j] = bounds[j-1] + pace;
}
break;
}
}
示例4: getMultiDimContinuousDiv
import weka.core.Attribute; //导入方法依赖的package包/类
/**
* At current version, we assume all attributes are numeric attributes with bounds
*
* Let PACE be upper-lower DIVided by the sampleSetSize
*
* @param useMid true if to use the middle point of a subdomain, false if to use a random point within a subdomain
*/
private static Instances getMultiDimContinuousDiv(ArrayList<Attribute> atts, int sampleSetSize, boolean useMid){
int L = Math.min(7, Math.max(sampleSetSize, atts.size()));//7 is chosen for no special reason
double maxMinDist = 0, crntMinDist;//work as the threshold to select the sample set
ArrayList<Integer>[] setWithMaxMinDist=null;
//generate L sets of sampleSetSize points
for(int i=0; i<L; i++){
ArrayList<Integer>[] setPerm = generateOneSampleSet(sampleSetSize, atts.size());
//compute the minimum distance minDist between any sample pair for each set
crntMinDist = minDistForSet(setPerm);
//select the set with the maximum minDist
if(crntMinDist>maxMinDist){
setWithMaxMinDist = setPerm;
maxMinDist = crntMinDist;
}
}
//generate and output the set with the maximum minDist as the result
//first, divide the domain of each attribute into sampleSetSize equal subdomain
double[][] bounds = new double[atts.size()][sampleSetSize+1];//sampleSetSize+1 to include the lower and upper bounds
Iterator<Attribute> itr = atts.iterator();
Attribute crntAttr;
double pace;
for(int i=0;i<bounds.length;i++){
crntAttr = itr.next();
bounds[i][0] = crntAttr.getLowerNumericBound();
bounds[i][sampleSetSize] = crntAttr.getUpperNumericBound();
pace = (bounds[i][sampleSetSize] - bounds[i][0])/sampleSetSize;
for(int j=1;j<sampleSetSize;j++){
bounds[i][j] = bounds[i][j-1] + pace;
}
}
//second, generate the set according to setWithMaxMinDist
Instances data = new Instances("InitialSetByLHS", atts, sampleSetSize);
for(int i=0;i<sampleSetSize;i++){
double[] vals = new double[atts.size()];
for(int j=0;j<vals.length;j++){
vals[j] = useMid?
(bounds[j][setWithMaxMinDist[j].get(i)]+bounds[j][setWithMaxMinDist[j].get(i)+1])/2:
bounds[j][setWithMaxMinDist[j].get(i)]+
(
(bounds[j][setWithMaxMinDist[j].get(i)+1]-bounds[j][setWithMaxMinDist[j].get(i)])*uniRand.nextDouble()
);
}
data.add(new DenseInstance(1.0, vals));
}
//third, return the generated points
return data;
}
示例5: getMultiDim
import weka.core.Attribute; //导入方法依赖的package包/类
/**
* Assumptions:(1)Numberic is continuous and has lower/upper bounds; (2) Nominals have domains permutable
*
* @param useMid true if to use the middle point of a subdomain, false if to use a random point within a subdomain
*/
public static Instances getMultiDim(ArrayList<Attribute> atts, int sampleSetSize, boolean useMid){
int L = Math.min(7, Math.max(sampleSetSize, atts.size()));//7 is chosen for no special reason
double maxMinDist = 0, crntMinDist;//work as the threshold to select the sample set
ArrayList<Integer>[] setWithMaxMinDist=null;
//generate L sets of sampleSetSize points
for(int i=0; i<L; i++){
ArrayList<Integer>[] setPerm = generateOneSampleSet(sampleSetSize, atts.size());
//compute the minimum distance minDist between any sample pair for each set
crntMinDist = minDistForSet(setPerm);
//select the set with the maximum minDist
if(crntMinDist>maxMinDist){
setWithMaxMinDist = setPerm;
maxMinDist = crntMinDist;
}
}
//generate and output the set with the maximum minDist as the result
//first, divide the domain of each attribute into sampleSetSize equal subdomain
double[][] bounds = new double[atts.size()][sampleSetSize+1];//sampleSetSize+1 to include the lower and upper bounds
Iterator<Attribute> itr = atts.iterator();
Attribute crntAttr;
double pace;
for(int i=0;i<bounds.length;i++){
crntAttr = itr.next();
if(crntAttr.isNumeric()){
bounds[i][0] = crntAttr.getLowerNumericBound();
bounds[i][sampleSetSize] = crntAttr.getUpperNumericBound();
pace = (crntAttr.getUpperNumericBound() - crntAttr.getLowerNumericBound())/sampleSetSize;
for(int j=1;j<sampleSetSize;j++){
bounds[i][j] = bounds[i][j-1] + pace;
}
}else{//crntAttr.isNominal()
if(crntAttr.numValues()>=sampleSetSize){
//randomly select among the set
for(int j=0;j<=sampleSetSize;j++)
bounds[i][j] = uniRand.nextInt(crntAttr.numValues());//the position of one of the nominal values
}else{
//first round-robin
int lastPart = sampleSetSize%crntAttr.numValues();
for(int j=0;j<sampleSetSize-lastPart;j++)
bounds[i][j] = j%crntAttr.numValues();
//then randomly select
for(int j=sampleSetSize-lastPart;j<=sampleSetSize;j++)
bounds[i][j] = uniRand.nextInt(crntAttr.numValues());
}
}//nominal attribute
}//get all subdomains
//second, generate the set according to setWithMaxMinDist
Instances data = new Instances("InitialSetByLHS", atts, sampleSetSize);
for(int i=0;i<sampleSetSize;i++){
double[] vals = new double[atts.size()];
for(int j=0;j<vals.length;j++){
if(atts.get(j).isNumeric()){
vals[j] = useMid?
(bounds[j][setWithMaxMinDist[j].get(i)]+bounds[j][setWithMaxMinDist[j].get(i)+1])/2:
bounds[j][setWithMaxMinDist[j].get(i)]+
(
(bounds[j][setWithMaxMinDist[j].get(i)+1]-bounds[j][setWithMaxMinDist[j].get(i)])*uniRand.nextDouble()
);
}else{//isNominal()
vals[j] = bounds[j][setWithMaxMinDist[j].get(i)];
}
}
data.add(new DenseInstance(1.0, vals));
}
//third, return the generated points
return data;
}
示例6: getMultiDimContinuousLog
import weka.core.Attribute; //导入方法依赖的package包/类
/**
* At current version, we assume all attributes are numeric attributes with bounds
*
* Let PACE be log10(upper/lower)
*
* @param useMid true if to use the middle point of a subdomain, false if to use a random point within a subdomain
*/
public static Instances getMultiDimContinuousLog(ArrayList<Attribute> atts, int sampleSetSize, boolean useMid){
int L = Math.min(7, Math.max(sampleSetSize, atts.size()));//7 is chosen for no special reason
double maxMinDist = 0, crntMinDist;//work as the threshold to select the sample set
ArrayList<Integer>[] setWithMaxMinDist=null;
//generate L sets of sampleSetSize points
for(int i=0; i<L; i++){
ArrayList<Integer>[] setPerm = generateOneSampleSet(sampleSetSize, atts.size());
//compute the minimum distance minDist between any sample pair for each set
crntMinDist = minDistForSet(setPerm);
//select the set with the maximum minDist
if(crntMinDist>maxMinDist){
setWithMaxMinDist = setPerm;
maxMinDist = crntMinDist;
}
}
//generate and output the set with the maximum minDist as the result
//first, divide the domain of each attribute into sampleSetSize equal subdomain
double[][] bounds = new double[atts.size()][sampleSetSize+1];//sampleSetSize+1 to include the lower and upper bounds
Iterator<Attribute> itr = atts.iterator();
Attribute crntAttr;
int step, crntStep;
for(int i=0;i<bounds.length;i++){
crntAttr = itr.next();
bounds[i][0] = crntAttr.getLowerNumericBound();
bounds[i][sampleSetSize] = crntAttr.getUpperNumericBound();
crntStep = (int)Math.log10(bounds[i][sampleSetSize] - bounds[i][0]);
step = sampleSetSize/crntStep;//num of points drawn after the multiplication of 10
int left = sampleSetSize%crntStep;
if(bounds[i][0]==0)
bounds[i][0]=uniRand.nextInt(10);
crntStep = 1;
double theBound = bounds[i][sampleSetSize]/10;
for(int j=1;j<sampleSetSize;j++){
if(crntStep>=step && bounds[i][j-1]<=theBound)
crntStep=0;
if(crntStep==0)
bounds[i][j] = bounds[i][j-step] * 10;
else if(crntStep<step)
bounds[i][j] = bounds[i][j-crntStep] * ((double)crntStep*10./((double)step+1.));
else if(crntStep>=step)
bounds[i][j] = bounds[i][j-crntStep] * ((double)crntStep*10./(double)(left+step+1));
if(bounds[i][j]>=bounds[i][sampleSetSize])
System.err.println("be careful!!!!");
crntStep++;
}
}
//second, generate the set according to setWithMaxMinDist
Instances data = new Instances("InitialSetByLHS", atts, sampleSetSize);
for(int i=0;i<sampleSetSize;i++){
double[] vals = new double[atts.size()];
for(int j=0;j<vals.length;j++){
vals[j] = useMid?
(bounds[j][setWithMaxMinDist[j].get(i)]+bounds[j][setWithMaxMinDist[j].get(i)+1])/2:
bounds[j][setWithMaxMinDist[j].get(i)]+
(
(bounds[j][setWithMaxMinDist[j].get(i)+1]-bounds[j][setWithMaxMinDist[j].get(i)])*uniRand.nextDouble()
);
}
data.add(new DenseInstance(1.0, vals));
}
//third, return the generated points
return data;
}
示例7: flexibleBoundsGeneration
import weka.core.Attribute; //导入方法依赖的package包/类
private static void flexibleBoundsGeneration(double[] bounds, Attribute crntAttr, int sampleSetSize){
int howGen = 0;//div
int step, crntStep;
double pace;
bounds[0] = crntAttr.getLowerNumericBound();
bounds[sampleSetSize] = crntAttr.getUpperNumericBound();
pace = (bounds[sampleSetSize] - bounds[0])/sampleSetSize;
crntStep = bounds[0]>1?(int)Math.log10(bounds[sampleSetSize] / bounds[0]):(int)Math.log10(bounds[sampleSetSize]);
if(crntStep>0)
step = sampleSetSize/crntStep;//num of points drawn after the multiplication of 10
else
step = 11;//anything larger than 10
if(sampleSetSize<crntStep){
howGen = 3;
}else if(0<step && step <10)//each hierarchy has fewer than 10 points
howGen = 1;
else if((bounds[0]>1 && (int)Math.log10(pace/bounds[0])> BigStepPower) ||
(bounds[0]<1 && (int)Math.log10(pace)> BigStepPower) )//a big first step
howGen = 2;
else
howGen = 0;
switch (howGen) {
case 1://use log
int left = sampleSetSize%crntStep;//æ?ä¸?½®ç个æ?
while(bounds[0]==0)
bounds[0]=uniRand.nextInt(10);
crntStep = 1;
double theBound = bounds[sampleSetSize]/10;
for(int j=1;j<sampleSetSize;j++){
//stepæ¯æ¯è½®ç个æ°
if(crntStep>=step && bounds[j-1]<=theBound)
crntStep=0;
if(crntStep==0)
bounds[j] = bounds[j-step] * 10;
else if(crntStep<step)
bounds[j] = bounds[j-crntStep] * ((double)crntStep*10./((double)step+1.));
else//(crntStep>=step)
bounds[j] = bounds[j-crntStep] * ((double)crntStep*10./(double)(left+step+1));
if(bounds[j]>=bounds[sampleSetSize]){
bounds[j] = bounds[sampleSetSize]-Math.random()*pace;
System.err.println("============Be careful!!!!=============");
}
crntStep++;
}
break;
case 2://first log, then pace
//for smaller than pace
int count = 0;
while(bounds[count]<pace && count<sampleSetSize-1){
count++;
bounds[count] = bounds[count-1]*10;
}
//for larger than pace
pace = (bounds[sampleSetSize] - bounds[count])/(sampleSetSize-count);
for(int j=count;j<sampleSetSize;j++){
bounds[j] = bounds[j-1] + pace;
}
break;
case 3://randomly choices
pace = bounds[sampleSetSize] - bounds[0];
for(int j=1;j<sampleSetSize;j++){
bounds[j] = bounds[0] + Math.random() * pace;
}
break;
default:
for(int j=1;j<sampleSetSize;j++){
bounds[j] = bounds[j-1] + pace;
}
break;
}
}
示例8: getMultiDimContinuousDiv
import weka.core.Attribute; //导入方法依赖的package包/类
/**
* At current version, we assume all attributes are numeric attributes with bounds
*
* Let PACE be upper-lower DIVided by the sampleSetSize
*
* @param useMid true if to use the middle point of a subdomain, false if to use a random point within a subdomain
*/
public static Instances getMultiDimContinuousDiv(ArrayList<Attribute> atts, int sampleSetSize, boolean useMid){
int L = Math.min(7, Math.max(sampleSetSize, atts.size()));//7 is chosen for no special reason
double maxMinDist = 0, crntMinDist;//work as the threshold to select the sample set
ArrayList<Integer>[] setWithMaxMinDist=null;
//generate L sets of sampleSetSize points
for(int i=0; i<L; i++){
ArrayList<Integer>[] setPerm = generateOneSampleSet(sampleSetSize, atts.size());
//compute the minimum distance minDist between any sample pair for each set
crntMinDist = minDistForSet(setPerm);
//select the set with the maximum minDist
if(crntMinDist>maxMinDist){
setWithMaxMinDist = setPerm;
maxMinDist = crntMinDist;
}
}
//generate and output the set with the maximum minDist as the result
//first, divide the domain of each attribute into sampleSetSize equal subdomain
double[][] bounds = new double[atts.size()][sampleSetSize+1];//sampleSetSize+1 to include the lower and upper bounds
Iterator<Attribute> itr = atts.iterator();
Attribute crntAttr;
double pace;
for(int i=0;i<bounds.length;i++){
crntAttr = itr.next();
bounds[i][0] = crntAttr.getLowerNumericBound();
bounds[i][sampleSetSize] = crntAttr.getUpperNumericBound();
pace = (bounds[i][sampleSetSize] - bounds[i][0])/sampleSetSize;
for(int j=1;j<sampleSetSize;j++){
bounds[i][j] = bounds[i][j-1] + pace;
}
}
//second, generate the set according to setWithMaxMinDist
Instances data = new Instances("InitialSetByLHS", atts, sampleSetSize);
for(int i=0;i<sampleSetSize;i++){
double[] vals = new double[atts.size()];
for(int j=0;j<vals.length;j++){
vals[j] = useMid?
(bounds[j][setWithMaxMinDist[j].get(i)]+bounds[j][setWithMaxMinDist[j].get(i)+1])/2:
bounds[j][setWithMaxMinDist[j].get(i)]+
(
(bounds[j][setWithMaxMinDist[j].get(i)+1]-bounds[j][setWithMaxMinDist[j].get(i)])*uniRand.nextDouble()
);
}
data.add(new DenseInstance(1.0, vals));
}
//third, return the generated points
return data;
}