当前位置: 首页>>代码示例>>Java>>正文


Java KernelDistribution类代码示例

本文整理汇总了Java中com.rapidminer.tools.math.distribution.kernel.KernelDistribution的典型用法代码示例。如果您正苦于以下问题:Java KernelDistribution类的具体用法?Java KernelDistribution怎么用?Java KernelDistribution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KernelDistribution类属于com.rapidminer.tools.math.distribution.kernel包,在下文中一共展示了KernelDistribution类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: KernelDistributionModel

import com.rapidminer.tools.math.distribution.kernel.KernelDistribution; //导入依赖的package包/类
public KernelDistributionModel(ExampleSet exampleSet, boolean laplaceCorrectionEnabled, int estimationMode,
		int bandwidthSelectionMode, double bandwidth, int numberOfKernels, int gridSize) {
	super(exampleSet, ExampleSetUtilities.SetsCompareOption.ALLOW_SUPERSET,
			ExampleSetUtilities.TypesCompareOption.ALLOW_SAME_PARENTS);
	this.laplaceCorrectionEnabled = laplaceCorrectionEnabled;
	this.useApplianceGrid = gridSize > 10;
	this.gridSize = gridSize;
	Attribute labelAttribute = exampleSet.getAttributes().getLabel();
	numberOfClasses = labelAttribute.getMapping().size();
	numberOfAttributes = exampleSet.getAttributes().size();
	nominal = new boolean[numberOfAttributes];
	attributeNames = new String[numberOfAttributes];
	attributeValues = new String[numberOfAttributes][];
	className = labelAttribute.getName();
	classValues = new String[numberOfClasses];
	for (int i = 0; i < numberOfClasses; i++) {
		classValues[i] = labelAttribute.getMapping().mapIndex(i);
	}
	int attributeIndex = 0;
	weightSums = new double[numberOfAttributes][numberOfClasses][];
	distributionProperties = new double[numberOfAttributes][numberOfClasses][];
	kernelDistributions = new KernelDistribution[numberOfAttributes][numberOfClasses];
	for (Attribute attribute : exampleSet.getAttributes()) {
		attributeNames[attributeIndex] = attribute.getName();
		if (attribute.isNominal()) {
			nominal[attributeIndex] = true;
			int mappingSize = attribute.getMapping().size() + 1;
			attributeValues[attributeIndex] = new String[mappingSize];
			for (int i = 0; i < mappingSize - 1; i++) {
				attributeValues[attributeIndex][i] = attribute.getMapping().mapIndex(i);
			}
			attributeValues[attributeIndex][mappingSize - 1] = UNKNOWN_VALUE_NAME;
			for (int i = 0; i < numberOfClasses; i++) {
				weightSums[attributeIndex][i] = new double[mappingSize];
				distributionProperties[attributeIndex][i] = new double[mappingSize];
			}
		} else {
			nominal[attributeIndex] = false;
			for (int i = 0; i < numberOfClasses; i++) {
				switch (estimationMode) {
					case KernelNaiveBayes.ESTIMATION_MODE_FULL:
						switch (bandwidthSelectionMode) {
							case KernelNaiveBayes.BANDWIDTH_SELECTION_MODE_HEURISTIC:
								kernelDistributions[attributeIndex][i] = new FullKernelDistribution();
								break;
							case KernelNaiveBayes.BANDWIDTH_SELECTION_MODE_FIX:
								kernelDistributions[attributeIndex][i] = new FullKernelDistribution(bandwidth);
								break;
						}
						break;
					case KernelNaiveBayes.ESTIMATION_MODE_GREEDY:
						kernelDistributions[attributeIndex][i] = new GreedyKernelDistribution(bandwidth, numberOfKernels);
						break;
					default:
						kernelDistributions[attributeIndex][i] = new FullKernelDistribution();
				}
			}
		}
		attributeIndex++;
	}

	// initialization of total and a priori weight counters
	totalWeight = 0.0d;
	classWeights = new double[numberOfClasses];
	priors = new double[numberOfClasses];

	if (useApplianceGrid) {
		grid = new double[numberOfAttributes][numberOfClasses][];
	}

	// update the model
	update(exampleSet);

	// calculate the probabilities
	updateDistributionProperties();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:77,代码来源:KernelDistributionModel.java

示例2: KernelDistributionModel

import com.rapidminer.tools.math.distribution.kernel.KernelDistribution; //导入依赖的package包/类
public KernelDistributionModel(ExampleSet exampleSet, boolean laplaceCorrectionEnabled, int estimationMode,
		int bandwidthSelectionMode, double bandwidth, int numberOfKernels, int gridSize) {
	super(exampleSet, ExampleSetUtilities.SetsCompareOption.ALLOW_SUPERSET,
			ExampleSetUtilities.TypesCompareOption.ALLOW_SAME_PARENTS);
	this.laplaceCorrectionEnabled = laplaceCorrectionEnabled;
	this.useApplianceGrid = gridSize > 10;
	this.gridSize = gridSize;
	Attribute labelAttribute = exampleSet.getAttributes().getLabel();
	numberOfClasses = labelAttribute.getMapping().size();
	numberOfAttributes = exampleSet.getAttributes().size();
	nominal = new boolean[numberOfAttributes];
	attributeNames = new String[numberOfAttributes];
	attributeValues = new String[numberOfAttributes][];
	className = labelAttribute.getName();
	classValues = new String[numberOfClasses];
	for (int i = 0; i < numberOfClasses; i++) {
		classValues[i] = labelAttribute.getMapping().mapIndex(i);
	}
	int attributeIndex = 0;
	weightSums = new double[numberOfAttributes][numberOfClasses][];
	distributionProperties = new double[numberOfAttributes][numberOfClasses][];
	kernelDistributions = new KernelDistribution[numberOfAttributes][numberOfClasses];
	for (Attribute attribute : exampleSet.getAttributes()) {
		attributeNames[attributeIndex] = attribute.getName();
		if (attribute.isNominal()) {
			nominal[attributeIndex] = true;
			int mappingSize = attribute.getMapping().size() + 1;
			attributeValues[attributeIndex] = new String[mappingSize];
			for (int i = 0; i < mappingSize - 1; i++) {
				attributeValues[attributeIndex][i] = attribute.getMapping().mapIndex(i);
			}
			attributeValues[attributeIndex][mappingSize - 1] = UNKNOWN_VALUE_NAME;
			for (int i = 0; i < numberOfClasses; i++) {
				weightSums[attributeIndex][i] = new double[mappingSize];
				distributionProperties[attributeIndex][i] = new double[mappingSize];
			}
		} else {
			nominal[attributeIndex] = false;
			for (int i = 0; i < numberOfClasses; i++) {
				switch (estimationMode) {
					case KernelNaiveBayes.ESTIMATION_MODE_FULL:
						switch (bandwidthSelectionMode) {
							case KernelNaiveBayes.BANDWIDTH_SELECTION_MODE_HEURISTIC:
								kernelDistributions[attributeIndex][i] = new FullKernelDistribution();
								break;
							case KernelNaiveBayes.BANDWIDTH_SELECTION_MODE_FIX:
								kernelDistributions[attributeIndex][i] = new FullKernelDistribution(bandwidth);
								break;
						}
						break;
					case KernelNaiveBayes.ESTIMATION_MODE_GREEDY:
						kernelDistributions[attributeIndex][i] = new GreedyKernelDistribution(bandwidth,
								numberOfKernels);
						break;
					default:
						kernelDistributions[attributeIndex][i] = new FullKernelDistribution();
				}
			}
		}
		attributeIndex++;
	}

	// initialization of total and a priori weight counters
	totalWeight = 0.0d;
	classWeights = new double[numberOfClasses];
	priors = new double[numberOfClasses];

	if (useApplianceGrid) {
		grid = new double[numberOfAttributes][numberOfClasses][];
	}

	// update the model
	update(exampleSet);

	// calculate the probabilities
	updateDistributionProperties();
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:78,代码来源:KernelDistributionModel.java

示例3: KernelDistributionModel

import com.rapidminer.tools.math.distribution.kernel.KernelDistribution; //导入依赖的package包/类
public KernelDistributionModel(ExampleSet exampleSet, boolean laplaceCorrectionEnabled, int estimationMode, int bandwidthSelectionMode, double bandwidth, int numberOfKernels, int gridSize) {
    super(exampleSet);
    this.laplaceCorrectionEnabled = laplaceCorrectionEnabled;
    this.useApplianceGrid = (gridSize > 10);
    this.gridSize = gridSize;
    Attribute labelAttribute = exampleSet.getAttributes().getLabel();
    numberOfClasses = labelAttribute.getMapping().size();
    numberOfAttributes = exampleSet.getAttributes().size();
    nominal = new boolean[numberOfAttributes];
    attributeNames = new String[numberOfAttributes];
    attributeValues = new String[numberOfAttributes][];
    className = labelAttribute.getName();
    classValues = new String[numberOfClasses];
    for (int i = 0; i < numberOfClasses; i++) {
        classValues[i] = labelAttribute.getMapping().mapIndex(i);
    }
    int attributeIndex = 0;
    weightSums = new double[numberOfAttributes][numberOfClasses][];
    distributionProperties = new double[numberOfAttributes][numberOfClasses][];
    kernelDistributions = new KernelDistribution[numberOfAttributes][numberOfClasses];
    for (Attribute attribute : exampleSet.getAttributes()) {
        attributeNames[attributeIndex] = attribute.getName();
        if (attribute.isNominal()) {
            nominal[attributeIndex] = true;
            int mappingSize = attribute.getMapping().size() + 1;
            attributeValues[attributeIndex] = new String[mappingSize];
            for (int i = 0; i < mappingSize - 1; i++) {
                attributeValues[attributeIndex][i] = attribute.getMapping().mapIndex(i);
            }
            attributeValues[attributeIndex][mappingSize - 1] = UNKNOWN_VALUE_NAME;
            for (int i = 0; i < numberOfClasses; i++) {
                weightSums[attributeIndex][i] = new double[mappingSize];
                distributionProperties[attributeIndex][i] = new double[mappingSize];
            }
        } else {
            nominal[attributeIndex] = false;
            for (int i = 0; i < numberOfClasses; i++) {
                switch (estimationMode) {
                case KernelNaiveBayes.ESTIMATION_MODE_FULL:
                    switch (bandwidthSelectionMode) {
                    case KernelNaiveBayes.BANDWIDTH_SELECTION_MODE_HEURISTIC:
                        kernelDistributions[attributeIndex][i] = new FullKernelDistribution();
                        break;
                    case KernelNaiveBayes.BANDWIDTH_SELECTION_MODE_FIX:
                        kernelDistributions[attributeIndex][i] = new FullKernelDistribution(bandwidth);
                        break;
                    }
                    break;
                case KernelNaiveBayes.ESTIMATION_MODE_GREEDY:
                    kernelDistributions[attributeIndex][i] = new GreedyKernelDistribution(bandwidth, numberOfKernels);
                    break;
                default:
                    kernelDistributions[attributeIndex][i] = new FullKernelDistribution();
                }
            }
        }
        attributeIndex++;
    }

    //  initialization of total and a priori weight counters
    totalWeight = 0.0d;
    classWeights = new double[numberOfClasses];
    priors = new double[numberOfClasses];

    if (useApplianceGrid) {
        grid = new double[numberOfAttributes][numberOfClasses][];
    }

    // update the model
    update(exampleSet);

    // calculate the probabilities
    updateDistributionProperties();
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:75,代码来源:KernelDistributionModel.java


注:本文中的com.rapidminer.tools.math.distribution.kernel.KernelDistribution类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。