neurobcl package#

Subpackages#

Submodules#

neurobcl.main module#

neurobcl.main.train_from_dictionary(data: List[Dict], keyword_feats_name, bucket_feats_name, quantile_gap=10, max_depth=2) NeuroBucketClassifier[source]#

Train using dictionary/json data, the format of the data should be a list of dictionaries where each dictionary represents a single item and the keys of the dictionary represent the features of the item. (Should be uniform)

Parameters:
  • data (List[Dict]) – The data to train on

  • keyword_feats_name (List[str]) – The name of the keyword features (categorical features)

  • bucket_feats_name (List[str]) – The name of the bucket features (numerical features)

  • quantile_gap (int, optional) – The gap between the quantiles

  • max_depth (int, optional) – The maximum depth of the decision tree

Returns:

The trained model

Return type:

neurobcl.base.model.NeuroBucketClassifier

data = [
    {"company": "ADIDAS", "category": "Shoes", "listPrice": 2000},
    {"company": "ADIDAS", "category": "Bracelets", "listPrice": 500},
    {"company": "NIKE", "category": "Shoes", "listPrice": 300},
    {"company": "NIKE", "category": "Clothes", "listPrice": 100},
    {"company": "PUMA", "category": "Clothes", "listPrice": 50},
    {"company": "PUMA", "category": "Shoes", "listPrice": 25},
    {"company": "PUMA", "category": "Shoes", "listPrice": 12},
    {"company": "NIKE", "category": "Shoes", "listPrice": 6},
    {"company": "NIKE", "category": "Shoes", "listPrice": 3},
]

model = train_from_dictionary(data, ["company", "category"], ["listPrice"])
print(model.get("listPrice", 1, '>')) # 3
print(model.get("listPrice", 4, '<')) # 2000

Note

The keyword_feats_name and bucket_feats_name should be contained in the data for each item

Module contents#