{"id":15969746,"url":"https://github.com/luca-parisi/m_arcsinh","last_synced_at":"2025-06-28T02:34:58.316Z","repository":{"id":183795009,"uuid":"296435554","full_name":"luca-parisi/m_arcsinh","owner":"luca-parisi","description":"m-arcsinh: A Reliable and Efficient Function for Supervised Machine Learning (scikit-learn, TensorFlow, and Keras) and Feature Extraction (scikit-learn)","archived":false,"fork":false,"pushed_at":"2024-09-02T22:23:23.000Z","size":54,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T05:51:04.411Z","etag":null,"topics":["activation","activation-function","activation-functions","activations","arcsinh","classification","dimensionality-reduction","feature-extraction","keras","keras-tensorflow","machine-learning","machinelearning","mlp","mlp-classifier","neural-network","python","scikit-learn","svm","svm-classifier","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luca-parisi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-17T20:30:02.000Z","updated_at":"2024-11-16T09:33:48.000Z","dependencies_parsed_at":"2024-10-30T04:29:03.190Z","dependency_job_id":null,"html_url":"https://github.com/luca-parisi/m_arcsinh","commit_stats":null,"previous_names":["luca-parisi/m-arcsinh_scikit-learn_tensorflow_keras","luca-parisi/m_arcsinh"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-parisi%2Fm_arcsinh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-parisi%2Fm_arcsinh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-parisi%2Fm_arcsinh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-parisi%2Fm_arcsinh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luca-parisi","download_url":"https://codeload.github.com/luca-parisi/m_arcsinh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245702621,"owners_count":20658648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activation","activation-function","activation-functions","activations","arcsinh","classification","dimensionality-reduction","feature-extraction","keras","keras-tensorflow","machine-learning","machinelearning","mlp","mlp-classifier","neural-network","python","scikit-learn","svm","svm-classifier","tensorflow"],"created_at":"2024-10-07T19:41:32.533Z","updated_at":"2025-03-26T17:32:45.590Z","avatar_url":"https://github.com/luca-parisi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# m-arcsinh in scikit-learn, TensorFlow, and Keras\n## A Reliable and Efficient Function for Supervised Machine Learning and Feature Extraction\n\n\nThe modified 'arcsinh' or **`m_arcsinh`** is a Python custom kernel and activation function available for the Support Vector Machine (SVM) implementation for classification [`SVC`](https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html) and Multi-Layer Perceptron (MLP) or [`MLPClassifier`](https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPClassifier.html) classes in scikit-learn for Machine Learning-based classification. For the same purpose, it is also available as a Python custom activation function for shallow neural networks in TensorFlow and Keras.\n\nFurthermore, it is also a reliable and computationally efficient G function to improve [FastICA](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.FastICA.html)-based feature extraction (m-ar-K-FastICA). \n\nIt is distributed under the [CC BY 4.0 license](http://creativecommons.org/licenses/by/4.0/).\n\nDetails on this function, implementation and validation are available at the following: \n\n   1. against gold standard kernel and activation functions for SVM and MLP respectively: **[Parisi, L., 2020](https://arxiv.org/abs/2009.07530)**.\n   2. when leveraged as a G function in the m-arcsinh Kernel-based FastICA (m-ar-K-FastICA), as compared to the benchmark FastICA method: **[Parisi, L., 2021](https://arxiv.org/abs/2108.07908)**.\n\n### Dependencies\n\n* For the **scikit-learn version** of the m-arcsinh and the m-ar-K-FastICA: As they are compatible with scikit-learn, please note the [dependencies of scikit-learn](https://github.com/scikit-learn/scikit-learn) to be able to use the 'm-arcsinh' function in the `SVC`, `MLPClassifier`, and `FastICA` classes.\n\n* For the **TensorFlow and Keras versions** of the m-arcsinh: Also developed in Python 3.6, compatible with TensorFlow (versions tested: 1.12 and 1.15) and Keras, please note the dependencies of TensorFlow (v1.12 or 1.15) and Keras to be able to use the 'm-arcsinh' activation function in shallow neural networks.\n\n### Usage\n\nYou can use the m-arcsinh function as a custom:\n\n* [kernel function](https://github.com/luca-parisi/m-arcsinh_scikit-learn_TensorFlow_Keras/blob/master/m_arcsinh_for_svc_sklearn.py) in the `SVC` class in scikit learn as per the following two steps:\n\n    1. defining the kernel function `m_arcsinh` as follows: \n    \n       ```python\n        import numpy as np\n\n\n        def m_arcsinh(data, Y):\n\n            return np.dot((\n                   1/3*np.arcsinh(data))*(1/4*np.sqrt(np.abs(data))), \n                   (1/3*np.arcsinh(Y.T))*(1/4*np.sqrt(np.abs(Y.T))\n                   ))\n       ```\n       \n    2. after importing the relevant 'svm' class from scikit-learn:  \n        \n        ```python\n        from sklearn import svm\n        \n        \n        classifier = svm.SVC(\n                     kernel=m_arcsinh,\n                     gamma=0.001,\n                     random_state=13,\n                     class_weight='balanced'\n                     )\n        ```\n        \n* [activation function](https://github.com/luca-parisi/m-arcsinh_scikit-learn_TensorFlow_Keras/blob/master/m_arcsinh_for_mlpclassifier_sklearn.py) in the `MLPClassifier` class in scikit-learn, as per the following two steps:\n\n    1. updating the `_base.py` file under your local installation of scikit-learn (`sklearn/neural_network/_base.py`), as per [this commit](https://github.com/scikit-learn/scikit-learn/pull/18419/commits/3e1141dc3448615018888e8da07622452b092f4f), including the m-arcsinh in the `ACTIVATIONS` dictionary\n    2. after importing the relevant `MLPClassifier` class from scikit-learn, you can use the `m_arcsinh` as any other activation functions within it:\n    \n    ```python\n       from sklearn.neural_network import MLPClassifier\n       \n       \n       classifier =  MLPClassifier(\n                     activation='m_arcsinh',\n                     random_state=1,\n                     max_iter=300\n                     )\n     ```\n\n* [activation function](https://github.com/luca-parisi/m-arcsinh_scikit-learn_TensorFlow_Keras/blob/master/m_arcsinh_TensorFlow_Keras.py) in shallow neural networks in Keras as a layer:\n\n    ```python\n       number_of_classes = 10\n       model.add(keras.layers.Dense(128))\n       model.add(m_arcsinh())\n       model.add(keras.layers.Dense(number_of_classes))\n    ```\n\n* [G function](https://github.com/luca-parisi/m-arcsinh_scikit-learn_TensorFlow_Keras/blob/master/_fastica.py) to improve FastICA-based feature extraction via the m-ar-K-FastICA approach in the `FastICA` class in scikit-learn, as per the following two steps:\n\n    1. updating the `_fastica.py` file under your local installation of scikit-learn (`sklearn/decomposition/_fastica.py`), as per [this file](https://github.com/luca-parisi/m-arcsinh_scikit-learn_TensorFlow_Keras/blob/master/_fastica.py), including the m-arcsinh as a G function (`fun`) for the `FastICA` class\n    2. after importing the relevant `FastICA` class from scikit-learn, you can use the `m_arcsinh` as any other G functions within it:\n    \n    ```python\n       from sklearn.decomposition import FastICA\n       \n       \n       transformer = FastICA(\n                     n_components=7,\n                     random_state=0,\n                     fun='m_arcsinh'\n                     )\n     ```\n\n### Citation request\n\nIf you are using this function, please cite the related papers by:\n* **[Parisi, L., 2020](https://arxiv.org/abs/2009.07530)**.\n* **[Parisi, L. et al., 2021](https://www.naun.org/main/NAUN/mcs/2021/a142002-007(2021).pdf)**.\n* **[Parisi, L., 2021](https://arxiv.org/abs/2108.07908)**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluca-parisi%2Fm_arcsinh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluca-parisi%2Fm_arcsinh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluca-parisi%2Fm_arcsinh/lists"}