parent
eb5a629d89
commit
87cdeed935
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: com.alibaba:fastjson:1.2.51" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -0,0 +1,7 @@
|
|||||||
|
package org.wlld.config;
|
||||||
|
|
||||||
|
public class Classifier {//分类器
|
||||||
|
public static final int LVQ = 1;//LVQ分类
|
||||||
|
public static final int DNN = 2; //使用DNN分类
|
||||||
|
public static final int VAvg = 3;//使用特征向量均值分类
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package org.wlld.imageRecognition;
|
||||||
|
|
||||||
|
import org.wlld.MatrixTools.Matrix;
|
||||||
|
import org.wlld.i.OutBack;
|
||||||
|
|
||||||
|
public class MaxPoint implements OutBack {
|
||||||
|
private int id;
|
||||||
|
private double point;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getBack(double out, int id, long eventId) {
|
||||||
|
if (out > point) {
|
||||||
|
point = out;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getBackMatrix(Matrix matrix, long eventId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package org.wlld.imageRecognition;
|
||||||
|
|
||||||
|
import org.wlld.MatrixTools.Matrix;
|
||||||
|
import org.wlld.MatrixTools.MatrixOperation;
|
||||||
|
import org.wlld.tools.ArithUtil;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class VectorK {
|
||||||
|
private Map<Integer, List<Matrix>> matrixMap = new HashMap<>();
|
||||||
|
private Map<Integer, Matrix> matrixK = new HashMap<>();
|
||||||
|
private int length;
|
||||||
|
|
||||||
|
public VectorK(int length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Matrix> getMatrixK() {
|
||||||
|
return matrixK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertMatrix(int type, Matrix matrix) throws Exception {
|
||||||
|
if (matrix.isRowVector() && matrix.getY() == length) {
|
||||||
|
if (matrixMap.containsKey(type)) {
|
||||||
|
List<Matrix> matrixList = matrixMap.get(type);
|
||||||
|
matrixList.add(matrix);
|
||||||
|
} else {
|
||||||
|
List<Matrix> list = new ArrayList<>();
|
||||||
|
list.add(matrix);
|
||||||
|
matrixMap.put(type, list);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Exception("MATRIX IS NOT RIGHT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Matrix sigma(List<Matrix> matrixList) throws Exception {
|
||||||
|
Matrix matrix = new Matrix(1, length);
|
||||||
|
for (Matrix matrix1 : matrixList) {
|
||||||
|
matrix = MatrixOperation.add(matrix, matrix1);
|
||||||
|
}
|
||||||
|
MatrixOperation.mathMul(matrix, ArithUtil.div(1, matrixList.size()));
|
||||||
|
return matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Matrix mind(List<Matrix> matrixList) throws Exception {//拿中位数
|
||||||
|
Matrix matrix = new Matrix(1, length);
|
||||||
|
List<List<Double>> lists = new ArrayList<>();
|
||||||
|
for (Matrix matrix1 : matrixList) {
|
||||||
|
for (int i = 0; i < matrix1.getY(); i++) {
|
||||||
|
if (lists.size() <= i) {
|
||||||
|
lists.add(new ArrayList<>());
|
||||||
|
}
|
||||||
|
List<Double> list = lists.get(i);
|
||||||
|
list.add(matrix1.getNumber(0, i));
|
||||||
|
Collections.sort(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
List<Double> list = lists.get(i);
|
||||||
|
int index = list.size() / 2;
|
||||||
|
matrix.setNub(0, i, list.get(index));
|
||||||
|
}
|
||||||
|
return matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void study() throws Exception {
|
||||||
|
for (Map.Entry<Integer, List<Matrix>> entry : matrixMap.entrySet()) {
|
||||||
|
List<Matrix> matrixList = entry.getValue();
|
||||||
|
Matrix matrix = sigma(matrixList);
|
||||||
|
matrixK.put(entry.getKey(), matrix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue