This package contains utilities to interact with the AI Squared technology stack, particularly with developing and deploying models to the AI Squared Platform or other applications developed through the AI Squared JavaScript SDK.
This package is available through Pypi and can be installed by running the following command:
pip install aisquaredAlternatively, the latest version of the software can be installed directly from GitHub using the following command
pip install git+https://github.com/AISquaredInc/aisquaredThis package is currently in a state of constant development, so it is likely that breaking changes can be made at any time. We will work diligently to document changes and make stable releases in the future.
The aisquared package currently contains five subpackages, the aisquared.config package, the aisquared.base subpackage, the aisquared.logging subpackage, the aisquared.serving subpackage, and the aisquared.platform package. The config package holds objects for building the configuration files that need to be included with converted model files for use within the AI Squared Extension. The contents of the config subpackage contain both pre- and postprocessing steps as well as harvesting, analytic, rendering, and feedback objects to use with the model. The following will explain the functionality of the config package:
The aisquared.config subpackage contains the following objects:
ModelConfiguration- The
ModelConfigurationobject is the final object to be used to create the configuration file. It takes as input a list of harvesting steps, list of preprocessing steps, a list of analytics, a list of postprocessing steps, a list of rendering steps, an optional MLFlow URI, an optional MLFlow user, and an optional MLFlow token
- The
GraphConfiguration- The `GraphConfiguration object is another method for creating configuration files. Instead of taking a predefined set of steps, it allows the developer to add steps to create a directed acyclic graph
The aisquared.config.harvesting subpackage contains the following objects:
ChatBotHarvester- The
ChatBotHarvesterclass configures harvesting based on data from a ChatBot
- The
ImageHarvester- The
ImageHarvesterclass indicates the harvesting of images within the DOM to perform prediction on
- The
InputHarvester- The
InputHarvesterclass configures harvesting of different kinds of user-defined inputs
- The
QueryParameterHarvester- The
QueryParameterHarvesterclass configures harvesting based on query parameters
- The
TextHarvester- The
TextHarvesterclass indicates the harvesting of text within the DOM to perform prediction on
- The
The aisquared.config.preprocessing subpackage contains the following objects:
ImagePreprocessor- The
ImagePreprocessorclass takes in preprocessing steps (defined below) which define preprocessing steps for images.
- The
TabularPreprocessor- The
TabularPreprocessorclass takes in preprocessing steps (defined below) which define preprocessing steps for tabular data.
- The
TextPreprocessor- The
TextPreprocessorclass takes in preprocessing steps (defined below) which define preprocessing steps for text data.
- The
The aisquared.config.analytic subpackage contains the following objects:
DeployedAnalytic- The
DeployedAnalyticclass indicates the use of an analytic or lookup table from a remote resource
- The
DeployedModel- The
DeployedModelclass indicates the use of a model deployed to a remote resource
- The
LocalAnalytic- The
LocalAnalyticclass indicates the use of an analytic or lookup table from a local file
- The
LocalModel- The
LocalModelclass indicates the use of a model from a local file
- The
OnnxModel- The
OnnxModelclass indicates the use of an ONNX model locally
- The
ReverseMLWorkflow- The
ReverseMLWorkflowclass indicates the use of a Reverse ML Workflow, pulling predictions from a remote source
- The
The aisquared.config.postprocessing subpackage contains the following objects:
BinaryClassification- The
BinaryClassificationobject is a postprocessing class for models which perform binary classification. The class is instantiated with a label map and a cutoff value used to identify when the positive class (class 1) is identified.
- The
MulticlassClassification- The
MulticlassClassificationobject is a postprocessing class for models which perform multiclass classification. The class is instantiated with a label map only.
- The
ObjectDetection- The
ObjectDetectionobject is a postprocessing class for models which perform object detection. The class is instantiated with a label map and a cutoff value for identification.
- The
Regression- The
Regressionobject is a postprocessing class for models which perform regression. Since it is common to train regression models by scaling regression outputs to values between 0 and 1, this class is designed to convert output values between 0 and 1 to their original values, corresponding tominandmaxwhen the class is instantiated.
- The
The aisquared.config.rendering subpackage contains the following objects:
BarChartRendering- The
BarChartRenderingobject is a rendering class for rendering bar charts.
- The
ChatBotRendering- The
ChatBotRenderingobject is a class for rendering chat bots
- The
ContainerRendering- The
ContainerRenderingobject is a rendering class for rendering containers.
- The
DashboardReplacementRendering- The
DashboardReplacementRenderingobject is a rendering class for rendering complete dashboard replacements
- The
DocumentRendering- The
DocumentRenderingobject is a rendering class for rendering document predictions.
- The
DoughnutChartRendering- The
DoughnutChartRenderingobject is a class for rendering doughnut charts
- The
FilterRendering- The
FilterRenderingobject is a class for pass data in a model chain
- The
HTMLTagRendering- The
HTMLTagRenderingobject is a class for rendering HTML tags
- The
ImageRendering- The
ImageRenderingobject is a rendering class for rendering single predictions on images.
- The
LineChartRendering- The
LineChartRenderingobject is a class for rendering line charts
- The
ObjectRendering- The
ObjectRenderingobject is a rendering class for rendering object detection predictions on images.
- The
PieChartRendering- The
PieChartRenderingobject is a class for rendering pie charts
- The
SOSRendering- The
SOSRenderingobject is a class for rendering SOS dashboards
- The
TableRendering- The
TableRenderingobject is a class for rendering tables
- The
TextRendering- The
TextRenderingobject is a class for rendering texts
- The
WordRendering- The
WordRenderingobject is a rendering class for rendering highlights, underlines, or badges on individual words.
- The
The aisquared.config.feedback subpackage contains the following objects:
BinaryFeedback- The
BinaryFeedbackobject is a feedback object for binary classification use cases
- The
ModelFeedback- The
ModelFeedbackobject is a feedback object for configuring feedback for the model directly, rather than its predictions
- The
MulticlassFeedback- The
MulticlassFeedbackobject is a feedback object for multiclass classification use cases
- The
QualitativeFeedback- The
QualitativeFeedbackobject is a feedback object for configuring questions asked about each individual prediction the model makes
- The
RegressionFeedback- The
RegressionFeedbackobject is a feedback object for regression use cases
- The
SimpleFeedback- The
SimpleFeedbackobject is a feedback object for simple thumbs up/thumbs down for predictions
- The
The aisquared.config.preprocessing subpackage contains PreProcStep objects, which are then fed into the ImagePreprocessor, TabularPreprocessor, and TextPreprocessor classes. The PreProcStep classes are:
tabular.ZScore- This class configures standard normalization procedures for tabular data
tabular.MinMax- This class configures Min-Max scaling procedures for tabular data
tabular.OneHot- This class configures One Hot encoding for columns of tabular data
tabular.DropColumn- This class configures dropping columns
image.AddValue- This class configures adding values to pixels in image data
image.SubtractValue- This class configures subtracting values to pixels in image data
image.MultiplyValue- This class configures multiplying pixel values by a value in image data
image.DivideValue- This class configures dividing pixel values by a value in image data
image.ConvertToColor- This class configures converting images to the specified color scheme
image.Resize- This class configures image resize procedures
text.Tokenize- This class configures how text will be tokenized
text.RemoveCharacters- This class configures which characters should be removed from text
text.ConvertToCase- This class configures which case - upper or lower - text should be converted to
text.ConvertToVocabulary- This class configures how text tokens should be converted to vocabulary integers
text.PadSequences- This class configures how padding should occur given a sequence of text tokens converted to a sequence of integers
These step objects can then be placed within the TabularPreprocessor, ImagePreprocessor, or TextPreprocessor objects. For the TabularPreprocessor, the ZScore, MinMax, and OneHot Steps are supported. For the ImagePreprocessor, the AddValue, SubtractValue, MultiplyValue, DivideValue, ConvertToColor, and Resize Steps are supported. For the TextPreprocessor, the Tokenize, RemoveCharacters, ConvertToCase, ConvertToVocabulary, and PadSequences Steps are supported
Once harvesting, preprocessing, analytic, postprocessing, and rendering objects have been created, these objects can then be passed to the aisquared.config.ModelConfiguration class. This class utilizes the objects passed to it to build the entire model configuration automatically.
Once the ModelConfiguration object has been created with the required parameters, the .compile() method can be used to create a file with the .air extension that can be loaded into an application which utilizes the AI Squared JavaScript SDK.
The aisquared.base subpackage contains base utilities not designed to be directly called by the end user.
The aisquared.platform subpackage contains classes and utilities for interacting with the AI Squared Platform. It primarily contains the AISquaredPlatformClient with the following capabilities:
- The ability to securely log in to an instance of the AI Squared Platform
- The ability to check whether the connection is healthy
- The ability to list
.airfiles deployed to the platform - The ability to retrieve the configuration for a
.airfile deployed in the platform - The ability to delete a
.airfile deployed in the platform - The ability to list users who have a
.airfile shared with them - The ability to share a
.airfile with users - The ability to unshare a
.airfile with users - The ability to list all users of the platform
- The ability to list all groups in the platform
- The ability to list all users in a group in the platform
The aisquared.serving subpackage contains utilities for serving models locally or remotely using MLflow or locally using Flask.
The aisquared.logging subpackage is powered by MLflow, a powerful open-source platform for the machine learning lifecycle. The logging subpackage inherits nearly all functionality from mlflow, so we highly recommend users refer to the MLflow documentation site for additional information.
In this subpackage, we have additionally added implementations of individual functions to save TensorFlow, Keras, Scikit-Learn, and PyTorch models in a format that can be deployed quickly using MLflow.
AI Squared welcomes feedback and contributions to this repository! We use GitHub for issue tracking, so feel free to place your input there. For any issues you would like to keep confidential, such as any confidential security issues, or if you would like to contribute directly to this project, please reach out to [email protected] and we will get back to you as soon as possible.
Below are a list of additional features, bug fixes, and other changes made for each version.
- Added
flagsparameter toTextHarvesterusing regular expression harvesting - Deleted
model_feedbackparameter inModelConfigurationobject and included functionality infeedback_stepsparameter - Changed
formatparameter toheaderfor both deployed analytics - Added feedback and stages to
DocumentPredictorandImagePredictorobjects - Non-API changes for
ALLOWED_STAGES - Fixed bugs preventing Windows users from importing the package
- Updated
ModelConfigurationto includeurlparameter - Changed default tokenization string
- Moved preprocessing steps under subpackages for specific kinds of preprocessing steps
- Cleaned up documentation to render within programmatic access environments
- Added
aisquared.loggingsubpackage - Created
InputHarvester- Allows for harvesting of input text, images, and tabular data
- Created the
aisquared.servingsubpackage, specifically thedeploy_modelandget_remote_predictionfunctions - Created the
GraphConfigurationclass - Added
auto-runparameter toModelConfigurationandGraphConfigurationclasses - Created the
aisquaredCLI with the following commands:aisquared deploy, which deploys a model locallyaisquared predict, which predicts using a local JSON fileaisquared airfiles, which contains the subcommandslist,delete,download, andupload
- Changed all classes within
aisquared.config.analyticto accept'tabular'as aninput_type - Removed
aisquared.loggingandaisquared.remotefrom top-level imports - Added
roundparameter to Regression postprocesser - Removed
DocumentPredictorandImagePredictorclasses - Removed
ChainRenderingclass - Created
FilterRenderingclass - Altered
QUALIFIERS - Added advanced rendering parameters to rendering objects
- Removed
loggingandremotesubpackages from top-levelaisquaredimport
- Added the
S3Connectorclass to theanalyticssubpackage, which allows download of an analytic directly from S3 - Updated the documentation and added the
docssubdirectory for hosting the documentation on GitHub Pages
- Fixed bug in
to_dictmethod withinObjectRenderingclass - Fixed bug in name of
MultiplyValuestep - Fixed bug in datatype checking for text harvester
- Added
body_onlyparameter toTextHarvester - Added
'underline'to possible badges - Added
threshold_keyandthreshold_valuesto relevant rendering classes - Added
Trimtext preprocessing class - Added
CustomObjectin the base package to allow for creation of custom classes - Added keyword harvesting capabilities
- Added
utilssubpackage with capabilities to mimic a trained sklearn model - Small documentation changes
- Changed the required imports for the package to streamline installation process, and created two installation options
aisquaredandaisquared[full]
- Added functionality to add custom preprocessing and postprocessing functions to the model deployment pipeline
- Added
allparameter toLocalAnalyticclass - Changed under-the-hood functionality of
mimic_modelfunction in line with updates toBeyondML - Altered the
ReverseMLWorkflowanalytic - Added the
BarChartRendering,ContainerRendering,DashboardReplacementRendering,DoughnutChartRendering,HTMLTagRendering,LineChartRendering,PieChartRendering,SOSRendering, andTableRenderingrendering classes - Added the
QueryParameterHarvesterharvester class - Added the
limitparameter to the TextHarvester class
- Added type hinting to documentation strings
- Revamped documentation to use Sphinx
- Changed Python type hints to allow for backwards compatibility with older versions of Python
- Added functionality to the
AISquaredPlatformClient - Added
top_level_kwargsparameter to theCustomObjectclass - Added
DashboardRenderingclass - Removed 'px' from default values in ImageRendering and ObjectRendering classes
- Added functionality for creating, updating, and deleting users to
AISquaredPlatformClient - Added functionality for creating, updating, and delting groups to
AISquaredPlatformClient - Fixed bug related to requiring
auto_runparameter to be string (fix involves casting as string) - Altered schemas for different "Chart" Rendering classes to conform to JavaScript standards
- Streamlined the
ModelConfigurationclass to allow a more functional interface to build.airfiles - Updated
ContainerRenderingclass with parameters forpositionandstatic_position - Updated across-the-board functionality of the
AISquaredPlatformClient
- Updated functionality of the
AISquaredPlatformClientto interact directly with the platform ALB - Changed function names in support of change from MANN to BeyondML
- Added documentation surrounding global configuration objects
- Removed redundant additional dependencies
- Added support for custom CSS strings to appropriate rendering classes
- Refactored
AISquaredPlatformClientto import functions from support files - Fixed documentation errors for the documentation site
- Checked whether responses returned OK status code rather than 200
- Moved
CustomObjecttoaisquared.configfromaisquared.base - Changed endpoint used to list platform users
- Fixed response behaviors where no data was returned from
AISquaredPlatformClient
- Changed
file_nameparameter inReverseMLWorkflowtofile_names - Added
documentation_linkparameter toModelConfigurationclass
- Fixed issue with type checking for
ModelConfigurationRendering classes - Restricted TensorFlow version to below
2.12.0to prevent import issues - Added
positionparameter toWordRenderingclass - Changed default CSS styling for rendering classes
- Changed name of all
processorclasses toprocesser
- Changed schema of the
DeployedAnalyticclass to include API key management - Changed JSON schema of Preprocesser classes
- Allowed .keras files to be saved and loaded with the
ModelConfigurationandGraphConfigurationAPIs into.airfiles - Relaxed TensorFlow requirements enforced in version
0.3.6
- Created
ChatbotHarvesterclass - Created
TextRenderingclass - Changed location of reference lists of classes to clean up code
- Updated class schemas to ensure compliance with expectations
- Updated test cases
- Added
CustomRenderingclass - Changed to full import of
CustomObjectinaisquared.basesubpackage
- Added
DatabricksClientto theaisquared.platformsubpackage
- Updated
DeployedModelclass configuration to conform to AIRJS - Updated
DatabricksClientclass to includeupdate_jobfunction - Updated custom CSS fields in rendering classes
- Reconfigured
ReverseMLWorkflowclass - Added
'User-Agent'to headers forAISquaredPlatformClientandDatabricksClient - Added
llmlinkas a dependency to the 'full' installation ofaisquaredand added it as a top-level package
- Updated
DeployedModelclass to support more abstract API calls - Updated
ChatbotHarvester,DeployedAnalytic, andChatRenderingclasses - Updated
ModelConfigurationclass withwarningsanddocumentURL - Updated
DeployedAnalyticclass with more general support for API calls,DeployedModelto be deprecated - Created
ONNXModelclass to support ONNX models
- Removed TensorFlow from base dependencies due to issues with running
aisquaredon Mac ARM devices