Package: aisquared
AISquaredThis 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.InstallationThis package is available throughPypiand can be installed by running the following command:pipinstallaisquaredAlternatively, the latest version of the software can be installed directly from GitHub using the following commandpipinstallgit+https://github.com/AISquaredInc/aisquaredCapabilitiesThis 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.Theaisquaredpackage currently contains five subpackages, theaisquared.configpackage, theaisquared.basesubpackage, theaisquared.loggingsubpackage, theaisquared.servingsubpackage, and theaisquared.platformpackage. Theconfigpackage 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:aisquared.configTheaisquared.configsubpackage contains the following objects:ModelConfigurationTheModelConfigurationobject 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 tokenGraphConfigurationThe `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 graphaisquared.config.harvestingTheaisquared.config.harvestingsubpackage contains the following objects:ImageHarvesterTheImageHarvesterclass indicates the harvesting of images within the DOM to perform prediction onTextHarvesterTheTextHarvesterclass indicates the harvesting of text within the DOM to perform prediction onInputHarvesterTheInputHarvesterclass configures harvesting of different kinds of user-defined inputsQueryParameterHarvesterTheQueryParameterHarvesterclass configures harvesting based on query parametersaisquared.config.preprocessingTheaisquared.config.preprocessingsubpackage contains the following objects:ImagePreprocessorTheImagePreprocessorclass takes in preprocessing steps (defined below) which define preprocessing steps for images.TabularPreprocessorTheTabularPreprocessorclass takes in preprocessing steps (defined below) which define preprocessing steps for tabular data.TextPreprocessorTheTextPreprocessorclass takes in preprocessing steps (defined below) which define preprocessing steps for text data.aisquared.config.analyticTheaisquared.config.analyticsubpackage contains the following objects:LocalAnalyticTheLocalAnalyticclass indicates the use of an analytic or lookup table from a local fileLocalModelTheLocalModelclass indicates the use of a model from a local fileDeployedAnalyticTheDeployedAnalyticclass indicates the use of an analytic or lookup table from a remote resourceDeployedModelTheDeployedModelclass indicates the use of a model deployed to a remote resourceReverseMLWorkflowTheReverseMLWorkflowclass indicates the use of a Reverse ML Workflow, pulling predictions from a remote sourceaisquared.config.postprocessingTheaisquared.config.postprocessingsubpackage contains the following objects:RegressionTheRegressionobject 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.BinaryClassificationTheBinaryClassificationobject 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.MulticlassClassificationTheMulticlassClassificationobject is a postprocessing class for models which perform multiclass classification. The class is instantiated with a label map only.ObjectDetectionTheObjectDetectionobject is a postprocessing class for models which perform object detection. The class is instantiated with a label map and a cutoff value for identification.aisquared.config.renderingTheaisquared.config.renderingsubpackage contains the following objects:ImageRenderingTheImageRenderingobject is a rendering class for rendering single predictions on images.ObjectRenderingTheObjectRenderingobject is a rendering class for rendering object detection predictions on images.WordRenderingTheWordRenderingobject is a rendering class for rendering highlights, underlines, or badges on individual words.DocumentRenderingTheDocumentRenderingobject is a rendering class for rendering document predictions.BarChartRenderingTheBarChartRenderingobject is a rendering class for rendering bar charts.ContainerRenderingTheContainerRenderingobject is a rendering class for rendering containers.DashboardReplacementRenderingTheDashboardReplacementRenderingobject is a rendering class for rendering complete dashboard replacementsDoughnutChartRenderingTheDoughnutChartRenderingobject is a class for rendering doughnut chartsFilterRenderingTheFilterRenderingobject is a class for pass data in a model chainHTMLTagRenderingTheHTMLTagRenderingobject is a class for rendering HTML tagsPieChartRenderingThePieChartRenderingobject is a class for rendering pie chartsSOSRenderingTheSOSRenderingobject is a class for rendering SOS dashboardsTableRenderingTheTableRenderingobject is a class for rendering tablesaisquared.config.feedbackTheaisquared.config.feedbacksubpackage contains the following objects:SimpleFeedbackTheSimpleFeedbackobject is a feedback object for simple thumbs up/thumbs down for predictionsBinaryFeedbackTheBinaryFeedbackobject is a feedback object for binary classification use casesMulticlassFeedbackTheMulticlassFeedbackobject is a feedback object for multiclass classification use casesRegressionFeedbackTheRegressionFeedbackobject is a feedback object for regression use casesModelFeedbackTheModelFeedbackobject is a feedback object for configuring feedback for the model directly, rather than its predictionsQualitativeFeedbackTheQualitativeFeedbackobject is a feedback object for configuring questions asked about each individual prediction the model makesPreprocessing StepsTheaisquared.config.preprocessingsubpackage containsPreProcStepobjects, which are then fed into theImagePreprocessor,TabularPreprocessor, andTextPreprocessorclasses. ThePreProcStepclasses are:tabular.ZScoreThis class configures standard normalization procedures for tabular datatabular.MinMaxThis class configures Min-Max scaling procedures for tabular datatabular.OneHotThis class configures One Hot encoding for columns of tabular datatabular.DropColumnThis class configures dropping columnsimage.AddValueThis class configures adding values to pixels in image dataimage.SubtractValueThis class configures subtracting values to pixels in image dataimage.MultiplyValueThis class configures multiplying pixel values by a value in image dataimage.DivideValueThis class configures dividing pixel values by a value in image dataimage.ConvertToColorThis class configures converting images to the specified color schemeimage.ResizeThis class configures image resize procedurestext.TokenizeThis class configures how text will be tokenizedtext.RemoveCharactersThis class configures which characters should be removed from texttext.ConvertToCaseThis class configures which case - upper or lower - text should be converted totext.ConvertToVocabularyThis class configures how text tokens should be converted to vocabulary integerstext.PadSequencesThis class configures how padding should occur given a sequence of text tokens converted to a sequence of integersThese step objects can then be placed within theTabularPreprocessor,ImagePreprocessor, orTextPreprocessorobjects. For theTabularPreprocessor, theZScore,MinMax, andOneHotSteps are supported. For theImagePreprocessor, theAddValue,SubtractValue,MultiplyValue,DivideValue,ConvertToColor, andResizeSteps are supported. For theTextPreprocessor, theTokenize,RemoveCharacters,ConvertToCase,ConvertToVocabulary, andPadSequencesSteps are supportedFinal Configuration and Model CreationOnce harvesting, preprocessing, analytic, postprocessing, and rendering objects have been created, these objects can then be passed to theaisquared.config.ModelConfigurationclass. This class utilizes the objects passed to it to build the entire model configuration automatically.Once theModelConfigurationobject has been created with the required parameters, the.compile()method can be used to create a file with the.airextension that can be loaded into an application which utilizes the AI Squared JavaScript SDK.aisquared.baseTheaisquared.basesubpackage contains base utilities not designed to be directly called by the end user.aisquared.platformTheaisquared.platformsubpackage contains classes and utilities for interacting with the AI Squared Platform. It primarily contains theAISquaredPlatformClientwith the following capabilities:The ability to securely log in to an instance of the AI Squared PlatformThe ability to check whether the connection is healthyThe ability to list.airfiles deployed to the platformThe ability to retrieve the configuration for a.airfile deployed in the platformThe ability to delete a.airfile deployed in the platformThe ability to list users who have a.airfile shared with themThe ability to share a.airfile with usersThe ability to unshare a.airfile with usersThe ability to list all users of the platformThe ability to list all groups in the platformThe ability to list all users in a group in the platformaisquared.serving(requires installing aisquared[full])Theaisquared.servingsubpackage contains utilities for serving models locally or remotely usingMLflowor locally usingFlask.aisquared.logging(requires installing aisquared[full])Theaisquared.loggingsubpackage is powered byMLflow, a powerful open-source platform for the machine learning lifecycle. Theloggingsubpackage inherits nearly all functionality from mlflow, so we highly recommend users refer to theMLflow documentation sitefor 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.ContributingAI 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 topythonsdk@squared.aiand we will get back to you as soon as possible.ChangesBelow are a list of additional features, bug fixes, and other changes made for each version.Version 0.1.3Addedflagsparameter toTextHarvesterusing regular expression harvestingDeletedmodel_feedbackparameter inModelConfigurationobject and included functionality infeedback_stepsparameterChangedformatparameter toheaderfor both deployed analyticsAdded feedback and stages toDocumentPredictorandImagePredictorobjectsNon-API changes forALLOWED_STAGESFixed bugs preventing Windows users from importing the packageUpdatedModelConfigurationto includeurlparameterChanged default tokenization stringVersion 0.2.0Moved preprocessing steps under subpackages for specific kinds of preprocessing stepsCleaned up documentation to render within programmatic access environmentsAddedaisquared.loggingsubpackageCreatedInputHarvesterAllows for harvesting of input text, images, and tabular dataCreated theaisquared.servingsubpackage, specifically thedeploy_modelandget_remote_predictionfunctionsCreated theGraphConfigurationclassAddedauto-runparameter toModelConfigurationandGraphConfigurationclassesCreated theaisquaredCLI 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, anduploadChanged all classes withinaisquared.config.analyticto accept'tabular'as aninput_typeRemovedaisquared.loggingandaisquared.remotefrom top-level importsAddedroundparameter to Regression postprocesserRemovedDocumentPredictorandImagePredictorclassesRemovedChainRenderingclassCreatedFilterRenderingclassAlteredQUALIFIERSAdded advanced rendering parameters to rendering objectsRemovedloggingandremotesubpackages from top-levelaisquaredimportVersion 0.2.1Added theS3Connectorclass to theanalyticssubpackage, which allows download of an analytic directly from S3Updated the documentation and added thedocssubdirectory for hosting the documentation on GitHub PagesVersion 0.2.2Fixed bug into_dictmethod withinObjectRenderingclassFixed bug in name ofMultiplyValuestepFixed bug in datatype checking for text harvesterAddedbody_onlyparameter toTextHarvesterAdded'underline'to possible badgesAddedthreshold_keyandthreshold_valuesto relevant rendering classesAddedTrimtext preprocessing classAddedCustomObjectin the base package to allow for creation of custom classesAdded keyword harvesting capabilitiesAddedutilssubpackage with capabilities to mimic a trained sklearn modelSmall documentation changesChanged the required imports for the package to streamline installation process, and created two installation optionsaisquaredandaisquared[full]Version 0.2.3Added functionality to add custom preprocessing and postprocessing functions to the model deployment pipelineAddedallparameter toLocalAnalyticclassChanged under-the-hood functionality ofmimic_modelfunction in line with updates toBeyondMLAltered theReverseMLWorkflowanalyticAdded theBarChartRendering,ContainerRendering,DashboardReplacementRendering,DoughnutChartRendering,HTMLTagRendering,LineChartRendering,PieChartRendering,SOSRendering, andTableRenderingrendering classesAdded theQueryParameterHarvesterharvester classAdded thelimitparameter to the TextHarvester classVersion 0.3.0Added type hinting to documentation stringsRevamped documentation to use SphinxVersion 0.3.1Changed Python type hints to allow for backwards compatibility with older versions of PythonVersion 0.3.2Added functionality to theAISquaredPlatformClientAddedtop_level_kwargsparameter to theCustomObjectclassAddedDashboardRenderingclassRemoved 'px' from default values in ImageRendering and ObjectRendering classesAdded functionality for creating, updating, and deleting users toAISquaredPlatformClientAdded functionality for creating, updating, and delting groups toAISquaredPlatformClientFixed bug related to requiringauto_runparameter to be string (fix involves casting as string)Altered schemas for different "Chart" Rendering classes to conform to JavaScript standardsStreamlined theModelConfigurationclass to allow a more functional interface to build.airfilesUpdatedContainerRenderingclass with parameters forpositionandstatic_positionUpdated across-the-board functionality of theAISquaredPlatformClientVersion 0.3.3Updated functionality of theAISquaredPlatformClientto interact directly with the platform ALBChanged function names in support of change from MANN to BeyondMLAdded documentation surrounding global configuration objectsRemoved redundant additional dependenciesVersion 0.3.4Added support for custom CSS strings to appropriate rendering classesRefactoredAISquaredPlatformClientto import functions from support filesFixed documentation errors for the documentation siteChecked whether responses returned OK status code rather than 200MovedCustomObjecttoaisquared.configfromaisquared.baseChanged endpoint used to list platform usersFixed response behaviors where no data was returned fromAISquaredPlatformClientVersion 0.3.5Changedfile_nameparameter inReverseMLWorkflowtofile_namesAddeddocumentation_linkparameter toModelConfigurationclassVersion 0.3.6Fixed issue with type checking forModelConfigurationRendering classesRestricted TensorFlow version to below2.12.0to prevent import issuesAddedpositionparameter toWordRenderingclassChanged default CSS styling for rendering classesChanged name of allprocessorclasses toprocesserVersion 0.3.7Changed schema of theDeployedAnalyticclass to include API key managementChanged JSON schema of Preprocesser classesAllowed .keras files to be saved and loaded with theModelConfigurationandGraphConfigurationAPIs into.airfilesRelaxed TensorFlow requirements enforced in version0.3.6Version 0.3.8CreatedChatbotHarvesterclassCreatedTextRenderingclassChanged location of reference lists of classes to clean up codeUpdated class schemas to ensure compliance with expectationsUpdated test casesVersion 0.3.9AddedCustomRenderingclassChanged to full import ofCustomObjectinaisquared.basesubpackageVersion 0.3.10AddedDatabricksClientto theaisquared.platformsubpackage