Skip to content

Commit bfc80a2

Browse files
docs: In bigtable fraud demo, change "demographics" wording (#7336)
* docs: In bigtable fraud demo, change "demographics" to be "customer profiles" * fix cf name * Fix table formatting
1 parent 9fdc1bb commit bfc80a2

File tree

9 files changed

+208
-120
lines changed

9 files changed

+208
-120
lines changed

bigtable/use-cases/fraudDetection/README.md

Lines changed: 170 additions & 82 deletions
Large diffs are not rendered by default.

bigtable/use-cases/fraudDetection/src/main/java/bigtable/fraud/beam/FraudDetection.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package bigtable.fraud.beam;
1717

1818
import bigtable.fraud.beam.utils.AggregatedData;
19-
import bigtable.fraud.beam.utils.CustomerDemographics;
19+
import bigtable.fraud.beam.utils.CustomerProfile;
2020
import bigtable.fraud.beam.utils.RowDetails;
2121
import bigtable.fraud.beam.utils.TransactionDetails;
2222
import bigtable.fraud.beam.utils.WriteCBTHelper;
@@ -127,12 +127,12 @@ public void processElement(
127127
Preconditions.checkArgument(new String(row.getRow()).equals(
128128
transactionDetails.getCustomerID()));
129129

130-
CustomerDemographics customerDemographics = new CustomerDemographics(
130+
CustomerProfile customerProfile = new CustomerProfile(
131131
row);
132132

133133
// Generate an AggregatedData object.
134134
AggregatedData aggregatedData =
135-
new AggregatedData(customerDemographics, transactionDetails, row);
135+
new AggregatedData(customerProfile, transactionDetails, row);
136136

137137
c.output(aggregatedData);
138138
} catch (Exception e) {

bigtable/use-cases/fraudDetection/src/main/java/bigtable/fraud/beam/LoadDataset.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package bigtable.fraud.beam;
1717

18-
import bigtable.fraud.beam.utils.CustomerDemographics;
18+
import bigtable.fraud.beam.utils.CustomerProfile;
1919
import bigtable.fraud.beam.utils.TransactionDetails;
2020
import bigtable.fraud.beam.utils.RowDetails;
2121
import bigtable.fraud.beam.utils.WriteCBTHelper;
@@ -29,7 +29,7 @@
2929
import org.apache.beam.sdk.transforms.ParDo;
3030
import org.apache.beam.sdk.values.TypeDescriptor;
3131

32-
// Load customer demographics and history into Cloud Bigtable.
32+
// Load customer profiles and history into Cloud Bigtable.
3333
public final class LoadDataset {
3434

3535
/**
@@ -46,7 +46,7 @@ public static void main(final String[] args) throws
4646
LoadDatasetOptions options =
4747
PipelineOptionsFactory.fromArgs(args).withValidation()
4848
.as(LoadDatasetOptions.class);
49-
options.setJobName("load-customer-demographics-" + options.getRandomUUID());
49+
options.setJobName("load-customer-profiles-" + options.getRandomUUID());
5050

5151
CloudBigtableTableConfiguration config =
5252
new CloudBigtableTableConfiguration.Builder()
@@ -55,21 +55,21 @@ public static void main(final String[] args) throws
5555
.withTableId(options.getCBTTableId())
5656
.build();
5757

58-
// Create a pipeline that reads the GCS demographics csv file
58+
// Create a pipeline that reads the GCS customer profile csv file
5959
// and write it into CBT.
60-
Pipeline pDemographics = Pipeline.create(options);
61-
pDemographics
60+
Pipeline pProfiles = Pipeline.create(options);
61+
pProfiles
6262
.apply("ReadGCSFile",
63-
TextIO.read().from(options.getDemographicsInputFile()))
63+
TextIO.read().from(options.getCustomerProfileInputFile()))
6464
.apply(
6565
MapElements.into(TypeDescriptor.of(RowDetails.class))
66-
.via(CustomerDemographics::new))
66+
.via(CustomerProfile::new))
6767
.apply("TransformParsingsToBigtable",
6868
ParDo.of(WriteCBTHelper.MUTATION_TRANSFORM))
6969
.apply(
7070
"WriteToBigtable",
7171
CloudBigtableIO.writeToTable(config));
72-
PipelineResult pDemographicsRun = pDemographics.run();
72+
PipelineResult pProfilesRun = pProfiles.run();
7373

7474
// Create a pipeline that reads the GCS history csv file and write
7575
// it into CBT
@@ -89,7 +89,7 @@ public static void main(final String[] args) throws
8989
CloudBigtableIO.writeToTable(config));
9090
PipelineResult pHistoryRun = pHistory.run();
9191

92-
pDemographicsRun.waitUntilFinish();
92+
pProfilesRun.waitUntilFinish();
9393
pHistoryRun.waitUntilFinish();
9494
}
9595
}

bigtable/use-cases/fraudDetection/src/main/java/bigtable/fraud/beam/LoadDatasetOptions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public interface LoadDatasetOptions extends DataflowPipelineOptions {
5858
void setCBTTableId(String tableID);
5959

6060
/**
61-
* @return customer demographics input file.
61+
* @return customer profile input file.
6262
*/
63-
@Description("The Cloud Storage path to the demographics CSV file.")
64-
String getDemographicsInputFile();
63+
@Description("The Cloud Storage path to the profile CSV file.")
64+
String getCustomerProfileInputFile();
6565

6666
/**
67-
* @param location customer demographics file location.
67+
* @param location customer profile file location.
6868
*/
69-
void setDemographicsInputFile(String location);
69+
void setCustomerProfileInputFile(String location);
7070

7171
/**
7272
* @return transactions history input file.

bigtable/use-cases/fraudDetection/src/main/java/bigtable/fraud/beam/utils/AggregatedData.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public final class AggregatedData {
2828
*/
2929
private TransactionDetails transactionDetails;
3030
/**
31-
* Stores the incoming transaction customer demographics.
31+
* Stores the incoming transaction customer profile.
3232
*/
33-
private CustomerDemographics customerDemographics;
33+
private CustomerProfile customerProfile;
3434
/**
3535
* Stores the time difference between this transaction and the last one in
3636
* minutes.
@@ -58,14 +58,14 @@ public final class AggregatedData {
5858
/**
5959
* Construct an AggregatedData object.
6060
*
61-
* @param iCustomerDemographics the incoming customer demographic object.
61+
* @param iCustomerProfile the incoming customer profile object.
6262
* @param iTransactionDetails the incoming transaction details object.
6363
* @param row a result row read from Cloud Bigtable.
6464
*/
6565
public AggregatedData(
66-
final CustomerDemographics iCustomerDemographics,
66+
final CustomerProfile iCustomerProfile,
6767
final TransactionDetails iTransactionDetails, final Result row) {
68-
this.customerDemographics = iCustomerDemographics;
68+
this.customerProfile = iCustomerProfile;
6969
this.transactionDetails = iTransactionDetails;
7070

7171
// Get last transaction.
@@ -162,8 +162,8 @@ public String getMLFeatures() {
162162
mlFeatures.add(String.valueOf(avgAmountSpentLastWeek));
163163
mlFeatures.add(String.valueOf(avgAmountSpentLastMonth));
164164
mlFeatures.add(String.valueOf(numOfTransactionLastDay));
165-
mlFeatures.add(String.valueOf(customerDemographics.getId()));
166-
mlFeatures.add(customerDemographics.getCcNumber());
165+
mlFeatures.add(String.valueOf(customerProfile.getId()));
166+
mlFeatures.add(customerProfile.getCcNumber());
167167
mlFeatures.add(String.valueOf(transactionDetails.getTransactionAmount()));
168168
mlFeatures.add(String.valueOf(transactionDetails.getMerchantID()));
169169

bigtable/use-cases/fraudDetection/src/main/java/bigtable/fraud/beam/utils/CustomerDemographics.java renamed to bigtable/use-cases/fraudDetection/src/main/java/bigtable/fraud/beam/utils/CustomerProfile.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.apache.hadoop.hbase.client.Result;
2121

2222
@DefaultCoder(AvroCoder.class)
23-
public final class CustomerDemographics extends RowDetails {
23+
public final class CustomerProfile extends RowDetails {
2424

2525
/**
2626
* The incoming request's customer id.
@@ -48,20 +48,20 @@ public final class CustomerDemographics extends RowDetails {
4848
private String accountNumber;
4949

5050
/**
51-
* Constructs CustomerDemographics object.
51+
* Constructs CustomerProfile object.
5252
*
53-
* @param line a CustomerDemographics comma-seperated line
53+
* @param line a CustomerProfile comma-seperated line
5454
*/
55-
public CustomerDemographics(final String line) {
55+
public CustomerProfile(final String line) {
5656
super(line);
5757
}
5858

5959
/**
60-
* Constructs CustomerDemographics object.
60+
* Constructs CustomerProfile object.
6161
*
6262
* @param row a row result read from Cloud Bigtable.
6363
*/
64-
public CustomerDemographics(final Result row) {
64+
public CustomerProfile(final Result row) {
6565
super(row);
6666
}
6767

@@ -81,6 +81,6 @@ public String getCcNumber() {
8181

8282
@Override
8383
public String getColFamily() {
84-
return "demographics";
84+
return "customer_profile";
8585
}
8686
}

bigtable/use-cases/fraudDetection/src/main/java/bigtable/fraud/beam/utils/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
/**
18-
* Classes that will hold customer demographics, transactions history, and
18+
* Classes that will hold customer profiles, transactions history, and
1919
* aggregated data to be sent to the machine learning model.
2020
*/
2121
package bigtable.fraud.beam.utils;

bigtable/use-cases/fraudDetection/terraform/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "google_bigtable_table" "tf-fd-table" {
3636
name = "customer-information-${random_string.uuid.result}"
3737
instance_name = google_bigtable_instance.tf-fd-instance.name
3838
column_family {
39-
family = "demographics"
39+
family = "customer_profile"
4040
}
4141
column_family {
4242
family = "history"
@@ -116,7 +116,7 @@ resource "google_storage_bucket_object" "legit_transactions" {
116116
bucket = google_storage_bucket.tf-fd-bucket.name
117117
}
118118

119-
# A CSV file that contains customers' demographics.
119+
# A CSV file that contains customers' profiles.
120120
resource "google_storage_bucket_object" "customers" {
121121
name = "training_dataset/customers.csv"
122122
source = "./datasets/training_data/customers.csv"
@@ -170,7 +170,7 @@ module "dataflow_pipeline" {
170170
destroy_cmd_body = "${var.region} ${random_string.uuid.result}"
171171
}
172172

173-
# Load both demographics and historical data into Cloud Bigtable so that
173+
# Load both profiles and historical data into Cloud Bigtable so that
174174
# the dataflow pipeline can aggregate data properly before querying
175175
# the ML model.
176176

bigtable/use-cases/fraudDetection/terraform/scripts/load_dataset.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Load demographics and historical transactions data from GCS into CBT.
3+
# Load customer profiles and historical transactions data from GCS into CBT.
44

55
PROJECT_ID=$1
66
REGION=$2
@@ -18,6 +18,6 @@ echo "GCS_BUCKET=$GCS_BUCKET"
1818
mvn -f ../pom.xml compile exec:java -Dexec.mainClass=bigtable.fraud.beam.LoadDataset -Dexec.cleanupDaemonThreads=false \
1919
"-Dexec.args= --runner=DataflowRunner --project=$PROJECT_ID --projectID=$PROJECT_ID --region=$REGION \
2020
--gcpTempLocation=gs://$GCS_BUCKET/temp --CBTInstanceId=$CBT_INSTANCE --CBTTableId=$CBT_TABLE \
21-
--demographicsInputFile=gs://$GCS_BUCKET/training_dataset/customers.csv \
21+
--customerProfileInputFile=gs://$GCS_BUCKET/training_dataset/customers.csv \
2222
--historyInputFile=gs://$GCS_BUCKET/training_dataset/transactions.csv \
2323
--randomUUID=$RANDOM_UUID"

0 commit comments

Comments
 (0)