本文整理汇总了Java中com.rapidminer.tools.math.Peak类的典型用法代码示例。如果您正苦于以下问题:Java Peak类的具体用法?Java Peak怎么用?Java Peak使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Peak类属于com.rapidminer.tools.math包,在下文中一共展示了Peak类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributePeaks
import com.rapidminer.tools.math.Peak; //导入依赖的package包/类
/**
* Calculates the fourier transformation from the first attribute on the second and delivers the
* <code>maxPeaks</code> highest peaks. Returns a list with the highest attribute peaks.
*/
public List<AttributePeak> getAttributePeaks(ExampleSet exampleSet, Attribute first, Attribute second)
throws OperatorException {
exampleSet.recalculateAllAttributeStatistics();
Complex[] result = fft.getFourierTransform(exampleSet, first, second);
Peak[] spectrum = filter.filter(result, exampleSet.size());
double average = 0.0d;
for (int k = 0; k < spectrum.length; k++) {
average += spectrum[k].getMagnitude();
}
average /= spectrum.length;
List<Peak> peaks = peakFinder.getPeaks(spectrum);
Collections.sort(peaks);
// remember highest peaks
double inputDeviation = Math.sqrt(exampleSet.getStatistics(second, Statistics.VARIANCE))
/ (exampleSet.getStatistics(second, Statistics.MAXIMUM) - exampleSet.getStatistics(second,
Statistics.MINIMUM));
Iterator p = peaks.iterator();
double maxEvidence = Double.NaN;
List<AttributePeak> attributes = new LinkedList<AttributePeak>();
for (int k = 0; k < maxPeaks; k++) {
if (p.hasNext()) {
Peak peak = (Peak) p.next();
double evidence = (peak.getMagnitude() / average) * (1.0d / inputDeviation);
if (Double.isNaN(maxEvidence)) {
maxEvidence = evidence;
}
if (evidence > (MIN_EVIDENCE * maxEvidence)) {
attributes.add(new AttributePeak(second, peak.getIndex(), evidence));
}
}
}
return attributes;
}
示例2: fillTable
import com.rapidminer.tools.math.Peak; //导入依赖的package包/类
/**
* Fills the table with the length of the given complex numbers in the column of the attribute.
*/
private void fillTable(ExampleTable table, Attribute attribute, Peak[] values) throws OperatorException {
DataRowReader reader = table.getDataRowReader();
int k = 0;
while (reader.hasNext()) {
DataRow dataRow = reader.next();
dataRow.set(attribute, values[k++].getMagnitude());
checkForStop();
}
}
示例3: getAttributePeaks
import com.rapidminer.tools.math.Peak; //导入依赖的package包/类
/**
* Calculates the fourier transformation from the first attribute on the second and delivers the
* <code>maxPeaks</code> highest peaks. Returns a list with the highest attribute peaks.
*/
public List<AttributePeak> getAttributePeaks(ExampleSet exampleSet, Attribute first, Attribute second)
throws OperatorException {
exampleSet.recalculateAllAttributeStatistics();
Complex[] result = fft.getFourierTransform(exampleSet, first, second);
Peak[] spectrum = filter.filter(result, exampleSet.size());
double average = 0.0d;
for (int k = 0; k < spectrum.length; k++) {
average += spectrum[k].getMagnitude();
}
average /= spectrum.length;
List<Peak> peaks = peakFinder.getPeaks(spectrum);
Collections.sort(peaks);
if (maxPeaks < peaks.size()) {
peaks = peaks.subList(0, maxPeaks);
}
// remember highest peaks
double inputDeviation = Math.sqrt(exampleSet.getStatistics(second, Statistics.VARIANCE))
/ (exampleSet.getStatistics(second, Statistics.MAXIMUM)
- exampleSet.getStatistics(second, Statistics.MINIMUM));
double maxEvidence = Double.NaN;
List<AttributePeak> attributes = new LinkedList<AttributePeak>();
for (Peak peak : peaks) {
double evidence = peak.getMagnitude() / average * (1.0d / inputDeviation);
if (Double.isNaN(maxEvidence)) {
maxEvidence = evidence;
}
if (evidence > MIN_EVIDENCE * maxEvidence) {
attributes.add(new AttributePeak(second, peak.getIndex(), evidence));
}
}
return attributes;
}
示例4: getAttributePeaks
import com.rapidminer.tools.math.Peak; //导入依赖的package包/类
/**
* Calculates the fourier transformation from the first attribute on the
* second and delivers the <code>maxPeaks</code> highest peaks. Returns a
* list with the highest attribute peaks.
*/
public List<AttributePeak> getAttributePeaks(ExampleSet exampleSet, Attribute first, Attribute second) throws OperatorException {
exampleSet.recalculateAllAttributeStatistics();
Complex[] result = fft.getFourierTransform(exampleSet, first, second);
Peak[] spectrum = filter.filter(result, exampleSet.size());
double average = 0.0d;
for (int k = 0; k < spectrum.length; k++)
average += spectrum[k].getMagnitude();
average /= spectrum.length;
List<Peak> peaks = peakFinder.getPeaks(spectrum);
Collections.sort(peaks);
// remember highest peaks
double inputDeviation = Math.sqrt(exampleSet.getStatistics(second, Statistics.VARIANCE)) / (exampleSet.getStatistics(second, Statistics.MAXIMUM) - exampleSet.getStatistics(second, Statistics.MINIMUM));
Iterator p = peaks.iterator();
double maxEvidence = Double.NaN;
List<AttributePeak> attributes = new LinkedList<AttributePeak>();
for (int k = 0; k < maxPeaks; k++) {
if (p.hasNext()) {
Peak peak = (Peak) p.next();
double evidence = (peak.getMagnitude() / average) * (1.0d / inputDeviation);
if (Double.isNaN(maxEvidence))
maxEvidence = evidence;
if (evidence > (MIN_EVIDENCE * maxEvidence))
attributes.add(new AttributePeak(second, peak.getIndex(), evidence));
}
}
return attributes;
}
示例5: apply
import com.rapidminer.tools.math.Peak; //导入依赖的package包/类
@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
Tools.onlyNonMissingValues(exampleSet, "Fourier Transform");
// create new example table
int numberOfNewExamples = FastFourierTransform.getGreatestPowerOf2LessThan(exampleSet.size()) / 2;
ExampleTable exampleTable = new MemoryExampleTable(new LinkedList<Attribute>(), new DataRowFactory(DataRowFactory.TYPE_DOUBLE_ARRAY, '.'), numberOfNewExamples);
// create frequency attribute (for frequency)
Attribute frequencyAttribute = AttributeFactory.createAttribute("frequency", Ontology.REAL);
exampleTable.addAttribute(frequencyAttribute);
DataRowReader drr = exampleTable.getDataRowReader();
int k = 0;
while (drr.hasNext()) {
DataRow dataRow = drr.next();
dataRow.set(frequencyAttribute, FastFourierTransform.convertFrequency(k++, numberOfNewExamples, exampleSet.size()));
}
// create FFT values
Attribute label = exampleSet.getAttributes().getLabel();
// add FFT values
FastFourierTransform fft = new FastFourierTransform(WindowFunction.BLACKMAN_HARRIS);
SpectrumFilter filter = new SpectrumFilter(SpectrumFilter.NONE);
for (Attribute current : exampleSet.getAttributes()) {
if (current.isNumerical()) {
Complex[] result = fft.getFourierTransform(exampleSet, label, current);
Peak[] spectrum = filter.filter(result, exampleSet.size());
// create new attribute and fill table with values
Attribute newAttribute = AttributeFactory.createAttribute("fft(" + current.getName() + ")", Ontology.REAL);
exampleTable.addAttribute(newAttribute);
fillTable(exampleTable, newAttribute, spectrum);
}
}
ExampleSet resultSet = new SimpleExampleSet(exampleTable);
return resultSet;
}
示例6: apply
import com.rapidminer.tools.math.Peak; //导入依赖的package包/类
@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
Tools.onlyNonMissingValues(exampleSet, getOperatorClassName(), this);
// create new example table
int numberOfNewExamples = FastFourierTransform.getGreatestPowerOf2LessThan(exampleSet.size()) / 2;
ExampleTable exampleTable = new MemoryExampleTable(new LinkedList<Attribute>(), new DataRowFactory(
DataRowFactory.TYPE_DOUBLE_ARRAY, '.'), numberOfNewExamples);
// create frequency attribute (for frequency)
Attribute frequencyAttribute = AttributeFactory.createAttribute("frequency", Ontology.REAL);
exampleTable.addAttribute(frequencyAttribute);
DataRowReader drr = exampleTable.getDataRowReader();
int k = 0;
while (drr.hasNext()) {
DataRow dataRow = drr.next();
dataRow.set(frequencyAttribute,
FastFourierTransform.convertFrequency(k++, numberOfNewExamples, exampleSet.size()));
}
// create FFT values
Attribute label = exampleSet.getAttributes().getLabel();
// add FFT values
FastFourierTransform fft = new FastFourierTransform(WindowFunction.BLACKMAN_HARRIS);
SpectrumFilter filter = new SpectrumFilter(SpectrumFilter.NONE);
for (Attribute current : exampleSet.getAttributes()) {
if (current.isNumerical()) {
Complex[] result = fft.getFourierTransform(exampleSet, label, current);
Peak[] spectrum = filter.filter(result, exampleSet.size());
// create new attribute and fill table with values
Attribute newAttribute = AttributeFactory.createAttribute("fft(" + current.getName() + ")", Ontology.REAL);
exampleTable.addAttribute(newAttribute);
fillTable(exampleTable, newAttribute, spectrum);
}
}
ExampleSet resultSet = new SimpleExampleSet(exampleTable);
return resultSet;
}