I have a dataframe that looks like this:
A B C
0 1 2 PRODUCT_1
1 3 2 PRODUCT_2
2 3 2 PRODUCT_4
3 3 2 PRODUCT_5
4 5 2 PRODUCT_1
5 3 2 PRODUCT_3
I want to, for each unique product, perform a model prediction with A and B columns, and store the corresponding accuracy.
unique = ["PRODUCT_1", ...] # unique products
accuracy
for i in unique:
first_subset = ??? # all rows for product `i` - how do I implement this correctly?
X = first_subset[:, 0]
Y = first_subset[:, 1]
prediction_product_1 = model.predict(X)
accuracy_product_1 = np.sum( (prediction_product_1)/np.sum(Y) )
accuracy.append([accuracy_product_1, PRODUCT_1])
How could I implement the second point in Python?