> For the complete documentation index, see [llms.txt](https://hwasumok.gitbook.io/r-flow/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hwasumok.gitbook.io/r-flow/r/machine-learning/similarity-based-ml.md).

# Similarity based ML

k-Nearest Neighbor, Support Vector Machines, One-Classification SVM, Logistic Regression

## K-Nearest Neighbor

### Input Data

|                   |                                                                                                           |
| ----------------- | --------------------------------------------------------------------------------------------------------- |
| **\*Target Data** | Input data                                                                                                |
| **\*Model Name**  | Name of the model                                                                                         |
| **Output Name**   | Name of the output after calculation(optional)                                                            |
| **Merge Data**    | If not empty, the prediction data will be stored in the selected data frame(optional)                     |
| **\*X**           | Input Variable                                                                                            |
| **\*Y(factor)**   | The target variable for classification or regression. If it is not a factor type, convert it to a factor. |

![\[Task Information of knn\]](https://3929524962-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGaxNdSdRN_L_WNiX4I%2F-ML7BloaOHtTsNfDhhQu%2F-ML7dTetNP24d5cEtJsY%2Fimage.png?alt=media\&token=cf25f3fa-7802-4a25-9654-5392c4b83515)

## Support Vector Machines

### Input Data

| Parameters        | Input                                                                                     |
| ----------------- | ----------------------------------------------------------------------------------------- |
| **\*Target Data** | Input data                                                                                |
| **\*Model Name**  | Name of the model                                                                         |
| **Output Name**   | Name of the output after calculation(optional)                                            |
| **Merge Data**    | If not empty, the prediction data will be stored in the selected data frame(optional)     |
| **\*X**           | Input variable                                                                            |
| **\*Y**           | <p>Target data.</p><p>Factor type for classification and numeric type for regression.</p> |

![\[Task Information of SVM\]](https://3929524962-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGaxNdSdRN_L_WNiX4I%2F-MMS6C-vha_QfFgqgGt6%2F-MMSCMXwf_3pWyAzusZr%2Fimage.png?alt=media\&token=2c93d1f7-f14d-47dd-b3c2-4c7c56ce79d3)

For classification, select C-classification of nu-classification for the type under Arguments. For regression, select eps-regression or nu-regression.

## One-Classification SVM

### Input Data

|       |                 |
| ----- | --------------- |
| **X** | Input variables |

One-classification SVM is used for the novelty detection. It uses the method 'one-classification' in the svm function.

![\[Task Information of One-classification SVM\]](https://3929524962-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGaxNdSdRN_L_WNiX4I%2F-MKvIR0Am1jJ3qHXkyZn%2F-MKvJVUFC5Ln__anKGLJ%2Fimage.png?alt=media\&token=c3ce80c3-9e1c-4b4d-9c6e-0e0249ac09c6)

## Logistic Regression

### Input Data

|       |                                |
| ----- | ------------------------------ |
| **X** | Independent variables          |
| **Y** | Dependent categorical variable |

![\[Task Information of Logistic Regression\]](https://3929524962-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGaxNdSdRN_L_WNiX4I%2F-MKvGNojQYD7Ppn2a6aP%2F-MKvHCBkATruNbEBQklc%2Fimage.png?alt=media\&token=3013ccb6-356b-4304-a664-7652df486af9)

## Workflow Example

![](https://3929524962-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGaxNdSdRN_L_WNiX4I%2F-MLfEvT9hHAj_K52450r%2F-MLgDZM57tB6e-m_N9kV%2Fimage.png?alt=media\&token=1b8bcaf8-45d2-4cc1-bfeb-4bb7db56ba39)

[R-Flow Task Example Video: Support Vector Machines](https://www.youtube.com/watch?v=SQejryKLjd4)

![](https://3929524962-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGaxNdSdRN_L_WNiX4I%2F-MLfEvT9hHAj_K52450r%2F-MLgDU3mkrhZTaydqFPW%2Fimage.png?alt=media\&token=70f35c31-c8d0-47d4-859a-751635342b3e)

## R Packages

**K-Nearest Neighbor**&#x20;

Packages name: kknn, Method: kknn

<https://cran.r-project.org/web/packages/kknn/index.html>

**Support Vector Machines/One-Classification svm**

Packages name: e1071, Method: svm

<https://cran.r-project.org/web/packages/e1071/index.html>
