# fcut: Transform data into a set of fuzzy attributes using... In lfl: Linguistic Fuzzy Logic

## Description

This function creates a set of fuzzy attributes from crisp data. Factors, numeric vectors, matrix or data frame columns are transformed into a set of fuzzy attributes, i.e. columns with membership degrees. Unlike `lcut`, for transformation is not used the linguistic linguistic approach, but partitioning using regular shapes of the fuzzy sets (such as triangle, raised cosine).

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17``` ```fcut(x, ...) ## S3 method for class 'data.frame' fcut(x, breaks, name=NULL, type=c('triangle', 'raisedcos'), merge=1, parallel=FALSE, ...) ## S3 method for class 'numeric' fcut(x, breaks, name=deparse(substitute(x)), type=c('triangle', 'raisedcos'), merge=1, parallel=FALSE, ...) ```

## Arguments

 `x` Data to be transformed: a vector, matrix, or data frame. Non-numeric data are allowed. `breaks` This argument determines the break-points of the positions of the fuzzy sets. It should be an ordered vector of numbers such that the i-th index specifies the beginning, (i+1)-th the center, and (i+2)-th the ending of the i-th fuzzy set. I.e. the minimum number of breaks-points is 3; n-2 elementary fuzzy sets would be created for n break-points. If considering an i-th fuzzy set (of `type='triangle'`), `x` values lower than i-th break (and greater than (i+2)-th break) would result in zero memberhsip degree, values equal to (i+1)-th break would have membership degree equal 1 and values between them the appropriate membership degree between 0 and 1. The resulting fuzzy sets would be named after the original data by adding dot (".") and a number i of fuzzy set. Unlike `cut`, `x` values, that are lower or greater than the given break-points, will have all memberhsip degrees equal to zero. For non-numeric data, this argument is ignored. For `x` being a numeric vector, it must be a vector of numeric values. For `x` being a numeric matrix or data frame, it must be a named list containing a numeric vector for each column - if not, the values are repeated for each column. `name` A name to be added as a suffix to the created fuzzy attribute names. This parameter can be used only if `x` is a vector. If `x` is a matrix or data frame, `name` should be NULL because the fuzzy attribute names are taken from column names of the argument `x`. `type` The type of fuzzy sets to create Currently, `'triangle'` or `'raisedcos'` may be used. The `type` argument may be also a function of 4 arguments that from the value of the first argument, and considering the boundaries given by the next 3 arguments, computes a membership degree. See e.g. `triangle` or `raisedcos` for details on how such function should look like. `merge` This argument determines whether to derive additional fuzzy sets by merging the elementary fuzzy sets (whose position is determined with the `breaks` argument) into super-sets. The argument is ignored for non-numeric data in `x`. `merge` may contain any integer number from `1` to `length(breaks) - 2`. Value `1` means that the elementary fuzzy sets should be present in the output. Value `2` means that the two consecutive elementary fuzzy sets should be combined by using the Lukasiewic t-conorm, value `3` causes combining three consecutive elementary fuzzy sets etc. The names of the derived (merged) fuzzy sets is derived from the names of the original elementary fuzzy sets by concatenating them with the "|" (pipe) separator. `parallel` Whether the processing should be run in parallel or not. Parallelization is implemented using the `foreach` package. The parallel environment must be set properly in advance, e.g. with the `registerDoMC()` function of the `doMC` package. Currently this argument is applied only if `x` is a matrix or data frame. `...` Other parameters to some methods.

## Details

The aim of this function is to transform numeric data into a set of fuzzy attributes. The result is in the form of the object of class "fsets", i.e. a numeric matrix whose columns represent fuzzy sets (fuzzy attributes) with values being the membership degrees.

The function behaves diffently to the type of input `x`.

If `x` is a factor or a logical vector (or other non-numeric data) then for each distinct value of an input, a fuzzy set is created, and data would be transformed into crisp membership degrees 0 or 1 only.

If `x` is a numeric vector then fuzzy sets are created accordingly to break-points specified in the `breaks` argument with 1st, 2nd and 3rd break-point specifying the first fuzzy set, 2nd, 3rd and 4th break-point specifying th second fuzzy set etc. The shape of the fuzzy set is determined by the `type` argument that may be equal either to a string `'triangle'` or `'raisedcos'` or it could be a function that computes the membership degrees for itself (see `triangle` or `raisedcos` functions for details). Additionally, super-sets of these elementary sets may be created by specifying the `merge` argument. Values of this argument specify how many consecutive fuzzy sets should be combined (by using the Lukasiewic's t-conorm) to produce super-sets - see the description of `merge` above.

If a matrix (resp. data frame) is provided to this function instead of single vector, all columns are processed separately as described above and the result is combined with the `cbind.fsets` function.

The function sets up properly the `vars` and `specs` properties of the result.

## Value

An object of class "fsets" is returned, which is a numeric matrix with columns representing the fuzzy attributes. Each source columm of the `x` argument corresponds to multiple columns in the resulting matrix. Columns have names that indicate the name of the source as well as a index i of fuzzy set(s) – see the description of arguments `breaks` and `merge` above.

The resulting object would also have set the `vars` and `specs` properties with the former being created from original column names (if `x` is a matrix or data frame) or the `name` argument (if `x` is a numeric vector). The `specs` incidency matrix would be created to reflect the superset-hood of the merged fuzzy sets.

## Author(s)

Michal Burda

`lcut`, `farules`, `pbld` `vars`, `specs`, `cbind.fsets`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ```# fcut on non-numeric data ff <- factor(substring("statistics", 1:10, 1:10), levels = letters) fcut(ff) # transform a single vector into a single fuzzy set x <- runif(10) fcut(x, breaks=c(0, 0.5, 1), name='age') # transform single vector into a partition of the interval 0-1 # (the boundary triangles are right-angled) fcut(x, breaks=c(0, 0, 0.5, 1, 1), name='age') # also create supersets fcut(x, breaks=c(0, 0, 0.5, 1, 1), name='age', merge=c(1, 2)) # transform all columns of a data frame # with different breakpoints data <- CO2[, c('conc', 'uptake')] fcut(data, breaks=list(conc=c(95, 95, 350, 1000, 1000), uptake=c(7, 7, 28.3, 46, 46))) ```

### Example output

```   ff.a ff.b ff.c ff.d ff.e ff.f ff.g ff.h ff.i ff.j ff.k ff.l ff.m ff.n ff.o
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    1    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    1    0    0    0    0    0    0
9     0    0    1    0    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.p ff.q ff.r ff.s ff.t ff.u ff.v ff.w ff.x ff.y ff.z
1     0    0    0    1    0    0    0    0    0    0    0
2     0    0    0    0    1    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    1    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    1    0    0    0    0    0    0    0
7     0    0    0    0    1    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    1    0    0    0    0    0    0    0

vars:
ff.a ff.b ff.c ff.d ff.e ff.f ff.g ff.h ff.i ff.j ff.k ff.l ff.m ff.n ff.o ff.p
"ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff"
ff.q ff.r ff.s ff.t ff.u ff.v ff.w ff.x ff.y ff.z
"ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff" "ff"

specs:
ff.a ff.b ff.c ff.d ff.e ff.f ff.g ff.h ff.i ff.j ff.k ff.l ff.m ff.n ff.o
ff.a    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.b    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.c    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.d    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.e    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.f    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.g    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.h    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.i    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.j    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.k    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.l    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.m    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.n    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.o    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.p    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.q    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.r    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.s    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.t    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.u    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.v    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.w    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.x    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.y    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.z    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
ff.p ff.q ff.r ff.s ff.t ff.u ff.v ff.w ff.x ff.y ff.z
ff.a    0    0    0    0    0    0    0    0    0    0    0
ff.b    0    0    0    0    0    0    0    0    0    0    0
ff.c    0    0    0    0    0    0    0    0    0    0    0
ff.d    0    0    0    0    0    0    0    0    0    0    0
ff.e    0    0    0    0    0    0    0    0    0    0    0
ff.f    0    0    0    0    0    0    0    0    0    0    0
ff.g    0    0    0    0    0    0    0    0    0    0    0
ff.h    0    0    0    0    0    0    0    0    0    0    0
ff.i    0    0    0    0    0    0    0    0    0    0    0
ff.j    0    0    0    0    0    0    0    0    0    0    0
ff.k    0    0    0    0    0    0    0    0    0    0    0
ff.l    0    0    0    0    0    0    0    0    0    0    0
ff.m    0    0    0    0    0    0    0    0    0    0    0
ff.n    0    0    0    0    0    0    0    0    0    0    0
ff.o    0    0    0    0    0    0    0    0    0    0    0
ff.p    0    0    0    0    0    0    0    0    0    0    0
ff.q    0    0    0    0    0    0    0    0    0    0    0
ff.r    0    0    0    0    0    0    0    0    0    0    0
ff.s    0    0    0    0    0    0    0    0    0    0    0
ff.t    0    0    0    0    0    0    0    0    0    0    0
ff.u    0    0    0    0    0    0    0    0    0    0    0
ff.v    0    0    0    0    0    0    0    0    0    0    0
ff.w    0    0    0    0    0    0    0    0    0    0    0
ff.x    0    0    0    0    0    0    0    0    0    0    0
ff.y    0    0    0    0    0    0    0    0    0    0    0
ff.z    0    0    0    0    0    0    0    0    0    0    0
age.1
[1,] 0.24771711
[2,] 0.29698541
[3,] 0.71075108
[4,] 0.65844746
[5,] 0.08459979
[6,] 0.58138773
[7,] 0.31454193
[8,] 0.35071095
[9,] 0.89127822
[10,] 0.52451957

vars:
age.1
"age"

specs:
age.1
age.1     0
age.1      age.2     age.3
[1,] 0.7522829 0.24771711 0.0000000
[2,] 0.0000000 0.29698541 0.7030146
[3,] 0.2892489 0.71075108 0.0000000
[4,] 0.3415525 0.65844746 0.0000000
[5,] 0.0000000 0.08459979 0.9154002
[6,] 0.0000000 0.58138773 0.4186123
[7,] 0.0000000 0.31454193 0.6854581
[8,] 0.0000000 0.35071095 0.6492890
[9,] 0.1087218 0.89127822 0.0000000
[10,] 0.4754804 0.52451957 0.0000000

vars:
age.1 age.2 age.3
"age" "age" "age"

specs:
age.1 age.2 age.3
age.1     0     0     0
age.2     0     0     0
age.3     0     0     0
age.1      age.2     age.3 age.1|age.2 age.2|age.3
[1,] 0.7522829 0.24771711 0.0000000  1.00000000   0.2477171
[2,] 0.0000000 0.29698541 0.7030146  0.29698541   1.0000000
[3,] 0.2892489 0.71075108 0.0000000  1.00000000   0.7107511
[4,] 0.3415525 0.65844746 0.0000000  1.00000000   0.6584475
[5,] 0.0000000 0.08459979 0.9154002  0.08459979   1.0000000
[6,] 0.0000000 0.58138773 0.4186123  0.58138773   1.0000000
[7,] 0.0000000 0.31454193 0.6854581  0.31454193   1.0000000
[8,] 0.0000000 0.35071095 0.6492890  0.35071095   1.0000000
[9,] 0.1087218 0.89127822 0.0000000  1.00000000   0.8912782
[10,] 0.4754804 0.52451957 0.0000000  1.00000000   0.5245196

vars:
age.1       age.2       age.3 age.1|age.2 age.2|age.3
"age"       "age"       "age"       "age"       "age"

specs:
age.1 age.2 age.3 age.1|age.2 age.2|age.3
age.1           0     0     0           1           0
age.2           0     0     0           1           1
age.3           0     0     0           0           1
age.1|age.2     0     0     0           0           0
age.2|age.3     0     0     0           0           0
conc.1    conc.2    conc.3    uptake.1   uptake.2   uptake.3
[1,] 1.0000000 0.0000000 0.0000000 0.577464789 0.42253521 0.00000000
[2,] 0.6862745 0.3137255 0.0000000 0.000000000 0.88135593 0.11864407
[3,] 0.3921569 0.6078431 0.0000000 0.000000000 0.63276836 0.36723164
[4,] 0.0000000 1.0000000 0.0000000 0.000000000 0.49717514 0.50282486
[5,] 0.0000000 0.7692308 0.2307692 0.000000000 0.60451977 0.39548023
[6,] 0.0000000 0.5000000 0.5000000 0.000000000 0.38418079 0.61581921
[7,] 0.0000000 0.0000000 1.0000000 0.000000000 0.35593220 0.64406780
[8,] 1.0000000 0.0000000 0.0000000 0.690140845 0.30985915 0.00000000
[9,] 0.6862745 0.3137255 0.0000000 0.046948357 0.95305164 0.00000000
[10,] 0.3921569 0.6078431 0.0000000 0.000000000 0.50282486 0.49717514
[11,] 0.0000000 1.0000000 0.0000000 0.000000000 0.23728814 0.76271186
[12,] 0.0000000 0.7692308 0.2307692 0.000000000 0.30508475 0.69491525
[13,] 0.0000000 0.5000000 0.5000000 0.000000000 0.25988701 0.74011299
[14,] 0.0000000 0.0000000 1.0000000 0.000000000 0.09604520 0.90395480
[15,] 1.0000000 0.0000000 0.0000000 0.568075117 0.43192488 0.00000000
[16,] 0.6862745 0.3137255 0.0000000 0.000000000 0.76836158 0.23163842
[17,] 0.3921569 0.6078431 0.0000000 0.000000000 0.32203390 0.67796610
[18,] 0.0000000 1.0000000 0.0000000 0.000000000 0.22033898 0.77966102
[19,] 0.0000000 0.7692308 0.2307692 0.000000000 0.17514124 0.82485876
[20,] 0.0000000 0.5000000 0.5000000 0.000000000 0.11864407 0.88135593
[21,] 0.0000000 0.0000000 1.0000000 0.000000000 0.02824859 0.97175141
[22,] 1.0000000 0.0000000 0.0000000 0.661971831 0.33802817 0.00000000
[23,] 0.6862745 0.3137255 0.0000000 0.197183099 0.80281690 0.00000000
[24,] 0.3921569 0.6078431 0.0000000 0.000000000 0.88700565 0.11299435
[25,] 0.0000000 1.0000000 0.0000000 0.000000000 0.64406780 0.35593220
[26,] 0.0000000 0.7692308 0.2307692 0.000000000 0.76271186 0.23728814
[27,] 0.0000000 0.5000000 0.5000000 0.000000000 0.59887006 0.40112994
[28,] 0.0000000 0.0000000 1.0000000 0.000000000 0.41242938 0.58757062
[29,] 1.0000000 0.0000000 0.0000000 0.892018779 0.10798122 0.00000000
[30,] 0.6862745 0.3137255 0.0000000 0.046948357 0.95305164 0.00000000
[31,] 0.3921569 0.6078431 0.0000000 0.000000000 0.62146893 0.37853107
[32,] 0.0000000 1.0000000 0.0000000 0.000000000 0.40677966 0.59322034
[33,] 0.0000000 0.7692308 0.2307692 0.000000000 0.41807910 0.58192090
[34,] 0.0000000 0.5000000 0.5000000 0.000000000 0.48022599 0.51977401
[35,] 0.0000000 0.0000000 1.0000000 0.000000000 0.20338983 0.79661017
[36,] 1.0000000 0.0000000 0.0000000 0.619718310 0.38028169 0.00000000
[37,] 0.6862745 0.3137255 0.0000000 0.342723005 0.65727700 0.00000000
[38,] 0.3921569 0.6078431 0.0000000 0.000000000 0.44632768 0.55367232
[39,] 0.0000000 1.0000000 0.0000000 0.000000000 0.67796610 0.32203390
[40,] 0.0000000 0.7692308 0.2307692 0.000000000 0.40112994 0.59887006
[41,] 0.0000000 0.5000000 0.5000000 0.000000000 0.36158192 0.63841808
[42,] 0.0000000 0.0000000 1.0000000 0.000000000 0.25988701 0.74011299
[43,] 1.0000000 0.0000000 0.0000000 0.830985915 0.16901408 0.00000000
[44,] 0.6862745 0.3137255 0.0000000 0.427230047 0.57276995 0.00000000
[45,] 0.3921569 0.6078431 0.0000000 0.098591549 0.90140845 0.00000000
[46,] 0.0000000 1.0000000 0.0000000 0.000000000 0.90395480 0.09604520
[47,] 0.0000000 0.7692308 0.2307692 0.000000000 0.85310734 0.14689266
[48,] 0.0000000 0.5000000 0.5000000 0.000000000 0.76836158 0.23163842
[49,] 0.0000000 0.0000000 1.0000000 0.000000000 0.59322034 0.40677966
[50,] 1.0000000 0.0000000 0.0000000 0.765258216 0.23474178 0.00000000
[51,] 0.6862745 0.3137255 0.0000000 0.295774648 0.70422535 0.00000000
[52,] 0.3921569 0.6078431 0.0000000 0.000000000 0.87005650 0.12994350
[53,] 0.0000000 1.0000000 0.0000000 0.000000000 0.80225989 0.19774011
[54,] 0.0000000 0.7692308 0.2307692 0.000000000 0.76836158 0.23163842
[55,] 0.0000000 0.5000000 0.5000000 0.000000000 0.84180791 0.15819209
[56,] 0.0000000 0.0000000 1.0000000 0.000000000 0.81920904 0.18079096
[57,] 1.0000000 0.0000000 0.0000000 0.798122066 0.20187793 0.00000000
[58,] 0.6862745 0.3137255 0.0000000 0.417840376 0.58215962 0.00000000
[59,] 0.3921569 0.6078431 0.0000000 0.117370892 0.88262911 0.00000000
[60,] 0.0000000 1.0000000 0.0000000 0.018779343 0.98122066 0.00000000
[61,] 0.0000000 0.7692308 0.2307692 0.000000000 0.98870056 0.01129944
[62,] 0.0000000 0.5000000 0.5000000 0.009389671 0.99061033 0.00000000
[63,] 0.0000000 0.0000000 1.0000000 0.023474178 0.97652582 0.00000000
[64,] 1.0000000 0.0000000 0.0000000 0.835680751 0.16431925 0.00000000
[65,] 0.6862745 0.3137255 0.0000000 0.629107981 0.37089202 0.00000000
[66,] 0.3921569 0.6078431 0.0000000 0.478873239 0.52112676 0.00000000
[67,] 0.0000000 1.0000000 0.0000000 0.441314554 0.55868545 0.00000000
[68,] 0.0000000 0.7692308 0.2307692 0.413145540 0.58685446 0.00000000
[69,] 0.0000000 0.5000000 0.5000000 0.286384977 0.71361502 0.00000000
[70,] 0.0000000 0.0000000 1.0000000 0.300469484 0.69953052 0.00000000
[71,] 1.0000000 0.0000000 0.0000000 0.967136150 0.03286385 0.00000000
[72,] 0.6862745 0.3137255 0.0000000 0.793427230 0.20657277 0.00000000
[73,] 0.3921569 0.6078431 0.0000000 0.751173709 0.24882629 0.00000000
[74,] 0.0000000 1.0000000 0.0000000 0.718309859 0.28169014 0.00000000
[75,] 0.0000000 0.7692308 0.2307692 0.741784038 0.25821596 0.00000000
[76,] 0.0000000 0.5000000 0.5000000 0.685446009 0.31455399 0.00000000
[77,] 0.0000000 0.0000000 1.0000000 0.652582160 0.34741784 0.00000000
[78,] 1.0000000 0.0000000 0.0000000 0.830985915 0.16901408 0.00000000
[79,] 0.6862745 0.3137255 0.0000000 0.483568075 0.51643192 0.00000000
[80,] 0.3921569 0.6078431 0.0000000 0.488262911 0.51173709 0.00000000
[81,] 0.0000000 1.0000000 0.0000000 0.488262911 0.51173709 0.00000000
[82,] 0.0000000 0.7692308 0.2307692 0.488262911 0.51173709 0.00000000
[83,] 0.0000000 0.5000000 0.5000000 0.441314554 0.55868545 0.00000000
[84,] 0.0000000 0.0000000 1.0000000 0.394366197 0.60563380 0.00000000

vars:
conc.1   conc.2   conc.3 uptake.1 uptake.2 uptake.3
"conc"   "conc"   "conc" "uptake" "uptake" "uptake"

specs:
conc.1 conc.2 conc.3 uptake.1 uptake.2 uptake.3
conc.1        0      0      0        0        0        0
conc.2        0      0      0        0        0        0
conc.3        0      0      0        0        0        0
uptake.1      0      0      0        0        0        0
uptake.2      0      0      0        0        0        0
uptake.3      0      0      0        0        0        0
```

lfl documentation built on April 12, 2018, 5:04 p.m.