Package: cleanlab-studio
cleanlab-studioCommand line and Python library interface toCleanlab Studio. Analyze datasets and producecleansets(cleaned datasets) with Cleanlab Studio in a single line of code!InstallationQuickstartAdvanced UsageDocumentation/TutorialsInstallationYou can install the Cleanlab Studio clientfrom PyPIwith:pipinstallcleanlab-studioIf you already have the client installed and wish to upgrade to the latest version, run:pipinstall--upgradecleanlab-studioQuickstartPython API -- run Cleanlab Studio from Python or Jupyter Notebookfromcleanlab_studioimportStudio# create your Cleanlab Studio API client with your API key, found here: https://app.cleanlab.ai/accountstudio=Studio(<yourapikey>)# upload your dataset via a filepath, Pandas DataFrame, or PySpark DataFrame!dataset_id:str=studio.upload_dataset(<yourdataset>,<yourdatasetname>)# navigate to Cleanlab Studio, create a project, and improve your labels# download your cleanset or apply corrections to your local Pandas or PySpark dataset!# you can find your cleanset ID by clicking on the Export Cleanset button in your projectcleanset=studio.download_cleanlab_columns(<yourcleansetid>)corrected_dataset=studio.apply_corrections(<yourcleansetid>,<yourdataset>)The Python API offers significantly more functionality than is available in the Cleanlab Studio Web Application. Learn more via thetutorialsandquickstart guide.CLI -- run Cleanlab Studio from your command lineIf this is your first time using the Cleanlab CLI, authenticate withcleanlab login. You can find your API key athttps://app.cleanlab.ai/account.Upload your dataset (image, text, or tabular) usingcleanlab dataset upload.Create a project in Cleanlab Studio.Improve your dataset in Cleanlab Studio (e.g., correct some labels).Download your cleanset withcleanlab cleanset download.Learn more about the Cleanlab Studio CLI from thequickstart guide.Dataset StructureCleanlab Studio supports the following data formats:Text/TabularCSVJSONXLS/XLSXPandas DataFrame(Python library only)PySpark DataFrame(Python library only)more to come!ImageCSV (external media)JSON (external media)XLS/XLSX (external media)Pandas DataFrame (external media)(Python library only)PySpark DataFrame (external media)(Python library only)Simple ZIP uploadMetadata ZIP uploadmore to come!Information on how to format your dataset can be found by clicking the tutorial onhttps://app.cleanlab.ai/uploador in theDatasets concept guide. We also provide tutorials for converting certain common Pythonimageortextdatasets.Advanced UsageSchemaPython APIAll schema information will be inferred by default when uploading a dataset through the Python API. We provide some options to override the inferred schema if necessary:To override the dataset modality, supply amodalitykwarg tostudio.upload_dataset(). Supported modalities include "text", "tabular", and "image"To override the ID column, supply anid_columnkwarg tostudio.upload_dataset()To override column types in your dataset, supply aschema_overrideskwarg tostudio.upload_dataset()in the following format:{
  <name_of_column_to_override>: {
    "data_type": <desired_data_type>,
    "feature_type": <desired_feature_type>,
  },
  ...
}CLITo specify the column types in your dataset, create a JSON file namedschema.json. If you would like to edit an inferred schema (rather than starting from scratch) follow these steps:Kick off a dataset upload using:cleanlab dataset uploadOnce schema generation is complete, you'll be asked whether you'd like to use our inferred schema. Enternto declineYou'll then be asked whether you'd like to save the inferred schema. Enteryto accept. Then enter the filename you'd like to save to (schema.jsonby default)Edit the schema file as you wishKick off a dataset upload again using:cleanlab dataset upload --schema_path [path to schema file]Your schema file should be formatted as follows:{"metadata":{"id_column":"tweet_id","modality":"text","name":"Tweets.csv"},"fields":{"tweet_id":{"data_type":"string","feature_type":"identifier"},"sentiment":{"data_type":"string","feature_type":"categorical"},"sentiment_confidence":{"data_type":"float","feature_type":"numeric"},"retweet_count":{"data_type":"integer","feature_type":"numeric"},"text":{"data_type":"string","feature_type":"text"},"tweet_created":{"data_type":"boolean","feature_type":"boolean"},"tweet_created":{"data_type":"string","feature_type":"datetime"}},"version":"0.1.12"}This is the schema of a hypothetical datasetTweets.csvthat contains tweets, where the columntweet_idcontains a
unique identifier for each record. Each column in the dataset is specified underfieldswith its data type and feature
type.Data types and Feature typesData typerefers to the type of the field's values: string, integer, float, or boolean.Note that the integer type is partiallystrict, meaning floats that are equal to integers (e.g.1.0,2.0, etc)
will be accepted, but floats like0.8and1.5will not. In contrast, the float type islenient, meaning integers
are accepted. Users should select the float type if the field may include float values. Note too that integers can have
categorical and identifier feature types, whereas floats cannot.For booleans, the list of accepted values are: true/false, t/f, yes/no, 1/0, 1.0/0.0.Feature typerefers to the secondary type of the field, relating to how it is used in a machine learning model, such
as whether it is:a categorical valuea numeric valuea datetime valuea boolean valuetextan identifier — a string / integer that identifies some entitya filepath value (only valid for image datasets)Some feature types can only correspond to specific data types. The list of possible feature types for each data type is
shown belowData typeFeature typestringtext, categorical, datetime, identifier, filepathintegercategorical, datetime, identifier, numericfloatdatetime, numericbooleanbooleanThedatetimetype should be used for datetime strings, e.g. "2015-02-24 11:35:52 -0800", and Unix timestamps (which
will be integers or floats). Datetime values must be parseable
bypolars.from_epochfor integer/floats orpolars.Expr.str.strptimefor strings.versionindicates the version of the Cleanlab CLI package version used to generate the schema.Other ResourcesDocumentation-- tutorials on how to use Cleanlab Studio and guides to learn key conceptsBlog-- end-to-end applications, feature announcements, how-it-works explanations, benchmarksSlack Community-- ask questions, request features, discuss Data-Centric AI with othersNeed professional help or want demo? Reach out via email:team@cleanlab.ai