cjapy 0.2.3.post1__tar.gz → 0.2.3.post3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/PKG-INFO +1 -1
  2. cjapy-0.2.3.post3/cjapy/__version__.py +1 -0
  3. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy/cjapy.py +261 -3
  4. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy/connector.py +2 -3
  5. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy/requestCreator.py +59 -15
  6. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy.egg-info/PKG-INFO +1 -1
  7. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/docs/cja.md +39 -0
  8. cjapy-0.2.3.post1/cjapy/__version__.py +0 -1
  9. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/LICENSE +0 -0
  10. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/README.md +0 -0
  11. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy/__init__.py +0 -0
  12. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy/config.py +0 -0
  13. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy/configs.py +0 -0
  14. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy/projects.py +0 -0
  15. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy/token_provider.py +0 -0
  16. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy/workspace.py +0 -0
  17. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy.egg-info/SOURCES.txt +0 -0
  18. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy.egg-info/dependency_links.txt +0 -0
  19. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy.egg-info/requires.txt +0 -0
  20. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/cjapy.egg-info/top_level.txt +0 -0
  21. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/docs/authenticating_without_config_json.md +0 -0
  22. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/docs/getting_started.md +0 -0
  23. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/docs/logging.md +0 -0
  24. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/docs/main.md +0 -0
  25. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/docs/projects.md +0 -0
  26. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/docs/releases.md +0 -0
  27. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/docs/requestCreator.md +0 -0
  28. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/docs/workspace.md +0 -0
  29. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/pyproject.toml +0 -0
  30. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/requirements.txt +0 -0
  31. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/setup.cfg +0 -0
  32. {cjapy-0.2.3.post1 → cjapy-0.2.3.post3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cjapy
3
- Version: 0.2.3.post1
3
+ Version: 0.2.3.post3
4
4
  Summary: Adobe Customer Journey Analytics (CJA) wrapper
5
5
  Home-page: https://github.com/pitchmuc/cjapy
6
6
  Author: Julien Piccini
@@ -0,0 +1 @@
1
+ __version__ = "0.2.3-3"
@@ -8,7 +8,7 @@ from collections import defaultdict, deque
8
8
  import time, logging, re
9
9
  from itertools import tee
10
10
  from datetime import datetime, timedelta
11
-
11
+ import string
12
12
 
13
13
  # Non standard libraries
14
14
  import pandas as pd
@@ -2460,13 +2460,13 @@ class CJA:
2460
2460
  def getFreeformTable(
2461
2461
  self,
2462
2462
  dimension: str = None,
2463
- metrics: List[str] = None,
2463
+ metrics: Union[str] = None,
2464
2464
  dataviewId: str = None,
2465
2465
  start_date: Union[str, datetime] = None,
2466
2466
  end_date: Union[str, datetime] = None,
2467
2467
  top_n: int = 400,
2468
2468
  filterId: str = None,
2469
- search: Union[str, List[str]] = None,
2469
+ search: Union[str, list] = None,
2470
2470
  search_operator: str = "OR",
2471
2471
  ) -> pd.DataFrame:
2472
2472
  """
@@ -2560,3 +2560,261 @@ class CJA:
2560
2560
 
2561
2561
  df.columns = [clean_column_name(col) for col in df.columns]
2562
2562
  return df
2563
+
2564
+ def getPersonProfiles(
2565
+ self,
2566
+ dataviewId: str = None,
2567
+ personId: str = "variables/adobe_identitynamespace_personid",
2568
+ featureMetrics: list = None,
2569
+ targetMetric: str = None,
2570
+ binaryTargetMetric: bool = False,
2571
+ startDate: Union[str, datetime] = None,
2572
+ endDate: Union[str, datetime] = None,
2573
+ sampleSize: int = 50000,
2574
+ sampleSeed: int = 0,
2575
+ fullPersonHistoryOnly: bool = False,
2576
+ removeSingleEventPeople: bool = False,
2577
+ filterId: str = None
2578
+ ) -> pd.DataFrame:
2579
+ """
2580
+ Retrieves a dataset where every row is a person profile.
2581
+
2582
+ Arguments:
2583
+ dataviewId : REQUIRED : The dataView ID to use for your report.
2584
+ personId : OPTIONAL : The dimension to use as your person ID. Defaults to adobe_identitynamespace_personid.
2585
+ featureMetrics : REQUIRED : List of metrics to include in the customer profiles.
2586
+ targetMetric : OPTIONAL : A target metric for supervised learning algorithms.
2587
+ TODO: featureDimensions (only supported when "flat view" is supported)
2588
+ binaryTargetMetric : OPTIONAL: Sets the target metric to 1 if the metric sum for a person is > 0 otherwise sets it to 0
2589
+ startDate : OPTIONAL : The start date for the report in 'YYYY-MM-DD' format or datetime object (defaults to 90 days ago).
2590
+ endDate : OPTIONAL : The end date for the report in 'YYYY-MM-DD' format or datetime object (defaults to today).
2591
+ sampleSize : OPTIONAL : Number of sampled person profiles to return (default 50000). All person profiles are returned if sample is greater than the total population.
2592
+ sampleSeed: OPTIONAL : A seed value for the random sampling of person profiles (default 0).
2593
+ fullPersonHistoryOnly : OPTIONAL : Filters the sample to only people whose entire history is present in the date range. Defaults to false.
2594
+ removeSingleEventPeople : OPTIONAL : Removes people that had only a single event in the date range.
2595
+ filterId : OPTIONAL : The segment ID to filter the report with.
2596
+
2597
+ Returns:
2598
+ A pandas DataFrame containing the person profile data.
2599
+ """
2600
+
2601
+ if featureMetrics is None:
2602
+ raise ValueError("Require at least one feature metric")
2603
+ if dataviewId is None:
2604
+ raise ValueError("Require a Data View ID")
2605
+ def ensure_dimension_prefix(dimension: str) -> str:
2606
+ if not dimension.startswith("variables/"):
2607
+ return f"variables/{dimension}"
2608
+ return dimension
2609
+ def ensure_metric_prefix(metric: str) -> str:
2610
+ if not metric.startswith("metrics/"):
2611
+ return f"metrics/{metric}"
2612
+ return metric
2613
+ def ensure_datetime_format(date: Union[str, datetime], is_start: bool) -> str:
2614
+ if isinstance(date, str):
2615
+ date = datetime.fromisoformat(date)
2616
+ if date.time() == datetime.min.time():
2617
+ if is_start:
2618
+ return date.strftime('%Y-%m-%dT00:00:00.000')
2619
+ else:
2620
+ return date.strftime('%Y-%m-%dT23:59:59.999')
2621
+ return date.strftime('%Y-%m-%dT%H:%M:%S.000')
2622
+ if startDate is None:
2623
+ startDate = datetime.today() - timedelta(days=90)
2624
+ if endDate is None:
2625
+ endDate = datetime.today()
2626
+ start_date_str = ensure_datetime_format(startDate, is_start=True)
2627
+ end_date_str = ensure_datetime_format(endDate, is_start=False)
2628
+ date_range = f"{start_date_str}/{end_date_str}"
2629
+ personId = ensure_dimension_prefix(personId)
2630
+ metrics = [ensure_metric_prefix(metric) for metric in featureMetrics]
2631
+ targetMetric = ensure_metric_prefix(targetMetric)
2632
+
2633
+ dataRequest = RequestCreator()
2634
+ dataRequest.setDataViewId(dataviewId)
2635
+
2636
+ sampling_metric_definition = {
2637
+ "func": "calc-metric",
2638
+ "formula": {
2639
+ "func": "add",
2640
+ "col1": {
2641
+ "func": "modulo",
2642
+ "description": "Modulo",
2643
+ "col1": {
2644
+ "func": "add",
2645
+ "col1": {
2646
+ "func": "multiply",
2647
+ "col1": {
2648
+ "func": "visualization-group",
2649
+ "col": {
2650
+ "func": "add",
2651
+ "col1": {
2652
+ "func": "cumul",
2653
+ "description": "Cumulative",
2654
+ "n": 0,
2655
+ "col": 1
2656
+ },
2657
+ "col2": sampleSeed
2658
+ }
2659
+ },
2660
+ "col2": 1664525
2661
+ },
2662
+ "col2": 1013904223
2663
+ },
2664
+ "col2": {
2665
+ "func": "pow",
2666
+ "description": "Power operator",
2667
+ "col1": 2,
2668
+ "col2": 32
2669
+ }
2670
+ },
2671
+ "col2": {
2672
+ "func": "visualization-group",
2673
+ "col": {
2674
+ "func": "multiply",
2675
+ "col1": {
2676
+ "func": "metric",
2677
+ "name": "metrics/occurrences",
2678
+ "description": "Events"
2679
+ },
2680
+ "col2": 0
2681
+ }
2682
+ }
2683
+ },
2684
+ "version": [
2685
+ 1,
2686
+ 0,
2687
+ 0
2688
+ ]
2689
+ }
2690
+
2691
+ dataRequest.addMetric(metricDefinition=sampling_metric_definition)
2692
+
2693
+ for metric in metrics:
2694
+ dataRequest.addMetric(metric)
2695
+
2696
+ if binaryTargetMetric:
2697
+ binary_metric_definition = {
2698
+ "func": "calc-metric",
2699
+ "formula": {
2700
+ "func": "if",
2701
+ "description": "If",
2702
+ "cond": {
2703
+ "func": "gt",
2704
+ "description": "Greater Than",
2705
+ "col1": {
2706
+ "func": "metric",
2707
+ "name": f"{targetMetric}",
2708
+ "description": "Binary Target Metric"
2709
+ },
2710
+ "col2": 0
2711
+ },
2712
+ "then": 1,
2713
+ "else": 0
2714
+ },
2715
+ "version": [
2716
+ 1,
2717
+ 0,
2718
+ 0
2719
+ ]
2720
+ }
2721
+ dataRequest.addMetric(metricDefinition=binary_metric_definition)
2722
+ else:
2723
+ dataRequest.addMetric(targetMetric)
2724
+
2725
+ dataRequest.setDimension(personId)
2726
+ dataRequest.setNoneBehavior(returnNones=False)
2727
+
2728
+ if filterId:
2729
+ dataRequest.addGlobalFilter(filterId)
2730
+ dataRequest.addGlobalFilter(date_range)
2731
+
2732
+ if fullPersonHistoryOnly:
2733
+ fullHistoryFilter = {
2734
+ "container": {
2735
+ "func": "container",
2736
+ "context": "visitors",
2737
+ "pred": {
2738
+ "func": "eq",
2739
+ "num": 1,
2740
+ "val": {
2741
+ "func": "attr",
2742
+ "name": "variables/adobe_firstvreturn_sessiontype"
2743
+ },
2744
+ "description": "Session Type"
2745
+ }
2746
+ },
2747
+ "func": "segment",
2748
+ "version": [
2749
+ 1,
2750
+ 0,
2751
+ 0
2752
+ ]
2753
+ }
2754
+ dataRequest.addGlobalFilter(adHocFilter=fullHistoryFilter)
2755
+
2756
+ if removeSingleEventPeople:
2757
+ excludeSingleEventPeopleFilter = {
2758
+ "container": {
2759
+ "func": "container",
2760
+ "context": "visitors",
2761
+ "pred": {
2762
+ "func": "without",
2763
+ "pred": {
2764
+ "func": "eq",
2765
+ "num": 1,
2766
+ "val": {
2767
+ "func": "total",
2768
+ "evt": {
2769
+ "func": "event",
2770
+ "name": "metrics/occurrences"
2771
+ }
2772
+ },
2773
+ "description": "Events"
2774
+ }
2775
+ }
2776
+ },
2777
+ "func": "segment",
2778
+ "version": [
2779
+ 1,
2780
+ 0,
2781
+ 0
2782
+ ]
2783
+ }
2784
+ dataRequest.addGlobalFilter(adHocFilter=excludeSingleEventPeopleFilter)
2785
+
2786
+ response = self.getReport(request=dataRequest, n_results=sampleSize)
2787
+
2788
+ df = response.dataframe
2789
+
2790
+ # Drop the itemId column if it exists
2791
+ if 'itemId' in df.columns:
2792
+ df = df.drop(columns=['itemId'])
2793
+
2794
+ # Drop the sampling metric
2795
+ if 'ad_hoc_cm_0' in df.columns:
2796
+ df = df.drop(columns=['ad_hoc_cm_0'])
2797
+
2798
+ # Remove any rows that exceed the requested top_n
2799
+ if len(df) > sampleSize:
2800
+ df = df.head(sampleSize)
2801
+
2802
+ # Clean the column names to remove prefixes
2803
+ def clean_column_name(col):
2804
+ if col.startswith("variables/"):
2805
+ return col.replace("variables/", "")
2806
+ elif col.startswith("metrics/"):
2807
+ return col.replace("metrics/", "")
2808
+ return col
2809
+
2810
+ df.columns = [clean_column_name(col) for col in df.columns]
2811
+
2812
+ # Rename the last column if binaryTargetMetric is True and targetMetric is provided
2813
+ if binaryTargetMetric and targetMetric:
2814
+ # Ensure the last column is renamed
2815
+ df.columns.values[-1] = f"{clean_column_name(targetMetric)}_binary"
2816
+
2817
+ # Randomize the rows
2818
+ df_randomized = df.sample(frac=1).reset_index(drop=True)
2819
+
2820
+ return df_randomized
@@ -46,13 +46,13 @@ class AdobeRequest:
46
46
  self.logger = logger
47
47
  self.restTime = 30
48
48
  self.retry = retry
49
+ self.connectionType = 'oauthV2'
49
50
  if self.config["token"] == "" or time.time() > self.config["date_limit"]:
50
51
  if self.config["private_key"] is not None or self.config["pathToKey"] is not None:
51
52
  self.connectionType = 'jwt'
52
53
  token_and_expiry = token_provider.get_jwt_token_and_expiry_for_config(
53
54
  config=self.config, verbose=verbose
54
55
  )
55
-
56
56
  elif self.config["scopes"] is not None:
57
57
  self.connectionType = 'oauthV2'
58
58
  token_and_expiry = token_provider.get_oauth_token_and_expiry_for_config(
@@ -81,8 +81,7 @@ class AdobeRequest:
81
81
  config=self.config)
82
82
  elif self.connectionType == 'oauthV2':
83
83
  token_with_expiry = token_provider.get_oauth_token_and_expiry_for_config(
84
- config=self.config,
85
- connectionType=self.connectionType)
84
+ config=self.config)
86
85
  token = token_with_expiry["token"]
87
86
  expiry = token_with_expiry["expiry"]
88
87
  if self.loggingEnabled:
@@ -103,6 +103,7 @@ class RequestCreator:
103
103
  def addMetric(
104
104
  self,
105
105
  metricId: str = None,
106
+ metricDefinition: dict = None,
106
107
  attributionModel: str = None,
107
108
  lookbackWindow: Union[int, str] = 30,
108
109
  lookbackGranularity: str = "day",
@@ -111,14 +112,25 @@ class RequestCreator:
111
112
  """
112
113
  Add a metric to the template.
113
114
  Arguments:
114
- metricId : REQUIRED : The metric to add
115
- attributionModel : OPTIONAL : The attribution model to use (e.g., "lastTouch", "firstTouch", "linear", "participation", "sameTouch", "uShaped", "jShaped", "reverseJShaped", "timeDecay", "positionBased", "algorithmic")
116
- lookbackWindow : OPTIONAL : The lookback window (number of minutes, hours, days, weeks, months, quarters, "session", or "person"). Assumes 30 if not specified.
117
- lookbackGranularity : OPTIONAL : The granularity of the lookback window (minute, hour, day, week, month, quarter). Defaults to "day".
118
- **kwargs : Additional model-specific parameters. For "timeDecay" (assumes 1 week): halfLifeNumPeriods, halfLifeGranularity, for "positionBased": firstWeight, middleWeight, lastWeight.
119
- """
120
- if metricId is None:
121
- raise ValueError("Require a metric ID")
115
+ metricId : OPTIONAL : The metric to add (or the calculated metric ID)
116
+ metricDefinition : OPTIONAL : The definition of an ad-hoc calculated metric
117
+ attributionModel : OPTIONAL : The attribution model to use (e.g., "lastTouch", "firstTouch", "linear", etc.)
118
+ lookbackWindow : OPTIONAL : The lookback window (e.g., number of minutes, hours, days, weeks, etc.)
119
+ lookbackGranularity : OPTIONAL : The granularity of the lookback window (minute, hour, day, week, etc.). Defaults to "day".
120
+ **kwargs : Additional model-specific parameters (e.g., half-life for "timeDecay", weights for "positionBased").
121
+ """
122
+ if not metricId and not metricDefinition:
123
+ raise ValueError("You must supply either a metricId or a metricDefinition.")
124
+
125
+ if metricId and metricDefinition:
126
+ raise ValueError("You cannot supply both a metricId and a metricDefinition.")
127
+
128
+ # Check if the metricId is a calculated metric (starts with "cm" and contains "@AdobeOrg")
129
+ is_calculated_metric = metricId and metricId.startswith("cm") and "@AdobeOrg" in metricId
130
+
131
+ # Check if attribution model is provided for a calculated metric
132
+ if (is_calculated_metric or metricDefinition is not None) and attributionModel:
133
+ raise ValueError("Attribution is not supported on calculated metrics.")
122
134
 
123
135
  if attributionModel and attributionModel not in ["lastTouch", "firstTouch", "linear", "participation", "sameTouch", "uShaped", "jShaped", "reverseJShaped", "timeDecay", "positionBased", "algorithmic"]:
124
136
  raise ValueError("Invalid attribution model")
@@ -127,9 +139,19 @@ class RequestCreator:
127
139
  raise ValueError("Invalid lookbackGranularity. Valid values are: 'minute', 'hour', 'day', 'week', 'month', 'quarter'")
128
140
 
129
141
  columnId = self.__metricCount
130
- addMetric = {"columnId": str(columnId), "id": metricId}
131
- if columnId == 0:
132
- addMetric["sort"] = "desc"
142
+ metric = {"columnId": str(columnId)}
143
+
144
+ if metricId:
145
+ metric["id"] = metricId
146
+ elif metricDefinition:
147
+ if not isinstance(metricDefinition, dict):
148
+ raise ValueError("metricDefinition must be a dictionary")
149
+ metric["id"] = f"ad_hoc_cm_{str(columnId)}"
150
+ metric["metricDefinition"] = metricDefinition
151
+
152
+ # Only add sorting to the first metric if no dimension sort is specified
153
+ if columnId == 0 and "dimensionSort" not in self.__request["settings"]:
154
+ metric["sort"] = "desc"
133
155
 
134
156
  if attributionModel:
135
157
  # Handle sameTouch separately
@@ -170,7 +192,7 @@ class RequestCreator:
170
192
  "numPeriods": lookbackWindow
171
193
  }
172
194
 
173
- addMetric["lookback"] = {
195
+ metric["lookback"] = {
174
196
  "func": "min-months",
175
197
  "granularity": lookbackGranularity,
176
198
  "numPeriods": lookbackWindow
@@ -222,9 +244,9 @@ class RequestCreator:
222
244
  allocationModel["middleWeight"] = middleWeight
223
245
  allocationModel["lastWeight"] = lastWeight
224
246
 
225
- addMetric["allocationModel"] = allocationModel
247
+ metric["allocationModel"] = allocationModel
226
248
 
227
- self.__request["metricContainer"]["metrics"].append(addMetric)
249
+ self.__request["metricContainer"]["metrics"].append(metric)
228
250
  self.__metricCount += 1
229
251
 
230
252
  def getMetrics(self) -> list:
@@ -414,17 +436,39 @@ class RequestCreator:
414
436
  else:
415
437
  self.__request["settings"]["nonesBehavior"] = "exclude-nones"
416
438
 
417
- def setDimension(self, dimension: str = None) -> None:
439
+ def setDimensionSort(self, order: str = "dsc") -> None:
440
+ """
441
+ Set sorting based on a dimension value.
442
+ Arguments:
443
+ order : OPTIONAL : The sort order, either "asc" or "dsc" (default is "dsc").
444
+ """
445
+ if order not in ["asc", "dsc"]:
446
+ raise ValueError("Sort order must be 'asc' or 'dsc'")
447
+
448
+ self.__request["settings"]["dimensionSort"] = order
449
+
450
+ # Remove sort from all metrics if dimension sort is set
451
+ for metric in self.__request["metricContainer"]["metrics"]:
452
+ if "sort" in metric:
453
+ del metric["sort"]
454
+
455
+ def setDimension(self, dimension: str = None, sort_order: str = None) -> None:
418
456
  """
419
457
  Set the dimension to be used for reporting.
420
458
  Arguments:
421
459
  dimension : REQUIRED : the dimension to build your report on
460
+ sort_order : OPTIONAL : The sort order, either "asc" or "desc".
422
461
  """
423
462
  if dimension is None:
424
463
  raise ValueError("A dimension must be passed")
464
+
425
465
  if 'dimensions' in self.__request.keys():
426
466
  del self.__request["dimensions"]
467
+
427
468
  self.__request["dimension"] = dimension
469
+
470
+ if sort_order:
471
+ self.setDimensionSort(sort_order)
428
472
 
429
473
  def setIdentityOverrides(self, identity_overrides: list) -> None:
430
474
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cjapy
3
- Version: 0.2.3.post1
3
+ Version: 0.2.3.post3
4
4
  Summary: Adobe Customer Journey Analytics (CJA) wrapper
5
5
  Home-page: https://github.com/pitchmuc/cjapy
6
6
  Author: Julien Piccini
@@ -601,4 +601,43 @@ The following arguments are possible with this method:
601
601
  * countRepeatInstances : OPTIONAL : set to count repeatInstances values (or not). True by default.
602
602
  * returnNones : OPTIONAL : Set the behavior of the None values in that request. (True by default)
603
603
 
604
+
605
+ ## getPersonProfiles
606
+
607
+ The `getPersonProfiles` method retrieves a dataset where each row represents a person profile. This is particularly useful for extracting feature metrics and target metrics for supervised learning applications or customer segmentation analysis.
608
+
609
+ ### Arguments:
610
+ - `dataviewId`: **REQUIRED**. The Data View ID to use for your report.
611
+ - `personId`: **OPTIONAL**. The dimension to use as your person ID. Defaults to `variables/adobe_identitynamespace_personid`.
612
+ - `featureMetrics`: **REQUIRED**. A list of metrics to include in the customer profiles.
613
+ - `targetMetric`: **OPTIONAL**. A target metric for supervised learning algorithms.
614
+ - `binaryTargetMetric`: **OPTIONAL**. If set to `True`, sets the target metric to 1 if the metric sum for a person is greater than 0, otherwise sets it to 0.
615
+ - `startDate`: **OPTIONAL**. The start date for the report in 'YYYY-MM-DD' format or as a datetime object. Defaults to 90 days ago.
616
+ - `endDate`: **OPTIONAL**. The end date for the report in 'YYYY-MM-DD' format or as a datetime object. Defaults to today.
617
+ - `sampleSize`: **OPTIONAL**. The number of sampled person profiles to return. Defaults to 50,000. If the sample size exceeds the total population, all profiles are returned.
618
+ - `sampleSeed`: **OPTIONAL**. A seed value for random sampling of person profiles. Defaults to 0.
619
+ - `fullPersonHistoryOnly`: **OPTIONAL**. If set to `True`, filters the sample to only people whose entire history is present in the date range. Defaults to `False`.
620
+ - `removeSingleEventPeople`: **OPTIONAL**. If set to `True`, removes people that had only a single event in the date range.
621
+ - `filterId`: **OPTIONAL**. The segment ID to filter the report with.
622
+
623
+ ### Returns:
624
+ A `pandas.DataFrame` containing the person profile data.
625
+
626
+ ### Example usage:
627
+
628
+ ```python
629
+ # Assuming `cja` is an instance of the CJA class
630
+ feature_metrics = ["metric1", "metric2", "metric3"]
631
+ df_profiles = cja.getPersonProfiles(
632
+ dataviewId="your_data_view_id",
633
+ featureMetrics=feature_metrics,
634
+ targetMetric="target_metric",
635
+ startDate="2023-01-01",
636
+ endDate="2023-03-31",
637
+ sampleSize=10000,
638
+ binaryTargetMetric=True
639
+ )
640
+ print(df_profiles.head())
641
+ ```
642
+
604
643
  [Back to README](../README.md)
@@ -1 +0,0 @@
1
- __version__ = "0.2.3-1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes