{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cl2: 4 7 3 1 5 4 3 3 10 4 5 5 9 3 10 5 6 8 2 2 1 7 3 1 1 5 9 10 3 2 8 2 8 1 10 2 8 9 6 8 2 6 8 6 5 2 7 4 4 1 5 8 6 1 3 2 6 9 1 1 9 1 4 6 8 6 1 9 8 1 10 1 4 5 2 10 6 8 6 4 3 10 3 9 5 4 9 9 9 5 1 7 10 1 7 10 4 10 3 2 \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "IOPub data rate exceeded.\n", "The notebook server will temporarily stop sending output\n", "to the client in order to avoid crashing it.\n", "To change this limit, set the config variable\n", "`--NotebookApp.iopub_data_rate_limit`.\n", "\n", "Current values:\n", "NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)\n", "NotebookApp.rate_limit_window=3.0 (secs)\n", "\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A matrix: 10 × 1 of type dbl
0.7515000
0.7611857
0.7651143
0.7584012
0.7577496
0.7632258
0.7605238
0.7674000
0.7581286
0.7734583
\n" ], "text/latex": [ "A matrix: 10 × 1 of type dbl\n", "\\begin{tabular}{l}\n", "\t 0.7515000\\\\\n", "\t 0.7611857\\\\\n", "\t 0.7651143\\\\\n", "\t 0.7584012\\\\\n", "\t 0.7577496\\\\\n", "\t 0.7632258\\\\\n", "\t 0.7605238\\\\\n", "\t 0.7674000\\\\\n", "\t 0.7581286\\\\\n", "\t 0.7734583\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A matrix: 10 × 1 of type dbl\n", "\n", "| 0.7515000 |\n", "| 0.7611857 |\n", "| 0.7651143 |\n", "| 0.7584012 |\n", "| 0.7577496 |\n", "| 0.7632258 |\n", "| 0.7605238 |\n", "| 0.7674000 |\n", "| 0.7581286 |\n", "| 0.7734583 |\n", "\n" ], "text/plain": [ " [,1] \n", " [1,] 0.7515000\n", " [2,] 0.7611857\n", " [3,] 0.7651143\n", " [4,] 0.7584012\n", " [5,] 0.7577496\n", " [6,] 0.7632258\n", " [7,] 0.7605238\n", " [8,] 0.7674000\n", " [9,] 0.7581286\n", "[10,] 0.7734583" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "number_cl=10\n", "ind <- 0\n", "JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n", "#cat(JI_final,\"\\n\")\n", "# Read clusters imposed on simulated data \n", "cl <- as.matrix(read.table(\"../data/simulations_20210329212141/equal/10/clusters.txt\", \n", " sep=\"\\t\", row.names=1, header=TRUE))\n", "#cat(\"cl:\",cl,\"\\t\")\n", "cl2 <- as.matrix(as.numeric(cl[,2]))\n", "cat(\"cl2:\",cl2[,1],\"\\n\")\n", "rownames(cl2) <- cl[,1]\n", "\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/AE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/AE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/DAE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/DAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "factorization=read.table(\"../data/simulations_20210329212141/equal/10/VAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/LSTMVAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "\n", "\n", "\n", "factors <- factorization\n", "#factors <- factorizations[[i]][[1]]\n", "\n", "#print(factors)\n", "# Clustering by Kmeans\n", "JI_good <- numeric(0)\n", "for (run in 1:1000) {\n", "kmeans.out <- kmeans(factors, centers=number_cl) \n", "clust_iCluster <- as.matrix(kmeans.out$cluster)\n", "cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n", "######creation sets of samples\n", "JI_mat <- numeric(0)\n", "for (p in 1:number_cl) {\n", " x1 <- rownames(clust_iCluster)[which(clust_iCluster[,1]==p)]\n", " print(x1)\n", "\n", " row <- numeric(0)\n", " for(j in 1:number_cl) {\n", " x2 <- rownames(cl2)[which(cl2[,1]==j)]\n", " cat(\"x2:\",x2,\"\\n\")\n", " I <- length(intersect(x1,x2))#交集\n", " cat(\"I:\",I,\"\\n\")\n", " S <- I/(length(x1)+length(x2)-I)\n", " cat(\"S:\",S,\"\\n\")\n", " row <- cbind(row,S)\n", " cat(\"row:\",row,\"\\n\")\n", " }\n", " JI_mat <- rbind(JI_mat,row)\n", " cat(\"JI_mat:\",JI_mat,\"\\n\")\n", " print(JI_mat)\n", "\n", "\n", " }\n", " JI_good <- rbind(JI_good,apply(JI_mat,1,max))\n", " cat(\"JI_good:\",JI_good,\"\\n\")\n", "}\n", "JI_final[1:number_cl] <- apply(JI_good,2,mean)\n", "JI_final" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cl2: 4 7 3 1 5 4 3 3 10 4 5 5 9 3 10 5 6 8 2 2 1 7 3 1 1 5 9 10 3 2 8 2 8 1 10 2 8 9 6 8 2 6 8 6 5 2 7 4 4 1 5 8 6 1 3 2 6 9 1 1 9 1 4 6 8 6 1 9 8 1 10 1 4 5 2 10 6 8 6 4 3 10 3 9 5 4 9 9 9 5 1 7 10 1 7 10 4 10 3 2 \n" ] } ], "source": [ "number_cl=10\n", "ind <- 0\n", "JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n", "#cat(JI_final,\"\\n\")\n", "# Read clusters imposed on simulated data \n", "cl <- as.matrix(read.table(\"../data/simulations_20210329212141/equal/10/clusters.txt\", \n", " sep=\"\\t\", row.names=1, header=TRUE))\n", "#cat(\"cl:\",cl,\"\\t\")\n", "cl2 <- as.matrix(as.numeric(cl[,2]))\n", "cat(\"cl2:\",cl2[,1],\"\\n\")\n", "rownames(cl2) <- cl[,1]\n", "\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/AE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/AE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/DAE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/DAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "factorization=read.table(\"../data/simulations_20210329212141/equal/10/VAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/LSTMVAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "\n", "\n", "\n", "factors <- factorization\n", "\n", "# Clustering by Kmeans\n", "JI_good <- numeric(0)\n", "for (run in 1:100) {\n", "kmeans.out <- kmeans(factors, centers=number_cl) \n", "clust_iCluster <- as.matrix(kmeans.out$cluster)\n", "cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n", "######creation sets of samples\n", "JI_mat <- numeric(0)\n", "for (p in 1:number_cl) {\n", " x1 <- rownames(clust_iCluster)[which(clust_iCluster[,1]==p)]\n", " print(x1)\n", "\n", " row <- numeric(0)\n", " for(j in 1:number_cl) {\n", " x2 <- rownames(cl2)[which(cl2[,1]==j)]\n", " cat(\"x2:\",x2,\"\\n\")\n", " I <- length(intersect(x1,x2))#交集\n", " cat(\"I:\",I,\"\\n\")\n", " S <- I/(length(x1)+length(x2)-I)\n", " cat(\"S:\",S,\"\\n\")\n", " row <- cbind(row,S)\n", " cat(\"row:\",row,\"\\n\")\n", " }\n", " JI_mat <- rbind(JI_mat,row)\n", " cat(\"JI_mat:\",JI_mat,\"\\n\")\n", " print(JI_mat)\n", "\n", "\n", " }\n", " JI_good <- rbind(JI_good,apply(JI_mat,1,max))\n", " cat(\"JI_good:\",JI_good,\"\\n\")\n", "}\n", "JI_final[1:number_cl] <- apply(JI_good,2,mean)\n", "JI_final" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "number_cl=10\n", "ind <- 0\n", "JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n", "#cat(JI_final,\"\\n\")\n", "# Read clusters imposed on simulated data \n", "cl <- as.matrix(read.table(\"../data/simulations_20210329212141/equal/10/clusters.txt\", \n", " sep=\"\\t\", row.names=1, header=TRUE))\n", "#cat(\"cl:\",cl,\"\\t\")\n", "cl2 <- as.matrix(as.numeric(cl[,2]))\n", "cat(\"cl2:\",cl2[,1],\"\\n\")\n", "rownames(cl2) <- cl[,1]\n", "\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/AE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/AE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/DAE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/DAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/10/VAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "factorization=read.table(\"../data/simulations_20210329212141/equal/10/LSTMVAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "\n", "\n", "\n", "factors <- factorization\n", "#factors <- factorizations[[i]][[1]]\n", "\n", "#print(factors)\n", "# Clustering by Kmeans\n", "JI_good <- numeric(0)\n", "for (run in 1:100) {\n", "kmeans.out <- kmeans(factors, centers=number_cl) \n", "clust_iCluster <- as.matrix(kmeans.out$cluster)\n", "cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n", "######creation sets of samples\n", "JI_mat <- numeric(0)\n", "for (p in 1:number_cl) {\n", " x1 <- rownames(clust_iCluster)[which(clust_iCluster[,1]==p)]\n", " print(x1)\n", "\n", " row <- numeric(0)\n", " for(j in 1:number_cl) {\n", " x2 <- rownames(cl2)[which(cl2[,1]==j)]\n", " cat(\"x2:\",x2,\"\\n\")\n", " I <- length(intersect(x1,x2))#交集\n", " cat(\"I:\",I,\"\\n\")\n", " S <- I/(length(x1)+length(x2)-I)\n", " cat(\"S:\",S,\"\\n\")\n", " row <- cbind(row,S)\n", " cat(\"row:\",row,\"\\n\")\n", " }\n", " JI_mat <- rbind(JI_mat,row)\n", " cat(\"JI_mat:\",JI_mat,\"\\n\")\n", " print(JI_mat)\n", "\n", "\n", " }\n", " JI_good <- rbind(JI_good,apply(JI_mat,1,max))\n", " cat(\"JI_good:\",JI_good,\"\\n\")\n", "}\n", "JI_final[1:number_cl] <- apply(JI_good,2,mean)\n", "JI_final" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "number_cl=15\n", "ind <- 0\n", "JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n", "#cat(JI_final,\"\\n\")\n", "# Read clusters imposed on simulated data \n", "cl <- as.matrix(read.table(\"../data/simulations_20210329212141/equal/15/clusters.txt\", \n", " sep=\"\\t\", row.names=1, header=TRUE))\n", "#cat(\"cl:\",cl,\"\\t\")\n", "cl2 <- as.matrix(as.numeric(cl[,2]))\n", "cat(\"cl2:\",cl2[,1],\"\\n\")\n", "rownames(cl2) <- cl[,1]\n", "\n", "factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/VAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/LSTMVAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "\n", "\n", "\n", "factors <- factorization\n", "#factors <- factorizations[[i]][[1]]\n", "\n", "#print(factors)\n", "# Clustering by Kmeans\n", "JI_good <- numeric(0)\n", "for (run in 1:1000) {\n", "kmeans.out <- kmeans(factors, centers=number_cl) \n", "clust_iCluster <- as.matrix(kmeans.out$cluster)\n", "cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n", "######creation sets of samples\n", "JI_mat <- numeric(0)\n", "for (p in 1:number_cl) {\n", " x1 <- rownames(clust_iCluster)[which(clust_iCluster[,1]==p)]\n", " print(x1)\n", "\n", " row <- numeric(0)\n", " for(j in 1:number_cl) {\n", " x2 <- rownames(cl2)[which(cl2[,1]==j)]\n", " #cat(\"x2:\",x2,\"\\n\")\n", " I <- length(intersect(x1,x2))#交集\n", " #cat(\"I:\",I,\"\\n\")\n", " S <- I/(length(x1)+length(x2)-I)\n", " #cat(\"S:\",S,\"\\n\")\n", " row <- cbind(row,S)\n", " #cat(\"row:\",row,\"\\n\")\n", " }\n", " JI_mat <- rbind(JI_mat,row)\n", " cat(\"JI_mat:\",JI_mat,\"\\n\")\n", " print(JI_mat)\n", "\n", "\n", " }\n", " JI_good <- rbind(JI_good,apply(JI_mat,1,max))\n", " cat(\"JI_good:\",JI_good,\"\\n\")\n", "}\n", "JI_final[1:number_cl] <- apply(JI_good,2,mean)\n", "JI_final" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cl2: 7 7 12 2 5 15 7 10 15 8 13 4 3 7 15 10 2 2 9 14 2 13 10 10 13 8 1 9 10 11 12 15 9 2 12 14 6 11 3 1 5 8 6 2 13 11 5 4 8 7 5 1 1 12 14 15 3 9 5 10 1 13 11 6 5 3 4 6 6 8 3 9 11 6 14 14 7 13 6 4 9 15 13 11 12 11 2 5 3 9 15 14 4 1 1 7 8 12 4 3 \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "IOPub data rate exceeded.\n", "The notebook server will temporarily stop sending output\n", "to the client in order to avoid crashing it.\n", "To change this limit, set the config variable\n", "`--NotebookApp.iopub_data_rate_limit`.\n", "\n", "Current values:\n", "NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)\n", "NotebookApp.rate_limit_window=3.0 (secs)\n", "\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A matrix: 15 × 1 of type dbl
0.7989517
0.8052115
0.8019024
0.8157678
0.7945885
0.8191150
0.8043023
0.8144615
0.8061806
0.8206591
0.8057421
0.7979146
0.8153197
0.8033851
0.8177235
\n" ], "text/latex": [ "A matrix: 15 × 1 of type dbl\n", "\\begin{tabular}{l}\n", "\t 0.7989517\\\\\n", "\t 0.8052115\\\\\n", "\t 0.8019024\\\\\n", "\t 0.8157678\\\\\n", "\t 0.7945885\\\\\n", "\t 0.8191150\\\\\n", "\t 0.8043023\\\\\n", "\t 0.8144615\\\\\n", "\t 0.8061806\\\\\n", "\t 0.8206591\\\\\n", "\t 0.8057421\\\\\n", "\t 0.7979146\\\\\n", "\t 0.8153197\\\\\n", "\t 0.8033851\\\\\n", "\t 0.8177235\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A matrix: 15 × 1 of type dbl\n", "\n", "| 0.7989517 |\n", "| 0.8052115 |\n", "| 0.8019024 |\n", "| 0.8157678 |\n", "| 0.7945885 |\n", "| 0.8191150 |\n", "| 0.8043023 |\n", "| 0.8144615 |\n", "| 0.8061806 |\n", "| 0.8206591 |\n", "| 0.8057421 |\n", "| 0.7979146 |\n", "| 0.8153197 |\n", "| 0.8033851 |\n", "| 0.8177235 |\n", "\n" ], "text/plain": [ " [,1] \n", " [1,] 0.7989517\n", " [2,] 0.8052115\n", " [3,] 0.8019024\n", " [4,] 0.8157678\n", " [5,] 0.7945885\n", " [6,] 0.8191150\n", " [7,] 0.8043023\n", " [8,] 0.8144615\n", " [9,] 0.8061806\n", "[10,] 0.8206591\n", "[11,] 0.8057421\n", "[12,] 0.7979146\n", "[13,] 0.8153197\n", "[14,] 0.8033851\n", "[15,] 0.8177235" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "number_cl=15\n", "ind <- 0\n", "JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n", "#cat(JI_final,\"\\n\")\n", "# Read clusters imposed on simulated data \n", "cl <- as.matrix(read.table(\"../data/simulations_20210329212141/equal/15/clusters.txt\", \n", " sep=\"\\t\", row.names=1, header=TRUE))\n", "#cat(\"cl:\",cl,\"\\t\")\n", "cl2 <- as.matrix(as.numeric(cl[,2]))\n", "cat(\"cl2:\",cl2[,1],\"\\n\")\n", "rownames(cl2) <- cl[,1]\n", "\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/VAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/LSTMVAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "\n", "\n", "\n", "factors <- factorization\n", "#factors <- factorizations[[i]][[1]]\n", "\n", "#print(factors)\n", "# Clustering by Kmeans\n", "JI_good <- numeric(0)\n", "for (run in 1:1000) {\n", "kmeans.out <- kmeans(factors, centers=number_cl) \n", "clust_iCluster <- as.matrix(kmeans.out$cluster)\n", "cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n", "######creation sets of samples\n", "JI_mat <- numeric(0)\n", "for (p in 1:number_cl) {\n", " x1 <- rownames(clust_iCluster)[which(clust_iCluster[,1]==p)]\n", " print(x1)\n", "\n", " row <- numeric(0)\n", " for(j in 1:number_cl) {\n", " x2 <- rownames(cl2)[which(cl2[,1]==j)]\n", " cat(\"x2:\",x2,\"\\n\")\n", " I <- length(intersect(x1,x2))#交集\n", " cat(\"I:\",I,\"\\n\")\n", " S <- I/(length(x1)+length(x2)-I)\n", " cat(\"S:\",S,\"\\n\")\n", " row <- cbind(row,S)\n", " cat(\"row:\",row,\"\\n\")\n", " }\n", " JI_mat <- rbind(JI_mat,row)\n", " cat(\"JI_mat:\",JI_mat,\"\\n\")\n", " print(JI_mat)\n", "\n", "\n", " }\n", " JI_good <- rbind(JI_good,apply(JI_mat,1,max))\n", " cat(\"JI_good:\",JI_good,\"\\n\")\n", "}\n", "JI_final[1:number_cl] <- apply(JI_good,2,mean)\n", "JI_final" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cl2: 7 7 12 2 5 15 7 10 15 8 13 4 3 7 15 10 2 2 9 14 2 13 10 10 13 8 1 9 10 11 12 15 9 2 12 14 6 11 3 1 5 8 6 2 13 11 5 4 8 7 5 1 1 12 14 15 3 9 5 10 1 13 11 6 5 3 4 6 6 8 3 9 11 6 14 14 7 13 6 4 9 15 13 11 12 11 2 5 3 9 15 14 4 1 1 7 8 12 4 3 \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "IOPub data rate exceeded.\n", "The notebook server will temporarily stop sending output\n", "to the client in order to avoid crashing it.\n", "To change this limit, set the config variable\n", "`--NotebookApp.iopub_data_rate_limit`.\n", "\n", "Current values:\n", "NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)\n", "NotebookApp.rate_limit_window=3.0 (secs)\n", "\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A matrix: 15 × 1 of type dbl
0.7532231
0.7563619
0.7594553
0.7525584
0.7487293
0.7492135
0.7440258
0.7524720
0.7362969
0.7606681
0.7808652
0.7486006
0.7620518
0.7535825
0.7502729
\n" ], "text/latex": [ "A matrix: 15 × 1 of type dbl\n", "\\begin{tabular}{l}\n", "\t 0.7532231\\\\\n", "\t 0.7563619\\\\\n", "\t 0.7594553\\\\\n", "\t 0.7525584\\\\\n", "\t 0.7487293\\\\\n", "\t 0.7492135\\\\\n", "\t 0.7440258\\\\\n", "\t 0.7524720\\\\\n", "\t 0.7362969\\\\\n", "\t 0.7606681\\\\\n", "\t 0.7808652\\\\\n", "\t 0.7486006\\\\\n", "\t 0.7620518\\\\\n", "\t 0.7535825\\\\\n", "\t 0.7502729\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A matrix: 15 × 1 of type dbl\n", "\n", "| 0.7532231 |\n", "| 0.7563619 |\n", "| 0.7594553 |\n", "| 0.7525584 |\n", "| 0.7487293 |\n", "| 0.7492135 |\n", "| 0.7440258 |\n", "| 0.7524720 |\n", "| 0.7362969 |\n", "| 0.7606681 |\n", "| 0.7808652 |\n", "| 0.7486006 |\n", "| 0.7620518 |\n", "| 0.7535825 |\n", "| 0.7502729 |\n", "\n" ], "text/plain": [ " [,1] \n", " [1,] 0.7532231\n", " [2,] 0.7563619\n", " [3,] 0.7594553\n", " [4,] 0.7525584\n", " [5,] 0.7487293\n", " [6,] 0.7492135\n", " [7,] 0.7440258\n", " [8,] 0.7524720\n", " [9,] 0.7362969\n", "[10,] 0.7606681\n", "[11,] 0.7808652\n", "[12,] 0.7486006\n", "[13,] 0.7620518\n", "[14,] 0.7535825\n", "[15,] 0.7502729" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "number_cl=15\n", "ind <- 0\n", "JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n", "#cat(JI_final,\"\\n\")\n", "# Read clusters imposed on simulated data \n", "cl <- as.matrix(read.table(\"../data/simulations_20210329212141/equal/15/clusters.txt\", \n", " sep=\"\\t\", row.names=1, header=TRUE))\n", "#cat(\"cl:\",cl,\"\\t\")\n", "cl2 <- as.matrix(as.numeric(cl[,2]))\n", "cat(\"cl2:\",cl2[,1],\"\\n\")\n", "rownames(cl2) <- cl[,1]\n", "\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/VAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/LSTMVAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "\n", "\n", "\n", "factors <- factorization\n", "#factors <- factorizations[[i]][[1]]\n", "\n", "#print(factors)\n", "# Clustering by Kmeans\n", "JI_good <- numeric(0)\n", "for (run in 1:1000) {\n", "kmeans.out <- kmeans(factors, centers=number_cl) \n", "clust_iCluster <- as.matrix(kmeans.out$cluster)\n", "cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n", "######creation sets of samples\n", "JI_mat <- numeric(0)\n", "for (p in 1:number_cl) {\n", " x1 <- rownames(clust_iCluster)[which(clust_iCluster[,1]==p)]\n", " print(x1)\n", "\n", " row <- numeric(0)\n", " for(j in 1:number_cl) {\n", " x2 <- rownames(cl2)[which(cl2[,1]==j)]\n", " cat(\"x2:\",x2,\"\\n\")\n", " I <- length(intersect(x1,x2))#交集\n", " cat(\"I:\",I,\"\\n\")\n", " S <- I/(length(x1)+length(x2)-I)\n", " cat(\"S:\",S,\"\\n\")\n", " row <- cbind(row,S)\n", " cat(\"row:\",row,\"\\n\")\n", " }\n", " JI_mat <- rbind(JI_mat,row)\n", " cat(\"JI_mat:\",JI_mat,\"\\n\")\n", " print(JI_mat)\n", "\n", "\n", " }\n", " JI_good <- rbind(JI_good,apply(JI_mat,1,max))\n", " cat(\"JI_good:\",JI_good,\"\\n\")\n", "}\n", "JI_final[1:number_cl] <- apply(JI_good,2,mean)\n", "JI_final" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cl2: 7 7 12 2 5 15 7 10 15 8 13 4 3 7 15 10 2 2 9 14 2 13 10 10 13 8 1 9 10 11 12 15 9 2 12 14 6 11 3 1 5 8 6 2 13 11 5 4 8 7 5 1 1 12 14 15 3 9 5 10 1 13 11 6 5 3 4 6 6 8 3 9 11 6 14 14 7 13 6 4 9 15 13 11 12 11 2 5 3 9 15 14 4 1 1 7 8 12 4 3 \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "IOPub data rate exceeded.\n", "The notebook server will temporarily stop sending output\n", "to the client in order to avoid crashing it.\n", "To change this limit, set the config variable\n", "`--NotebookApp.iopub_data_rate_limit`.\n", "\n", "Current values:\n", "NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)\n", "NotebookApp.rate_limit_window=3.0 (secs)\n", "\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A matrix: 15 × 1 of type dbl
0.7940330
0.8056647
0.7995865
0.7820629
0.7863840
0.7954261
0.7985005
0.7922929
0.7948400
0.8013052
0.8022179
0.7860330
0.8102876
0.7921890
0.7864014
\n" ], "text/latex": [ "A matrix: 15 × 1 of type dbl\n", "\\begin{tabular}{l}\n", "\t 0.7940330\\\\\n", "\t 0.8056647\\\\\n", "\t 0.7995865\\\\\n", "\t 0.7820629\\\\\n", "\t 0.7863840\\\\\n", "\t 0.7954261\\\\\n", "\t 0.7985005\\\\\n", "\t 0.7922929\\\\\n", "\t 0.7948400\\\\\n", "\t 0.8013052\\\\\n", "\t 0.8022179\\\\\n", "\t 0.7860330\\\\\n", "\t 0.8102876\\\\\n", "\t 0.7921890\\\\\n", "\t 0.7864014\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A matrix: 15 × 1 of type dbl\n", "\n", "| 0.7940330 |\n", "| 0.8056647 |\n", "| 0.7995865 |\n", "| 0.7820629 |\n", "| 0.7863840 |\n", "| 0.7954261 |\n", "| 0.7985005 |\n", "| 0.7922929 |\n", "| 0.7948400 |\n", "| 0.8013052 |\n", "| 0.8022179 |\n", "| 0.7860330 |\n", "| 0.8102876 |\n", "| 0.7921890 |\n", "| 0.7864014 |\n", "\n" ], "text/plain": [ " [,1] \n", " [1,] 0.7940330\n", " [2,] 0.8056647\n", " [3,] 0.7995865\n", " [4,] 0.7820629\n", " [5,] 0.7863840\n", " [6,] 0.7954261\n", " [7,] 0.7985005\n", " [8,] 0.7922929\n", " [9,] 0.7948400\n", "[10,] 0.8013052\n", "[11,] 0.8022179\n", "[12,] 0.7860330\n", "[13,] 0.8102876\n", "[14,] 0.7921890\n", "[15,] 0.7864014" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "number_cl=15\n", "ind <- 0\n", "JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n", "#cat(JI_final,\"\\n\")\n", "# Read clusters imposed on simulated data \n", "cl <- as.matrix(read.table(\"../data/simulations_20210329212141/equal/15/clusters.txt\", \n", " sep=\"\\t\", row.names=1, header=TRUE))\n", "#cat(\"cl:\",cl,\"\\t\")\n", "cl2 <- as.matrix(as.numeric(cl[,2]))\n", "cat(\"cl2:\",cl2[,1],\"\\n\")\n", "rownames(cl2) <- cl[,1]\n", "\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/VAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/LSTMVAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "\n", "\n", "\n", "factors <- factorization\n", "#factors <- factorizations[[i]][[1]]\n", "\n", "#print(factors)\n", "# Clustering by Kmeans\n", "JI_good <- numeric(0)\n", "for (run in 1:1000) {\n", "kmeans.out <- kmeans(factors, centers=number_cl) \n", "clust_iCluster <- as.matrix(kmeans.out$cluster)\n", "cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n", "######creation sets of samples\n", "JI_mat <- numeric(0)\n", "for (p in 1:number_cl) {\n", " x1 <- rownames(clust_iCluster)[which(clust_iCluster[,1]==p)]\n", " print(x1)\n", "\n", " row <- numeric(0)\n", " for(j in 1:number_cl) {\n", " x2 <- rownames(cl2)[which(cl2[,1]==j)]\n", " cat(\"x2:\",x2,\"\\n\")\n", " I <- length(intersect(x1,x2))#交集\n", " cat(\"I:\",I,\"\\n\")\n", " S <- I/(length(x1)+length(x2)-I)\n", " cat(\"S:\",S,\"\\n\")\n", " row <- cbind(row,S)\n", " cat(\"row:\",row,\"\\n\")\n", " }\n", " JI_mat <- rbind(JI_mat,row)\n", " cat(\"JI_mat:\",JI_mat,\"\\n\")\n", " print(JI_mat)\n", "\n", "\n", " }\n", " JI_good <- rbind(JI_good,apply(JI_mat,1,max))\n", " cat(\"JI_good:\",JI_good,\"\\n\")\n", "}\n", "JI_final[1:number_cl] <- apply(JI_good,2,mean)\n", "JI_final" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cl2: 7 7 12 2 5 15 7 10 15 8 13 4 3 7 15 10 2 2 9 14 2 13 10 10 13 8 1 9 10 11 12 15 9 2 12 14 6 11 3 1 5 8 6 2 13 11 5 4 8 7 5 1 1 12 14 15 3 9 5 10 1 13 11 6 5 3 4 6 6 8 3 9 11 6 14 14 7 13 6 4 9 15 13 11 12 11 2 5 3 9 15 14 4 1 1 7 8 12 4 3 \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "IOPub data rate exceeded.\n", "The notebook server will temporarily stop sending output\n", "to the client in order to avoid crashing it.\n", "To change this limit, set the config variable\n", "`--NotebookApp.iopub_data_rate_limit`.\n", "\n", "Current values:\n", "NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)\n", "NotebookApp.rate_limit_window=3.0 (secs)\n", "\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A matrix: 15 × 1 of type dbl
0.7365600
0.7399893
0.7380597
0.7495614
0.7558608
0.7513054
0.7519942
0.7433741
0.7291959
0.7450379
0.7317692
0.7382499
0.7398166
0.7516091
0.7268284
\n" ], "text/latex": [ "A matrix: 15 × 1 of type dbl\n", "\\begin{tabular}{l}\n", "\t 0.7365600\\\\\n", "\t 0.7399893\\\\\n", "\t 0.7380597\\\\\n", "\t 0.7495614\\\\\n", "\t 0.7558608\\\\\n", "\t 0.7513054\\\\\n", "\t 0.7519942\\\\\n", "\t 0.7433741\\\\\n", "\t 0.7291959\\\\\n", "\t 0.7450379\\\\\n", "\t 0.7317692\\\\\n", "\t 0.7382499\\\\\n", "\t 0.7398166\\\\\n", "\t 0.7516091\\\\\n", "\t 0.7268284\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A matrix: 15 × 1 of type dbl\n", "\n", "| 0.7365600 |\n", "| 0.7399893 |\n", "| 0.7380597 |\n", "| 0.7495614 |\n", "| 0.7558608 |\n", "| 0.7513054 |\n", "| 0.7519942 |\n", "| 0.7433741 |\n", "| 0.7291959 |\n", "| 0.7450379 |\n", "| 0.7317692 |\n", "| 0.7382499 |\n", "| 0.7398166 |\n", "| 0.7516091 |\n", "| 0.7268284 |\n", "\n" ], "text/plain": [ " [,1] \n", " [1,] 0.7365600\n", " [2,] 0.7399893\n", " [3,] 0.7380597\n", " [4,] 0.7495614\n", " [5,] 0.7558608\n", " [6,] 0.7513054\n", " [7,] 0.7519942\n", " [8,] 0.7433741\n", " [9,] 0.7291959\n", "[10,] 0.7450379\n", "[11,] 0.7317692\n", "[12,] 0.7382499\n", "[13,] 0.7398166\n", "[14,] 0.7516091\n", "[15,] 0.7268284" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "number_cl=15\n", "ind <- 0\n", "JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n", "#cat(JI_final,\"\\n\")\n", "# Read clusters imposed on simulated data \n", "cl <- as.matrix(read.table(\"../data/simulations_20210329212141/equal/15/clusters.txt\", \n", " sep=\"\\t\", row.names=1, header=TRUE))\n", "#cat(\"cl:\",cl,\"\\t\")\n", "cl2 <- as.matrix(as.numeric(cl[,2]))\n", "cat(\"cl2:\",cl2[,1],\"\\n\")\n", "rownames(cl2) <- cl[,1]\n", "\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "factorization=read.table(\"../data/simulations_20210329212141/equal/15/VAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/LSTMVAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "\n", "\n", "\n", "factors <- factorization\n", "#factors <- factorizations[[i]][[1]]\n", "\n", "#print(factors)\n", "# Clustering by Kmeans\n", "JI_good <- numeric(0)\n", "for (run in 1:1000) {\n", "kmeans.out <- kmeans(factors, centers=number_cl) \n", "clust_iCluster <- as.matrix(kmeans.out$cluster)\n", "cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n", "######creation sets of samples\n", "JI_mat <- numeric(0)\n", "for (p in 1:number_cl) {\n", " x1 <- rownames(clust_iCluster)[which(clust_iCluster[,1]==p)]\n", " print(x1)\n", "\n", " row <- numeric(0)\n", " for(j in 1:number_cl) {\n", " x2 <- rownames(cl2)[which(cl2[,1]==j)]\n", " cat(\"x2:\",x2,\"\\n\")\n", " I <- length(intersect(x1,x2))#交集\n", " cat(\"I:\",I,\"\\n\")\n", " S <- I/(length(x1)+length(x2)-I)\n", " cat(\"S:\",S,\"\\n\")\n", " row <- cbind(row,S)\n", " cat(\"row:\",row,\"\\n\")\n", " }\n", " JI_mat <- rbind(JI_mat,row)\n", " cat(\"JI_mat:\",JI_mat,\"\\n\")\n", " print(JI_mat)\n", "\n", "\n", " }\n", " JI_good <- rbind(JI_good,apply(JI_mat,1,max))\n", " cat(\"JI_good:\",JI_good,\"\\n\")\n", "}\n", "JI_final[1:number_cl] <- apply(JI_good,2,mean)\n", "JI_final" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cl2: 7 7 12 2 5 15 7 10 15 8 13 4 3 7 15 10 2 2 9 14 2 13 10 10 13 8 1 9 10 11 12 15 9 2 12 14 6 11 3 1 5 8 6 2 13 11 5 4 8 7 5 1 1 12 14 15 3 9 5 10 1 13 11 6 5 3 4 6 6 8 3 9 11 6 14 14 7 13 6 4 9 15 13 11 12 11 2 5 3 9 15 14 4 1 1 7 8 12 4 3 \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "IOPub data rate exceeded.\n", "The notebook server will temporarily stop sending output\n", "to the client in order to avoid crashing it.\n", "To change this limit, set the config variable\n", "`--NotebookApp.iopub_data_rate_limit`.\n", "\n", "Current values:\n", "NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)\n", "NotebookApp.rate_limit_window=3.0 (secs)\n", "\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A matrix: 15 × 1 of type dbl
0.4727026
0.4756525
0.4718643
0.4635589
0.4793765
0.4613873
0.4629963
0.4653092
0.4717958
0.4745232
0.4752839
0.4738429
0.4763239
0.4642153
0.4669012
\n" ], "text/latex": [ "A matrix: 15 × 1 of type dbl\n", "\\begin{tabular}{l}\n", "\t 0.4727026\\\\\n", "\t 0.4756525\\\\\n", "\t 0.4718643\\\\\n", "\t 0.4635589\\\\\n", "\t 0.4793765\\\\\n", "\t 0.4613873\\\\\n", "\t 0.4629963\\\\\n", "\t 0.4653092\\\\\n", "\t 0.4717958\\\\\n", "\t 0.4745232\\\\\n", "\t 0.4752839\\\\\n", "\t 0.4738429\\\\\n", "\t 0.4763239\\\\\n", "\t 0.4642153\\\\\n", "\t 0.4669012\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A matrix: 15 × 1 of type dbl\n", "\n", "| 0.4727026 |\n", "| 0.4756525 |\n", "| 0.4718643 |\n", "| 0.4635589 |\n", "| 0.4793765 |\n", "| 0.4613873 |\n", "| 0.4629963 |\n", "| 0.4653092 |\n", "| 0.4717958 |\n", "| 0.4745232 |\n", "| 0.4752839 |\n", "| 0.4738429 |\n", "| 0.4763239 |\n", "| 0.4642153 |\n", "| 0.4669012 |\n", "\n" ], "text/plain": [ " [,1] \n", " [1,] 0.4727026\n", " [2,] 0.4756525\n", " [3,] 0.4718643\n", " [4,] 0.4635589\n", " [5,] 0.4793765\n", " [6,] 0.4613873\n", " [7,] 0.4629963\n", " [8,] 0.4653092\n", " [9,] 0.4717958\n", "[10,] 0.4745232\n", "[11,] 0.4752839\n", "[12,] 0.4738429\n", "[13,] 0.4763239\n", "[14,] 0.4642153\n", "[15,] 0.4669012" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "number_cl=15\n", "ind <- 0\n", "JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n", "#cat(JI_final,\"\\n\")\n", "# Read clusters imposed on simulated data \n", "cl <- as.matrix(read.table(\"../data/simulations_20210329212141/equal/15/clusters.txt\", \n", " sep=\"\\t\", row.names=1, header=TRUE))\n", "#cat(\"cl:\",cl,\"\\t\")\n", "cl2 <- as.matrix(as.numeric(cl[,2]))\n", "cat(\"cl2:\",cl2[,1],\"\\n\")\n", "rownames(cl2) <- cl[,1]\n", "\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/AE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FAETC_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/DAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "#factorization=read.table(\"../data/simulations_20210329212141/equal/15/VAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "factorization=read.table(\"../data/simulations_20210329212141/equal/15/LSTMVAE_FCTAE_EM.txt\", sep=\" \", row.names=cl[,1],header=FALSE)\n", "\n", "\n", "\n", "factors <- factorization\n", "#factors <- factorizations[[i]][[1]]\n", "\n", "#print(factors)\n", "# Clustering by Kmeans\n", "JI_good <- numeric(0)\n", "for (run in 1:1000) {\n", "kmeans.out <- kmeans(factors, centers=number_cl) \n", "clust_iCluster <- as.matrix(kmeans.out$cluster)\n", "cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n", "######creation sets of samples\n", "JI_mat <- numeric(0)\n", "for (p in 1:number_cl) {\n", " x1 <- rownames(clust_iCluster)[which(clust_iCluster[,1]==p)]\n", " print(x1)\n", "\n", " row <- numeric(0)\n", " for(j in 1:number_cl) {\n", " x2 <- rownames(cl2)[which(cl2[,1]==j)]\n", " cat(\"x2:\",x2,\"\\n\")\n", " I <- length(intersect(x1,x2))#交集\n", " cat(\"I:\",I,\"\\n\")\n", " S <- I/(length(x1)+length(x2)-I)\n", " cat(\"S:\",S,\"\\n\")\n", " row <- cbind(row,S)\n", " cat(\"row:\",row,\"\\n\")\n", " }\n", " JI_mat <- rbind(JI_mat,row)\n", " cat(\"JI_mat:\",JI_mat,\"\\n\")\n", " print(JI_mat)\n", "\n", "\n", " }\n", " JI_good <- rbind(JI_good,apply(JI_mat,1,max))\n", " cat(\"JI_good:\",JI_good,\"\\n\")\n", "}\n", "JI_final[1:number_cl] <- apply(JI_good,2,mean)\n", "JI_final" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "R", "language": "R", "name": "ir" }, "language_info": { "codemirror_mode": "r", "file_extension": ".r", "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", "version": "3.5.1" } }, "nbformat": 4, "nbformat_minor": 4 }