Package: skift
scikit-learnwrappers for PythonfastText.>>>fromskiftimportFirstColFtClassifier>>>df=pandas.DataFrame([['woof',0],['meow',1]],columns=['txt','lbl'])>>>sk_clf=FirstColFtClassifier(lr=0.3,epoch=10)>>>sk_clf.fit(df[['txt']],df['lbl'])>>>sk_clf.predict([['woof']])[0]Contents1Installation2Configuration3Features4Wrappers4.1Standard wrappers4.2pandas-dependent wrappers4.3Hyperparameter auto-tuning5Contributing5.1Installing for development5.2Running the tests5.3Adding documentation6Credits1InstallationDependencies:numpyscipyscikit-learnThefasttextPython packagepipinstallskift2ConfigurationBecausefasttextreads input data from files,skifthas to dump the input data into temporary files forfasttextto use. A dedicated folder is created for those files on the filesystem.  By default, this storage is allocated in the system temporary storage location (i.e. /tmp on *nix systems).  To override this default location, use theSKIFT_TEMP_DIRenvironment variable:exportSKIFT_TEMP_DIR=/path/to/desired/temp/folderNOTE:The directory will be created if it does not already exist.3FeaturesAdheres to thescikit-learnclassifier API, includingpredict_proba.Also caters to the common use case ofpandas.DataFrameinputs.Enables easy stacking offastTextwith other types ofscikit-learn-compliant classifiers.Pickle-able classifier objects.Built around theofficial fasttext Python package.Pure python.Supports Python 3.5+.Fully tested on Linux, OSX and Windows operating systems.4WrappersfastTextworks only on text data, which means that it will only use a single column from a dataset which might contain many feature columns of different types. As such, a common use case is to have thefastTextclassifier use a single column as input, ignoring other columns. This is especially true whenfastTextis to be used as one of several classifiers in a stacking classifier, with other classifiers using non-textual features.skiftincludes severalscikit-learn-compatible wrappers (for theofficialfastTextPython package) which cater to these use cases.NOTICE:Any additional keyword arguments provided to the classifier constructor, besides those required, will be forwarded to thefastText.train_supervisedmethod on every call tofit.4.1Standard wrappersThese wrappers do not make additional assumptions on input besides those commonly made byscikit-learnclassifies; i.e. that input is a 2dndarrayobject and such.FirstColFtClassifier- An sklearn classifier adapter for fasttext that takes the first column of inputndarrayobjects as input.>>>fromskiftimportFirstColFtClassifier>>>df=pandas.DataFrame([['woof',0],['meow',1]],columns=['txt','lbl'])>>>sk_clf=FirstColFtClassifier(lr=0.3,epoch=10)>>>sk_clf.fit(df[['txt']],df['lbl'])>>>sk_clf.predict([['woof']])[0]IdxBasedFtClassifier- An sklearn classifier adapter for fasttext that takes input by column index. This is set on object construction by providing theinput_ixparameter to the constructor.>>>fromskiftimportIdxBasedFtClassifier>>>df=pandas.DataFrame([[5,'woof',0],[83,'meow',1]],columns=['count','txt','lbl'])>>>sk_clf=IdxBasedFtClassifier(input_ix=1,lr=0.4,epoch=6)>>>sk_clf.fit(df[['count','txt']],df['lbl'])>>>sk_clf.predict([['woof']])[0]4.2pandas-dependent wrappersThese wrappers assume theXparameter given tofit,predict, andpredict_probamethods is apandas.DataFrameobject:FirstObjFtClassifier- An sklearn adapter for fasttext using the first column ofdtype == objectas input.>>>fromskiftimportFirstObjFtClassifier>>>df=pandas.DataFrame([['woof',0],['meow',1]],columns=['txt','lbl'])>>>sk_clf=FirstObjFtClassifier(lr=0.2)>>>sk_clf.fit(df[['txt']],df['lbl'])>>>sk_clf.predict([['woof']])[0]ColLblBasedFtClassifier- An sklearn adapter for fasttext taking input by column label. This is set on object construction by providing theinput_col_lblparameter to the constructor.>>>fromskiftimportColLblBasedFtClassifier>>>df=pandas.DataFrame([['woof',0],['meow',1]],columns=['txt','lbl'])>>>sk_clf=ColLblBasedFtClassifier(input_col_lbl='txt',epoch=8)>>>sk_clf.fit(df[['txt']],df['lbl'])>>>sk_clf.predict([['woof']])[0]SeriesFtClassifier- An sklearn adapter for fasttext taking a Pandas Series as input.>>>fromskiftimportSeriesFtClassifier>>>df=pandas.DataFrame([['woof',0],['meow',1]],columns=['txt','lbl'])>>>sk_clf=SeriesFtClassifier(input_col_lbl='txt',epoch=8)>>>sk_clf.fit(df['txt'],df['lbl'])>>>sk_clf.predict(['woof'])>>>sk_clf.predict(df['txt'])4.3Hyperparameter auto-tuningIt’s possible to pass a validation set tofit()in order to optimize the hyper-parameters.First, to adjust theauto-tune settings, the corresponding keyword arguments can be passed to the constructor (if none are passed the default settings are used):>>>fromskiftimportSeriesFtClassifier>>>df_train=pandas.DataFrame([['woof',0],['meow',1]],columns=['txt','lbl'])>>>df_val=pandas.DataFrame([['woof woof',0],['meow meow',1]],columns=['txt','lbl'])>>>sk_clf=SeriesFtClassifier(input_col_lbl='txt',epoch=8,autotuneDuration=5)Then, the validation dataframe (or series, in this case, since we constructed aSeriesFtClassifier) and label column should be provided to thefit()method:>>>sk_clf.fit(df_train['txt'],df_train['lbl'],X_validation=df_val['txt'],y_validation=df_val['lbl'])Or simply by position:>>>sk_clf.fit(df_train['txt'],df_train['lbl'],df_val['txt'],df_val['lbl'])5ContributingPackage author and current maintainer is Shay Palachy (shay.palachy@gmail.com); You are more than welcome to approach him for help. Contributions are very welcomed.5.1Installing for developmentClone:gitclonegit@github.com:shaypal5/skift.gitInstall in development mode, including test dependencies:cdskiftpipinstall-e'.[test]'To also installfasttext, see instructions in the Installation section.5.2Running the testsTo run the tests use:cdskiftpytest5.3Adding documentationThe project is documented using thenumpy docstring conventions, which were chosen as they are perhaps the most widely-spread conventions that are both supported by common tools such as Sphinx and result in human-readable docstrings. When documenting code you add to this project, followthese conventions.Additionally, if you update thisREADME.rstfile,  usepython setup.py checkdocsto validate it compiles.6CreditsCreated by Shay Palachy (shay.palachy@gmail.com).Contributions:Dimid Duchovny <https://github.com/dimidd>_contributed theSeriesFtClassifierclass and the hyperparameter auto-tuning capability.Fixes:uniaz,crouffer,amirzamliandsgt.