GithubHelp home page GithubHelp logo

clustering_toolbox's People

Contributors

fveronesi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

clustering_toolbox's Issues

List subscript issue

My modified version to make it work on my computer

KMeans Clustering Toolbox

##Author: Fabio Veronesi
tool_exec <- function(in_params, out_params)
{
if (!requireNamespace("sp", quietly = TRUE))
install.packages("sp")
require(sp)

print("K-Means Clustering of Shapefiles")
print("Author: Fabio Veronesi")

source_dataset <- in_params[[1]]
nclust <- in_params[[2]]
variable <- in_params[[3]]

out_shape <- out_params[[1]]

Read Data

arc.progress_label("Loading Dataset")
d <- arc.open(source_dataset)
print(d)

Create a Data.Frame with the variables to cluster

data <- arc.select(d, variable)

data_clust <- data.frame(data[,variable[[1]]]) # First issue here

if(length(variable)>1){
for(i in 2:length(variable)){
data_clust <- cbind(data_clust,data[,variable[[i]]]) # second here
}
}

names(data_clust) <- variable

for(i in 1:length(variable)){
dev.new()
plot(hist(data_clust[,i]),main=paste0("Histogram of ",variable[[i]]),xlab=variable[[i]]) # this needed to be modified as well
}

clusters <- kmeans(data_clust, nclust)

result <- data.frame(cluster=clusters$cluster)

arc.write(out_shape, result, coords = arc.shape(data))

print("Done")
return(out_params)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.