Dynamic Categorization Code Samples

Dynamic categorization best fits product information such as title and description to a product taxonomy tree or categories list. The baseline dynamic categorization endpoint does not need to be tuned for your specific categories as it's learned a relationship across different taxonomy trees.

A fine-tuned dynamic categorization model is a newly trained model that focuses on fitting product data to a specific taxonomy tree or categories list. Once the model has been fine-tuned on your specific tree it cannot change. The model has been "steered" to your specific use case and products. The steering leads to a much higher accuracy for your specific products and catalog information.

These are code examples we've used to interact with the Pumice.ai dynamic batch categorization endpoint and the correlated data.

Output json to pandas function

def pumice_json_to_pandas(filename):
with open(filename) as f:
data = json.load(f)['data']
return pd.DataFrame(data)

Pumice.ai formatted json to a csv file

import csv
def pumice_json_to_csv(filename, csv_file):
with open(filename) as f:
data = json.load(f)['data'][0]
print(data)
with open(csv_file, 'w') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=data.keys())
writer.writeheader()
for row in data:
writer.writerow(row)
return 'Success!'

Pumice.ai pandas dataframe to csv

def pumice_pandas_to_csv(pumice_df, csv_file):
pumice_df.to_csv(csv_file)
return 'Success!'