Skip to main content

The library that automates the silly ML things.

Project description

AutoAI

This repository is a compilation of scripts that I have created in my time working with machine learning. These scripts aim to automate the annoying and tedious parts of ML, allowing you to focus on what is important. PyPi: https://pypi.org/project/AutoAILib/
$ pip install autoailib
This library was developed for and used with keras convolutional neural networks. They do however work with other keras models, besides image test obviously.

AutoAiLib.general_tester(model path or object, labels, preprocessor)

Class Video Demo

AutoAiLib.general_tester.predict_single(example)

  • example- If you have defined a preprocessor for your tester, this should comply with the preprocessor's argument. If you have not defined a preprocessor, example must be in a form that your model will accept.

AutoAiLib.general_tester.predict_many(container=None, testing_folder = None, csv_dir)

  • container - This can be a container of test objects (any iterable). If preprocessor is defined, these objects must comply with the preprocessors parameter. Otherwise they must be in a form that your model will accept.
  • testing_dir - This can be a path to a testing folder which has sub folders of all classes. Again, must be preprocessed or have preprocessor defined.
  • csv_dir - This function compiles data into a csv folder to allow users to easily extract data from it, if not defined it will return a pandas data frame.

AutoAi.convnet_tester(model path or object, labels)

Class Video Demo

AutoAi.image_predict(model_path, image_path, labels)

This function takes 3 arguments: a path to a keras model, a path to an image, and a list of labels.
Demo:
Given a the correct arguments, we get the following output, as well as this image saved to our model directory.

AutoAi.manual_test(model, testing_dir, labels)

This function tests a model given labels and testing data. It then compiles the results in a CSV file, and groups the results by class, and by correct and incorrect.
  • Model - Path of model that you want to test or model object.
  • Testing_dir - Path to the directory with your testing data.
  • Labels - Dictionary of the classes, in form (index:class_name)
Example csv:

Update! This has now been packaged in the AutoAI.data_compiler class. AutoAi.data_compiler(self,src, dest, **kwargs)
AutoAi.data_compiler.run() will compile the data based on the constructor parameters.

This function takes 2 required arguments, an original data source file, and a path to the desired data directory. Given just these two arguments, this function will create a new testing data folder at dest with training, validation, and testing folders, containing folders for each class. You can alter the ratio with the ratio arguments, as well as provide a number of img transforms to do if you are using images.
  • Src - Path to a folder that contains a folder for each class and then data examples in those class folders.
  • Dest - Path to a folder where you want the data to end up.
  • Num_imgs_per_class - This number of images will be added to the original set for each class through transforms. The theoretical limit for this would be 3! * original images per class
Demo:
Given the a path to the following folder: If augmentation used the following results will be yielded: Then these images will be copied to the dest folder with copied file structure, but an added upper layer: Example showing the images made it:

Homeless Methods:

model_to_img(model_path)

  • Returns an image form of your model.

plot(history=None, file=None, min_=0, max_=1)

  • history- numpy file (Keras callback)
  • file - path to a .npy file.
  • min_ - the minimum of accuracy/loss in the graph
  • max_ - the maximum of accuracy/loss in the graph, the closer the min and max, the more zoomed your graph will be

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AutoAiLib-1.1.0.tar.gz (7.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page