本文整理汇总了Java中org.apache.commons.math.linear.RealVector.getData方法的典型用法代码示例。如果您正苦于以下问题:Java RealVector.getData方法的具体用法?Java RealVector.getData怎么用?Java RealVector.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.linear.RealVector
的用法示例。
在下文中一共展示了RealVector.getData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAvgProductVector
import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
public double[] createAvgProductVector(List<Long> recentitemInteractions,Map<Long,float[]> productFeatures)
{
int numLatentFactors = productFeatures.values().iterator().next().length;
double[] userFeatures = new double[numLatentFactors];
for (Long item : recentitemInteractions)
{
float[] productFactors = productFeatures.get(item);
if (productFactors != null)
{
for (int feature = 0; feature < numLatentFactors; feature++)
{
userFeatures[feature] += productFactors[feature];
}
}
}
RealVector userFeaturesAsVector = new ArrayRealVector(userFeatures);
RealVector normalised = userFeaturesAsVector.mapDivide(userFeaturesAsVector.getL1Norm());
return normalised.getData();
}
示例2: calculateInitialState
import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
* Calculates the initial state.
* @return the initial state
*/
private double[] calculateInitialState() {
if (numberOfCoefficients == 1) {
//initial state is always numberOfCoefficients - 1.
return new double[0];
} else {
RealMatrix zin = calculateZIN();
RealVector zid = calculateZID();
RealVector zi = getInvertedMatrix(zin).operate(zid);
return zi.getData();
}
}
示例3: getInvertedCoeffiecientSum
import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
* Get the -1 times the sum of all coefficients in the given array.
* @param coefficients coefficients to sum
* @return the -1 times the sum of all coefficients in the given array.
*/
protected static double getInvertedCoeffiecientSum(final RealVector coefficients) {
double sum = 0;
for (double coefficient : coefficients.getData()) {
sum -= coefficient;
}
return sum;
}
示例4: unwrap
import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
* @param x A Commons vector, not null
* @return An OG 1-D matrix of doubles
*/
public static DoubleMatrix1D unwrap(final RealVector x) {
Validate.notNull(x);
return new DoubleMatrix1D(x.getData());
}
示例5: estimateResiduals
import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public double[] estimateResiduals() {
RealVector b = calculateBeta();
RealVector e = Y.subtract(X.operate(b));
return e.getData();
}
示例6: estimateRegressionParameters
import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public double[] estimateRegressionParameters() {
RealVector b = calculateBeta();
return b.getData();
}
示例7: assertVectorEquals
import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
* Asserts that the elements of two vectors are equal concerning
* a delta.
*
* @param expected the expected values
* @param actual the actual values
* @param delta determines how much the actual value can be different from the expected
* value for the assertion to hold true
*/
public static void assertVectorEquals(RealVector expected, RealVector actual, double delta) {
double[] expectedData = expected.getData();
double[] actualData = actual.getData();
assertArrayEquals(expectedData, actualData, delta);
}