Learn R Programming

Rcoclust (version 0.1.1)

randp: Random projection for sparse matrix

Description

Implementation of the reduction of matrix via a right multiplication with a generated Gaussian random matrix. The data vectors for the columns are not required for the input parameters in envrdata.

Usage

randp(envrdata,dimr,sgr,vect_Ar,transfrm,debug)

Arguments

envrdata
environment with data.
dimr
reduced dimension for random projection.
sgr
standard deviation for random projection.
vect_Ar
vector with the transformed matrix after random projection.
transfrm
transformation of the data (0:none, 1:binarization, 2:tf-idf, 3:tf-idf+rows normalization).
debug
flag for debug, if equal to 1 shows some informations to user.

Value

The function alters the matrix in vect_Ar with the result of the reduction.

Examples

Run this code
  library(Rcoclust);
  
  #load data
  data(data_cstr);
  envrdata=get_envrdata(A_ijx,lbs,name,0);
  
  #retrieve matrix size and number of classes
  n=envrdata$n;
  d=envrdata$d;
  g=length(unique(envrdata$lbs));
  
  #random projection
  dimr    = min(500,envrdata$d); #reduced dimension
  sgr     = 1;                   #std for projection
  vect_Ar = rep(0,n*dimr);       #reduced matrix in vector form
  Rcoclust::randp(envrdata,dimr,sgr,vect_Ar,3,0);
  Ar=matrix(vect_Ar,nrow=n,byrow = TRUE);
  
  #kmeans+random projection
  km=kmeans(Ar,g);
  table(km$cluster,envrdata$lbs);

Run the code above in your browser using DataLab