package com.itcmdas.service;
import com.itcmdas.vo.TwoMedicineCombination;
import com.itcmdas.vo.TwoMedicineMapForClustering;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
/**
* 复杂系统熵聚类算法
*/
public class ComplexEntropyClustering {
public static int maxn = 10010;
//处方总和
public static int prescriptionSum = 0;
//药物和处方构成的二维字符串数组
private static ArrayList<String>[] medicalTableStr = null;
public static ArrayList<String>[] getMedicalTableStr() {
return medicalTableStr;
}
public static void setMedicalTableStr(ArrayList<String>[] medicalTableStr) {
ComplexEntropyClustering.medicalTableStr = medicalTableStr;
}
//使用独热编码,将二维字符串数组转化为整型数组
public static int[][] medicalTableOneHot = null;
//所有药物的集合
public static ArrayList<String> medicineList = new ArrayList<String>();
/**
* 初始化方法:获取处方总数、处方中一共有多少种不同药方、生成独热编码的二维整形数组
*/
public static void init(){
//获得处方总和
getPrescriptionSum();
//System.out.println(prescriptionSum);
//获得所有处方中一共有多少种不同的药方
getMedicineList();
//得到使用独热编码的二维整型数组,存储处方和药物的关系
getMedicalTableOneHot();
}
/**
* 计算所有处方的和
*/
public static void getPrescriptionSum() {
prescriptionSum = medicalTableStr.length;
}
/**
* 统计总共有多少味药,并存入一个集合中
*/
public static void getMedicineList() {
for (int i = 0; i < medicalTableStr.length; i++) {
for (int j = 0; j < medicalTableStr[i].size(); j++) {
if (!medicineList.contains(medicalTableStr[i].get(j))) {
medicineList.add(medicalTableStr[i].get(j));
}
}
}
/*for(int i=0;i<medicineList.size();i++){
System.out.println(medicineList.get(i));
}
System.out.println(medicineList.size());*/
}
/**
* 使用独热编码将二维字符串数组转化为整型数组
* 即:当某个药在处方中出现,则设置为1,否则为0
*/
public static void getMedicalTableOneHot() {
int row = prescriptionSum;
int col = medicineList.size();
medicalTableOneHot = new int[row][col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (medicalTableStr[i].contains(medicineList.get(j))) {
medicalTableOneHot[i][j] = 1;
} else {
medicalTableOneHot[i][j] = 0;
}
}
}
/*for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
System.out.print(medicalTableOneHot[i][j]+" ");
}
System.out.println();
}*/
}
/**
* 计算某个药品在处方出现的概率
*
* @param medicineName
* @return 出现的概率
*/
public static double getMedicineExistedRate(String medicineName) {
int count = 0;
for (int i = 0; i < medicineList.size(); i++) {
if (medicineList.get(i).equals(medicineName)) {
for (int j = 0; j < prescriptionSum; j++) {
if (medicalTableOneHot[j][i] == 1) {
count++;
}
}
break;
}
}
//System.out.println(count*1.0/prescriptionSum);
/*if(medicineName.equals("桑白皮")){
System.out.println(medicineName+": "+count);
}*/
double rate = 0;
if (count != 0)
rate = count * 1.0 / prescriptionSum;
return rate;
}
/**
* 计算某个药品在处方不出现的概率
*
* @param medicineName
* @return 不出现的概率
*/
public static double getMedicineNotExistedRate(String medicineName) {
int count = 0;
for (int i = 0; i < medicineList.size(); i++) {
if (medicineList.get(i).equals(medicineName)) {
for (int j = 0; j < prescriptionSum; j++) {
if (medicalTableOneHot[j][i] == 0) {
count++;
}
}
break;
}
}
/*if(medicineName.equals("桑白皮")){
System.out.println(medicineName+": "+count);
}*/
double rate = 0;
if (count != 0)
rate = (count * 1.0 / prescriptionSum);
return rate;
}
/**
* 计算单个药品的熵
*
* @param medicineName
* @return
*/
public static double getOneMedicineEntropy(String medicineName) {
double rate1 = getMedicineExistedRate(medicineName);
double rate2 = getMedicineNotExistedRate(medicineName);
double oneMedicineEntropy = (rate1 * Math.log10(rate1)) + (rate2 * Math.log10(rate2));
return -1.0 * oneMedicineEntropy;
}
/**
* 计算两个药品同时属于某个处方的概率
*
* @param medicine1Name
* @param medicine2Name
* @return
*/
public static double getTwoMedicineOneOneRate(String medicine1Name, String medicine2Name) {
int count = 0;
int a = 0, b = 0;
for (int i = 0; i < medicineList.size(); i++) {
if (medicineList.get(i).equals(medicine1Name)) {
a = i;
}
if (medicineList.get(i).equals(medicine2Name)) {
b = i;
}
}
for (int i = 0; i < prescriptionSum; i++) {
if (medicalTableOneHot[i][a] == 1 && medicalTableOneHot[i][b] == 1) {
count++;
}
}
/*if(medicine1Name.equals("百部")&&medicine2Name.equals("桑白皮")){
System.out.println(count);
}*/
double rate = 0;
if (count != 0)
rate = (count * 1.0 / prescriptionSum);
return rate;
}
/**
* 计算两个药品都不属于某个处方的概率
*
* @param medicine1Name
* @param medicine2Name
* @return
*/
public static double getTwoMedicineZeroZeroRate(String medicine1Name, String medicine2Name) {
int count = 0;
int a = 0, b = 0;
for (int i = 0; i < medicineList.size(); i++) {
if (medicineList.get(i).equals(medicine1Name)) {
a = i;
}
if (medicineList.get(i).equals(medicine2Name)) {
b = i;
}
}
for (int i = 0; i < prescriptionSum; i++) {
if (medicalTableOneHot[i][a] == 0 && medicalTableOneHot[i][b] == 0) {
count++;
}
}
/*if(medicine1Name.equals("百部")&&medicine2Name.equals("桑白皮")){
System.out.println(count);
}*/
double rate = 0;
if (count != 0)
rate = (count * 1.0 / prescriptionSum);
return rate;
}
/**
* 计算第一个属于第二个不属于某个处方的概率
*
* @param medicine1Name
* @param medicine2Name
* @return
*/
public static double getTwoMedicineOneZeroRate(String medicine1Name, String medicine2Name) {
int count = 0;
int a = 0, b = 0;
for (int i = 0; i < medicineList.size(); i++) {
if (medicineList.get(i).equals(medicine1Name)) {
a = i;
}
if (medicineList.get(i).equals(medicine2Name)) {
b = i;
}
}
for (int i = 0; i < prescriptionSum; i++) {
if ((medicalTableOneHot[i][a] == 1 && medicalTableOneHot[i][b] == 0)) {
count++;
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
该项目是一款基于Java核心技术的智能中医药数据分析系统,融合了JavaScript、CSS、HTML等多种前端技术,共计642个文件。其中,170个为GIF动画文件,92个为JavaScript脚本文件,89个为PNG图片文件,66个为Java源代码文件,45个为XML配置文件,42个为编译后的class文件,32个为CSS样式表文件,22个为JSP页面文件,21个为JAR包文件,以及10个HTML文件。系统旨在通过智能数据分析,提升中医药领域的研发与临床应用效率。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java及JavaScript、CSS、HTML的智能中医药数据分析系统设计源码 (642个子文件)
ComplexEntropyClustering.class 10KB
AprioriDemo.class 9KB
Test.class 7KB
AssociationAnalysisServlet.class 7KB
TestTextUtility.class 7KB
UploadFileServlet.class 6KB
FrequencyAnalysis.class 6KB
MedicineStrTest.class 6KB
FrequencyAnalysisServlet.class 6KB
CoreMedicineListServlet.class 5KB
FlusterAnalysisServlet.class 5KB
DataList.class 3KB
HanlpServlet.class 3KB
TestHanlp.class 2KB
tongueTest.class 2KB
TwoMedicineCombination.class 2KB
RedirectServlet.class 2KB
MedicineServlet.class 2KB
BasicServlet.class 2KB
CorrelationCoefficientListData.class 2KB
ComplexEntropyClustering$CorrelationCoefficientCmp.class 2KB
MedicineDao.class 2KB
AssociationData.class 2KB
TwoMedicineMapForClustering.class 2KB
Medicine.class 2KB
FrequencyAnalysis$5.class 1KB
FrequencyAnalysis$3.class 1KB
FrequencyAnalysis$1.class 1KB
ComplexEntropyClustering$CoreMedicineCmp.class 1KB
HanlpService.class 1KB
MedicineStrTableGeneration.class 1KB
CoreMedicine.class 1KB
DBUtil.class 1005B
MedincineStrGeneration.class 1000B
MedicineFreTable.class 991B
FrequencyAnalysis$4.class 979B
FrequencyAnalysis$2.class 977B
DaoTest.class 900B
AssociationFormData.class 824B
UploadFileServlet$1.class 773B
DataDao.class 600B
ComplexEntropyClustering$1.class 260B
bootstrap.css 143KB
bootstrap.css 143KB
bootstrap.min.css 118KB
bootstrap.min.css 118KB
layui.css 93KB
layui.css 93KB
bootstrap-theme.css 26KB
bootstrap-theme.css 26KB
bootstrap-theme.min.css 23KB
bootstrap-theme.min.css 23KB
layer.css 14KB
layer.css 14KB
layui.mobile.css 10KB
layui.mobile.css 10KB
zyUpload.css 8KB
zyUpload.css 8KB
laydate.css 7KB
laydate.css 7KB
showBo.css 3KB
showBo.css 3KB
alertstyle.css 2KB
alertstyle.css 2KB
tongueAnalysisCss.css 2KB
tongueAnalysisCss.css 2KB
code.css 1KB
code.css 1KB
frequencyfunctionDeclartionCSS.css 637B
frequencyfunctionDeclartionCSS.css 637B
fraquencyAnalysis.css 493B
fraquencyAnalysis.css 493B
cssindex.css 240B
cssindex.css 240B
Thumbs.db 8KB
Thumbs.db 8KB
Thumbs.db 8KB
Thumbs.db 8KB
iconfont.eot 46KB
iconfont.eot 46KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
关联分析下载演示.gif 4.12MB
关联分析下载演示.gif 4.12MB
frequency_img3.gif 3.86MB
frequency_img3.gif 3.86MB
frequency_img4.gif 2.69MB
frequency_img4.gif 2.69MB
获取核心药物组合下载演示.gif 2.59MB
获取核心药物组合下载演示.gif 2.59MB
frequency_img2.gif 2.32MB
frequency_img2.gif 2.32MB
获取药物关联度系数下载演示.gif 1.97MB
获取药物关联度系数下载演示.gif 1.97MB
获取药物关联度系数演示.gif 1.79MB
获取药物关联度系数演示.gif 1.79MB
frequency_img1.gif 1.78MB
frequency_img1.gif 1.78MB
关联分析功能演示.gif 1.5MB
关联分析功能演示.gif 1.5MB
共 642 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
lly202406
- 粉丝: 2520
- 资源: 5428
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功