diff --git a/Jupyter Notebook/Modelling_of_features_in_R.R b/Jupyter Notebook/Modelling_of_features_in_R.R new file mode 100644 index 0000000000000000000000000000000000000000..18ed4d490b042a207917dbe428d563d3514302be --- /dev/null +++ b/Jupyter Notebook/Modelling_of_features_in_R.R @@ -0,0 +1,77 @@ +getwd() +setwd("C:\\Users\\Ankit\\Desktop") +getwd() + +library(visNetwork) +library(bnlearn) +library(ggplot2) + + +df <- read.csv("C:\\Users\\Ankit\\Desktop\\recent_features.csv") + + +df <- as.numeric(df) + +df[1:35] <- lapply(df[1:35], as.numeric) +df[36] <- lapply(df[36], as.factor) +res <- hc(df) +str(df) + +plot.network <- function(structure, ht = "400px"){ + + nodes.uniq <- unique(c(structure$arcs[,1], structure$arcs[,2])) + + nodes <- data.frame(id = nodes.uniq, + + label = nodes.uniq, + + color = "darkturquoise", + + shadow = TRUE) + + + + edges <- data.frame(from = structure$arcs[,1], + + to = structure$arcs[,2], + + arrows = "to", + + smooth = TRUE, + + shadow = TRUE, + + color = "black") + + + + return(visNetwork(nodes, edges, height = ht, width = "100%")) + +} + + + + +plot.network(res) +#df$ +plot(res) + + + + + + +plot.network <- function(structure, ht = "400px"){ + nodes.uniq <- unique(c(structure$arcs[,1], structure$arcs[,2])) + nodes <- data.frame(id = nodes.uniq, + label = nodes.uniq, + color = "darkturquoise", + shadow = TRUE) + edges <- data.frame(from = structure$arcs[,1], + to = structure$arcs[,2], + arrows = "to", + smooth = TRUE, + shadow = TRUE, + color = "black") + return(visNetwork(nodes, edges, height = ht, width = "100%")) +} \ No newline at end of file