Package: transfertools
transfertoolstransfertoolsis a small Python package containing recenttransfer learning algorithms.
Transfer learning strives to transfer information from one dataset, thesource domain, to a related dataset, thetarget domain. Several constraints and assumptions can be placed on the domains, inspiring different algorithms to do the information transfer.
The package contains four transfer learning algorithms.InstallationInstall the package directly from PyPi with the following command:pipinstalltransfertoolsOR install the package using thesetup.pyfile:pythonsetup.pyinstallOR install it directly from GitHub itself:pipinstallgit+https://github.com/Vincent-Vercruyssen/transfertools.git@masterContents and usageTransfer learning aims to transfer information from asource domainDsto a relatedtarget domainDt. A domain consists of a dataset with attributesXand labelsY. Thus, the source domain isDs= {Xs,Ys} and the target domain isDt= {Xt,Yt}.  The fundamental assumption is that the source and target domain live in the same feature space.
Different flavors of transfer learning methodologies exist.Unsupervised transferlearning, for instance, disregards label information and only usesXsandXtto determine what information to transfer.Supervised transferlearning uses the full domainsDsandDtto do the transfer.Semi-supervised transferlearning uses the full source domainDsand the target attributesXtto do the transfer.The actual information that is transferred also differs between methods.
Domain adaptation techniques transform the source (and target) domains such that they match more closely (according to different criteria) and then combine all the data points to constructDcombo.
Instance selection techniques select a subset of the source data that should be transferred to the target data to constructDcombo.
After transfer, a classifier can be constructed usingDcombo.Instance selection techniquesThetransfertoolspackage contains two instance selection transfer techniques tailored to anomaly detection:TheLocIT(localized instance transfer) algorithm works in a completely unsupervised manner. It transfers the instances inDsthat have matching localized distributions in both domains [1]. This algorithm can also be used in other applications than anomaly detection.TheCBIT(cluster-based instance transfer) algorithm works in a semi-supervised manner. It transfer the instances inDsthat fall inside a cluster defined on the target data [2].Given a source domain {Xs,Ys} and a target domain {Xt,Yt}, the algorithms are applied as follows:fromtransfertools.modelsimportLocIT,CBIT# traintransfor=LocIT()transfor.fit(Xs,Xt)# predictXs_trans=transfor.transfer(Xs)# ... or immediatelyXs_trans=transfor.fit_transfer(Xs,Xt)Domain adaptation techniquesThetransfertoolspackage contains two instance domain adaptation techniques:TheCORAL(correlation alignment) algorithm is an unsupervised transfer learning technique that aligns the first and second order statistics of the source and target data [3].TheTCA(transfer component analysis) algorithm is an unsupervised transfer learning technique that projects the source and target data onto a lower-dimensional subspace [4].Given a source domain {Xs,Ys} and a target domain {Xt,Yt}, the algorithms are applied as follows:fromtransfertools.modelsimportTCA,CORAL# traintransfor=CORAL()transfor.fit(Xs,Xt)# predictXs_trans=transfor.transfer(Xs)# ... or immediatelyXs_trans=transfor.fit_transfer(Xs,Xt)Package structureThe transfer learning algorithms are located in:transfertools/models/For further examples of how to use the algorithms see the notebooks:transfertools/notebooks/DependenciesThetransfertoolspackage requires the following python packages to be installed:Python 3NumpyScipyScikit-learnContactContact the author of the package:vincent.vercruyssen@kuleuven.beReferences[1] Vercruyssen, V., Meert, W., and J. Davis. (2020)Transfer Learning for Anomaly Detection through Localized and Unsupervised Instance Selection.In 34th AAAI Conference on Artificial Intelligence, New York.To be published[2] Vercruyssen, V., Meert, W., and Davis, J. (2017)Transfer learning for time series anomaly detection.In CEUR Workshop Proceedings, vol. 1924, pp. 27-37.