# RandPro

The goal of RandPro is to provide the platform for R users to perform random projection (RP) based feature extraction with ease and simple functions. Random Projection is one of the projection based feature extraction technique where the projection matrix is filled with independent and identically distributed (i.i.d) random values. Even though the projection is random, RP nearly preserves all the pairwise distance between any two samples in the projected low dimensional subspace with the controlled amount of error. RP even outperforms principal component analysis (PCA) in very high dimensional data analysis and streaming applications.

## Functions in RandPro

dimension() - determines the number of dimension required to project the data in low dimensional space using Johnson-Lindenstrauss Lemma.

form_matrix() - creates a projection matrix filled with four suitable distributions that are primarily used in the research community.

classify() - performs the classification with random projection based feature extraction. It uses classifiers in the caret package.

## Installation

You can install the released version of RandPro from CRAN with:

``install.packages("RandPro")``

And the development version from GitHub with:

``````# install.packages("devtools")
devtools::install_github("cran/RandPro")``````

## Example - IRIS dataset

This is a basic example which shows you how to perform random projection based feature extraction with classification

``````# Load Library
library(RandPro)``````
``````## Loading required package: caret

``````#Load Iris Data
data("iris")
#Split the data into training set and test set of 75:25 ratio.
set.seed(101)
sample <- sample.int(n = nrow(iris), size = floor(.75*nrow(iris)), replace = FALSE)
trainn <- iris[sample, ]
testt <- iris[-sample,]
#Extract the train label and test label
trainl <- trainn\$Species
testl <- testt\$Species
typeof(trainl)
#Remove the label from training set and test set
trainn <- trainn[,1:4]
testt <- testt[,1:4]
#classify the Iris data with default K-NN Classifier.
res <- classify(trainn,testt,trainl,testl)``````
``````## Function uses default value 0.5 for epsilon

## Function uses Gaussian Projection function

## Function uses default K-NN classifier``````
``res``
{"ft_lang_label":"__label__en","ft_lang_prob":0.7762999,"math_prob":0.7184893,"size":2158,"snap":"2023-14-2023-23","text_gpt3_token_len":449,"char_repetition_ratio":0.13231198,"word_repetition_ratio":0.006430868,"special_character_ratio":0.20852642,"punctuation_ratio":0.09550562,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9593398,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-30T21:12:01Z\",\"WARC-Record-ID\":\"<urn:uuid:0838a321-ff35-43ef-9d7a-0173b1ad65a1>\",\"Content-Length\":\"9709\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4a973ccd-5b3e-43e1-89a5-2be0e808a1a4>\",\"WARC-Concurrent-To\":\"<urn:uuid:a5b45fc5-699b-428d-890c-9d2cd0485b6e>\",\"WARC-IP-Address\":\"13.66.202.75\",\"WARC-Target-URI\":\"https://cran.microsoft.com/snapshot/2020-08-19/web/packages/RandPro/readme/README.html\",\"WARC-Payload-Digest\":\"sha1:4ZUG5VWOTYP6X3XTBS5NL5F22SFIEEYV\",\"WARC-Block-Digest\":\"sha1:G5DG33PBCA7MUL2KYIDBMKMZWFIFTD7R\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296949387.98_warc_CC-MAIN-20230330194843-20230330224843-00032.warc.gz\"}"}