Package: helperfns
helperfns🎀 This is a python package that contains some helper functions for machine leaning.Getting startedTo start usinghelperfnsin your project you run the following command:pipinstallhelperfnsOr if you wan to install it in notebooks such as jupyter notebooks you can run the code cell with the following code:!pipinstallhelperfnsUsageThehelperfnspackage is made up of different sub packages such as:tablestextutilsvisualizationtablesIn the tables sub package you can print your data in tabular form for example:fromhelperfns.tablesimporttabulate_datacolumn_names=["SUBSET","EXAMPLE(s)","Hello"]row_data=[["training",5,4],['validation',4,4],['test',3,'']]tabulate_data(column_names,row_data)Output:Table

+------------+------------+-------+|SUBSET|EXAMPLE(s)|Hello|+------------+------------+-------+|training|5|4||validation|4|4||test|3||+------------+------------+-------+textThe text package offers two main function which areclean_sentence,de_contract,generate_ngramsandgenerate_bigramsfromhelperfns.textimport*# cleans the sentenceprint(clean_sentence("text 1 # https://url.com/bla1/blah1/"))# list of all english wordsprint(english_words)# converts strings like `I'm` to 'I am'print(de_contract("I'm"))# generate bigrams from a list of wordprint(text.generate_bigrams(['This','film','is','terrible']))# generates n-grams from a list of wordsprint(text.generate_ngrams(['This','film','is','terrible']))utilsutils package comes with a simple helper function for converting seconds to hours, minutes and seconds.Example:fromhelperfns.utilsimporthms_stringstart=time.time()foriinrange(100000):passend=time.time()print(hms_string(end-start))Output:'0:00:00.01'It also comes with a helper functions for normalizing an image so that it can be ploted using matplot lib:Example:fromhelperfns.utilsimportnormalize_imageimage=normalize_image(image)plt.imshow(image.permute(1,2,0).cpu().numpy())visualizationThis sub package provides different helper functions for visualizing data using plots.Examples:fromhelperfns.visualizationimportplot_complicated_confusion_matrix,plot_images,plot_images_predictions,plot_simple_confusion_matrix,plot_classification_report# plotting classification reportfig,ax=plot_classification_report(labels,preds,title='Classification Report',figsize=(10,5),dpi=70,target_names=classes)# plot predicted image labels with the imagesplot_images_predictions(images,true_labels,preds,classes=["dog","cat"],cols=8)# plot the images with their labelsplot_images(images[:24],true_labels[:24],cols=8)# plot a simple confusion matrixy_true=[random.randint(0,1)for_inrange(100)]y_pred=[random.randint(0,1)for_inrange(100)]classes=["dog","cat"]plot_simple_confusion_matrix(y_true,y_pred,classes)# plot a confusion matrix with percentage value of confusiony_true=[random.randint(0,1)for_inrange(100)]y_pred=[random.randint(0,1)for_inrange(100)]classes=["dog","cat"]plot_complicated_confusion_matrix(y_true,y_pred,classes)Contributing tohelperfns.To contribute tohelperfnsread theCONTRIBUTION.mdfile.LicenseIn this package theMITlicense was used which reads as follows:MIT License



Copyright (c) 2022 crispengari



Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:



The above copyright notice and this permission notice shall be included in all

copies or substantial portions of the Software.



THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

SOFTWARE.