@@ -62,7 +62,7 @@ class DeploymentType(Enum):
6262 ONPREM = 1
6363 AWS = 2
6464 GCP = 3
65- AZURE = 4
65+ AZURE = 43
6666
6767
6868# NOTE: Don't modify this unless you are deploying on-prem.
@@ -103,6 +103,39 @@ def create_project(
103103 name : str ,
104104 description : str ,
105105 ):
106+ """Creates a project on the Unbox platform.
107+
108+ Parameters
109+ ----------
110+ name : str
111+ Name of your project.
112+
113+ .. important::
114+ The project name must be unique in a user's account. Furthermore, this is the name
115+ that is used to identify the project when uploading models and datasets.
116+
117+ description : str
118+ Project description.
119+
120+ Returns
121+ -------
122+ Project
123+ An object that is used to upload models and datasets to the Unbox platform that
124+ also contains information about the project.
125+
126+ Examples
127+ --------
128+ Instantiate the client and create the project:
129+
130+ >>> import unboxapi
131+ >>> client = unboxapi.UnboxClient('YOUR_API_KEY_HERE')
132+ >>>
133+ >>> project = client.create_project(name="Churn prediction",
134+ ... description="My first error analysis playground")
135+
136+ With the Project object created, you are able to start uploading models and datasets to the platform. Refer to :obj:`add_model`
137+ and obj:`add_dataset` or obj:`add_dataframe` for detailed examples.
138+ """
106139 # ----------------------------- Schema validation ---------------------------- #
107140 project_schema = ProjectSchema ()
108141 try :
@@ -123,6 +156,34 @@ def create_project(
123156 return Project (project_data , self .upload , self .subscription_plan , self )
124157
125158 def load_project (self , name : str ):
159+ """Loads an existing project from the Unbox platform.
160+
161+ Parameters
162+ ----------
163+ name : str
164+ Name of the project to be loaded. The name of the project is the one displayed on the Unbox platform.
165+
166+ .. note::
167+ If you haven't created the project yet, you should use the :obj:`create_project` method.
168+
169+ Returns
170+ -------
171+ Project
172+ An object that is used to upload models and datasets to the Unbox platform that
173+ also contains information about the project.
174+
175+ Examples
176+ --------
177+ Instantiate the client and load the project:
178+
179+ >>> import unboxapi
180+ >>> client = unboxapi.UnboxClient('YOUR_API_KEY_HERE')
181+ >>>
182+ >>> project = client.load_project(name="Churn prediction")
183+
184+ With the Project object loaded, you are able to upload models and datasets to the platform. Refer to :obj:`add_model`
185+ and obj:`add_dataset` or obj:`add_dataframe` for detailed examples.
186+ """
126187 endpoint = f"load_project/{ name } "
127188 project_data = self .api .get_request (endpoint )
128189 return Project (project_data , self .upload , self .subscription_plan , self )
@@ -153,6 +214,13 @@ def add_model(
153214 ----------
154215 name : str
155216 Name of your model.
217+
218+ .. important::
219+ Versioning models on the Unbox platform happens via the ``name`` argument. If ``add_model`` is called
220+ with a ``name`` that still does not exist inside the project, Unbox treats it as the **first version** of a new model lineage.
221+ On the other hand, if the ``name`` argument value already exists inside the project, Unbox treats it as a **new version** of an existing
222+ model lineage.
223+
156224 task_type : :obj:`TaskType`
157225 Type of ML task. E.g. :obj:`TaskType.TextClassification`.
158226 function :
@@ -174,8 +242,8 @@ def add_model(
174242 feature_names : List[str], default []
175243 List of input feature names. Only applicable if your ``task_type`` is
176244 :obj:`TaskType.TabularClassification` or :obj:`TaskType.TabularRegression`.
177- categorical_features_map : Dict [str], default {}
178- A dict containing a list of category names for each feature that is categorical. E.g. `{'Weather': ['Hot', 'Cold']} `.
245+ categorical_feature_names : List [str], default []
246+ A list containing the feature names for each feature that is categorical. E.g. `["Gender", "Geography"] `.
179247 Only applicable if your ``task_type`` is :obj:`TaskType.TabularClassification` or :obj:`TaskType.TabularRegression`.
180248 train_sample_df : pd.DataFrame, default None
181249 A random sample of >= 100 rows from your training dataset. This is used to support explainability features.
@@ -213,11 +281,24 @@ def add_model(
213281 Our `sample notebooks <https://github.com/unboxai/unboxapi-python-client/tree/main/examples>`_ and
214282 `tutorials <https://unbox.readme.io/docs/overview-of-tutorial-tracks>`_.
215283
216- Instantiate the client:
284+
285+ The models are uploaded directly into a **project** on the Unbox platform, using the ``project.add_model()`` method.
286+ Therefore, you need to get the project object to start uploading your models.
287+
288+ First, instantiate the client:
217289
218290 >>> import unboxapi
219291 >>> client = unboxapi.UnboxClient('YOUR_API_KEY_HERE')
220292
293+ Then, get the project object. If you don't have a project yet, you need to create one using the :obj:`create_project` method:
294+
295+ >>> project = client.create_project(name="Your project name",
296+ ... description="Your project description")
297+
298+ Otherwise, if you already have a project created on the platform, you just need to load it using the :obj:`load_project` method:
299+
300+ >>> project = client.load_project(name="Your project name")
301+
221302 **If your task type is tabular classification...**
222303
223304 Let's say your dataset looks like the following:
@@ -236,7 +317,7 @@ def add_model(
236317 >>> task_type = TaskType.TabularClassification
237318 >>> class_names = ['Retained', 'Churned']
238319 >>> feature_names = ['CreditScore', 'Geography', 'Balance']
239- >>> categorical_features_map = {'CreditScore': ['France', 'Germany', 'Spain']}
320+ >>> categorical_feature_names = ['Geography']
240321
241322 Now let's say you've trained a simple ``scikit-learn`` model on data that looks like the above.
242323
@@ -251,8 +332,8 @@ def add_model(
251332 The ``model`` arg must be the actual trained model object, and the ``input_features`` arg must be a 2D numpy array
252333 containing a batch of features that will be passed to the model as inputs.
253334
254- You can optionally include other kwargs in the function, including tokenizers, variables, encoders etc.
255- You simply pass those kwargs to the ``client .add_model`` function call when you upload the model.
335+ You can optionally include other kwargs in the function, including variables, encoders etc.
336+ You simply pass those kwargs to the ``project .add_model`` function call when you upload the model.
256337
257338 Here's an example of the ``predict_proba`` function in action:
258339
@@ -286,15 +367,16 @@ def add_model(
286367
287368 You can now upload this dataset to Unbox:
288369
289- >>> model = client.add_model(
290- ... name='Churn Classifier',
370+ >>> model = project.add_model(
371+ ... name='Linear classifiers',
372+ ... description='First iteration of vanilla logistic regression',
291373 ... task_type=task_type,
292374 ... function=predict_proba,
293375 ... model=sklearn_model,
294376 ... model_type=model_type,
295377 ... class_names=class_names,
296378 ... feature_names=feature_names,
297- ... categorical_features_map=categorical_features_map ,
379+ ... categorical_feature_names=categorical_feature_names ,
298380 ... train_sample_df=train_sample_df,
299381 ... train_sample_label_column_name=train_sample_label_column_name,
300382 ... )
@@ -332,7 +414,7 @@ def add_model(
332414 strings.
333415
334416 You can optionally include other kwargs in the function, including tokenizers, variables, encoders etc.
335- You simply pass those kwargs to the ``client .add_model`` function call when you upload the model.
417+ You simply pass those kwargs to the ``project .add_model`` function call when you upload the model.
336418
337419 Here's an example of the ``predict_proba`` function in action:
338420
@@ -363,15 +445,23 @@ def add_model(
363445
364446 You can now upload this dataset to Unbox:
365447
366- >>> model = client .add_model(
367- ... name='Churn Classifier ',
448+ >>> model = project .add_model(
449+ ... name='Linear classifiers ',
368450 ... task_type=task_type,
369451 ... function=predict_proba,
370452 ... model=sklearn_model,
371453 ... model_type=model_type,
372454 ... class_names=class_names,
373455 ... )
374456 >>> model.to_dict()
457+
458+ .. note::
459+ If inside the given project the ``add_model`` method is called with ``name='Linear classifiers'`` for the first time,
460+ a new model lineage will be created with ``Linear classifier`` as a name and ``description`` will be the first commit
461+ on that new tree. In the future, if you'd like to commit a new version to that same lineage, you can simply call `add_model`
462+ using ``name='Linear classifier'`` again and use ``description`` with the new commit message. Alternatively, if you'd like
463+ to start a new separate lineage inside that project, you can call the ``add_model`` method with a different ``name``, e.g.,
464+ ``name ='Nonlinear classifiers'``.
375465 """
376466 # ---------------------------- Schema validations ---------------------------- #
377467 if task_type not in [
@@ -651,8 +741,8 @@ def add_dataset(
651741 text_column_name : str, default None
652742 Column header in the csv containing the input text. Only applicable if your ``task_type`` is
653743 :obj:`TaskType.TextClassification`.
654- categorical_features_map : Dict[str, List[str]] , default {}
655- A dict containing a list of category names for each feature that is categorical. E.g. `{'Weather': ['Hot', 'Cold']} `.
744+ categorical_feature_names : List[str], default []
745+ A list containing the feature names for each feature that is categorical. E.g. `["Gender", "Geography"] `.
656746 Only applicable if your ``task_type`` is :obj:`TaskType.TabularClassification` or :obj:`TaskType.TabularRegression`.
657747 tag_column_name : str, default None
658748 Column header in the csv containing tags you want pre-populated in Unbox.
@@ -684,11 +774,23 @@ def add_dataset(
684774
685775 Examples
686776 --------
687- Instantiate the client:
777+ The datasets are uploaded directly into a **project** on the Unbox platform, using the ``project.add_dataset()`` method.
778+ Therefore, you need to get the project object to start uploading your datasets.
779+
780+ First, instantiate the client:
688781
689782 >>> import unboxapi
690783 >>> client = unboxapi.UnboxClient('YOUR_API_KEY_HERE')
691784
785+ Then, get the project object. If you don't have a project yet, you need to create one using the :obj:`create_project` method:
786+
787+ >>> project = client.create_project(name="Your project name",
788+ ... description="Your project description")
789+
790+ Otherwise, if you already have a project created on the platform, you just need to load it using the :obj:`load_project` method:
791+
792+ >>> project = client.load_project(name="Your project name")
793+
692794 **If your task type is tabular classification...**
693795
694796 Let's say your dataset looks like the following:
@@ -712,18 +814,18 @@ def add_dataset(
712814 >>> class_names = ['Retained', 'Churned']
713815 >>> feature_names = ['CreditScore', 'Geography', 'Balance']
714816 >>> label_column_name = 'Churned'
715- >>> categorical_features_map = {'CreditScore': ['France', 'Germany', 'Spain']}
817+ >>> categorical_feature_names = ['Geography']
716818
717819 You can now upload this dataset to Unbox:
718820
719- >>> dataset = client .add_dataset(
821+ >>> dataset = project .add_dataset(
720822 ... name='Churn Validation',
721823 ... task_type=task_type,
722824 ... file_path='/path/to/dataset.csv',
723825 ... class_names=class_names,
724826 ... label_column_name=label_column_name,
725827 ... feature_names=feature_names,
726- ... categorical_features_map=categorical_map ,
828+ ... categorical_feature_names=categorical_feature_names ,
727829 ... )
728830 >>> dataset.to_dict()
729831
@@ -749,7 +851,7 @@ def add_dataset(
749851
750852 You can now upload this dataset to Unbox:
751853
752- >>> dataset = client .add_dataset(
854+ >>> dataset = project .add_dataset(
753855 ... name='Churn Validation',
754856 ... task_type=task_type,
755857 ... file_path='/path/to/dataset.csv',
@@ -933,8 +1035,8 @@ def add_dataframe(
9331035 text_column_name : str, default None
9341036 Column header in the csv containing the input text. Only applicable if your ``task_type`` is
9351037 :obj:`TaskType.TextClassification`.
936- categorical_features_map : Dict[str, List[str]] , default {}
937- A dict containing a list of category names for each feature that is categorical. E.g. `{'Weather': ['Hot', 'Cold']} `.
1038+ categorical_feature_names : List[str], default []
1039+ A list containing the feature names for each feature that is categorical. E.g. `["Gender", "Geography"] `.
9381040 Only applicable if your ``task_type`` is :obj:`TaskType.TabularClassification` or :obj:`TaskType.TabularRegression`.
9391041 description : str, default None
9401042 Commit message for this version.
@@ -964,11 +1066,23 @@ def add_dataframe(
9641066
9651067 Examples
9661068 --------
967- Instantiate the client
1069+ The dataframes are uploaded directly into a **project** on the Unbox platform, using the ``project.add_dataframe()`` method.
1070+ Therefore, you need to get the project object to start uploading your dataframes.
1071+
1072+ First, instantiate the client:
9681073
9691074 >>> import unboxapi
9701075 >>> client = unboxapi.UnboxClient('YOUR_API_KEY_HERE')
9711076
1077+ Then, get the project object. If you don't have a project yet, you need to create one using the :obj:`create_project` method:
1078+
1079+ >>> project = client.create_project(name="Your project name",
1080+ ... description="Your project description")
1081+
1082+ Otherwise, if you already have a project created on the platform, you just need to load it using the :obj:`load_project` method:
1083+
1084+ >>> project = client.load_project(name="Your project name")
1085+
9721086 **If your task type is tabular classification...**
9731087
9741088 Let's say your dataframe looks like the following:
@@ -991,18 +1105,18 @@ def add_dataframe(
9911105 >>> class_names = ['Retained', 'Churned']
9921106 >>> feature_names = ['CreditScore', 'Geography', 'Balance']
9931107 >>> label_column_name = 'Churned'
994- >>> categorical_features_map = {'CreditScore': ['France', 'Germany', 'Spain']}
1108+ >>> categorical_feature_names = ['Geography']
9951109
9961110 You can now upload this dataset to Unbox:
9971111
998- >>> dataset = client .add_dataset(
1112+ >>> dataset = project .add_dataset(
9991113 ... name='Churn Validation',
10001114 ... task_type=task_type,
10011115 ... df=df,
10021116 ... class_names=class_names,
10031117 ... feature_names=feature_names,
10041118 ... label_column_name=label_column_name,
1005- ... categorical_features_map=categorical_map ,
1119+ ... categorical_feature_names=categorical_feature_names ,
10061120 ... )
10071121 >>> dataset.to_dict()
10081122
@@ -1027,7 +1141,7 @@ def add_dataframe(
10271141
10281142 You can now upload this dataset to Unbox:
10291143
1030- >>> dataset = client .add_dataset(
1144+ >>> dataset = project .add_dataset(
10311145 ... name='Churn Validation',
10321146 ... task_type=task_type,
10331147 ... df=df,
0 commit comments