I have a dataframe which has categorical and numeric variables. I want to cluster this data using gower distance and get cluster values as a vector as in kmeans function. How can i achieve that?
Clustering using gower distance in R
7.7k Views Asked by cuneyttyler At
2
There are 2 best solutions below
0
Mehmet Yildirim
On
You can use kproto() function from clustMixType if you don't want to insist on using Gower distance. The distance measure in kproto is similar to Gower distance except that kproto uses Euclidean distance to measure dissimilarity between numerical variables; however, Gower distance normalizes each variable (divides the distance between two observations by the range of that variable). The code is pretty simple.
kproto_clustering <- kproto(df, k) # k is number of cluster
clusters <- kproto_clustering$cluster
Related Questions in R
- in R, recovering strings that have been converted to factors with factor()
- How to reinstall pandoc after removing .cabal?
- How do I code a Mixed effects model for abalone growth in Aquaculture nutrition with nested individuals
- How to save t.test result in R to a txt file?
- how to call function from library in formula with R type provider
- geom_bar define border color with different fill colors
- Different outcome using model.matrix for a function in R
- Creating a combination data.table in R
- Force specific interactions in Package 'earth' in R
- Output from recursive function R
- Extract series of observations from dataframe for complete sets of data
- Retrieve path of supplementary data file of developed package
- r package development - own function not visible for opencpu
- Label a dataset according to bins of a histogram
- multiply each columns of a matrix by a vector
Related Questions in CLUSTER-ANALYSIS
- How to cluster a set of strings?
- What clustering algorithms can I consider for graph?
- Center of clusteres in rapidminer
- Spectral clustering with Similarity matrix constructed by jaccard coefficient
- Selecting initial centroids in Kmeans in R
- kmeans clustering on the basis of fixed number of variables out of all variables
- MinHashing vs SimHashing
- knn predictions with Clustering
- How do I choose a linkage method for Hierarchical Agglomerative Clustering?
- Affinity Propagation (sklearn) - strange behavior
- How to extract cluster centres from agnes for inputting into kmeans?
- Is it possible to estimate at survey data at cluster level?
- How to explain a higher percentage of point variability using kmeans clustering?
- Mahout clustering: How to retrieve the name of a named vector
- String clustering using matlab?
Related Questions in CATEGORICAL-DATA
- in R, recovering strings that have been converted to factors with factor()
- R plspm working with categorical and numeric variables
- Using Pandas 'categorical' dtype with sklearn
- Extract the level from a factor
- How to get rid of main effects when coding interaction between categorical variables in patsy?
- Extract unique strings from a factor string variable
- How to create 'clustered dotplots' for categorical data?
- Is it necessary to convert categorical attributes to numerical attributes to use LabeledPoint function in Pyspark?
- Computing similarity matrix with mixed data
- Using pandas pd.cut to generate a categorical variable with statsmodels
- Scikit Learn: Predicting Categorical Features
- How to keep all levels of categorical variables when splitting data frame in test and train set in R
- setting levels apriori when using factorize in Pandas to cover missing cases
- Loading data with missing values as numeric data
- How can I produce a MATLAB bar graph of categorical responses?
Related Questions in MIXED-TYPE
- How can mixed data types (int, float, char, etc) be stored in an array?
- Swift Decodable for a list or items of mixed types
- Dynamically assign property of object with mixed-type properties in TypeScript
- How to decide best number of clusters for kamila clustering with R?
- Pandas: Drop all string components in a mixed typed series with integers and strings
- How to access different attributes of different implementation of the same interface
- How to create mixed type data in pandas
- Migrating python2 mixed-type np.array operations to python3
- Clustering using gower distance in R
- Check if value is equal to 0 for mixed type column (with timedelta and floats)
- Converting Floats to String in Mixed Type DF Column Uses Scientific Notation
- Clustering a mixed data set in R
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can use the vegan package to generate your gower matrix, and then create your clusters using the cluster package.
Then you can feed that matrix into the PAM function. The example below will use the gower distance to generate 5 clusters
You can then get your cluster information from