Skip to content

Instantly share code, notes, and snippets.

@iqbalali
iqbalali / user-feedback-tagging-openai.py
Created December 15, 2022 19:23
Using OpenAI to tag user feedback. You can use this as starting block to build an app iterating over user feedback items and tagging them.
import openai
openai.api_key = 'sk-****' # Get your own API key from OpenAI, I ain't sharing mine!
prompt = """
Decide whether to tag the following review with one or more of the following themes:
Pricing, Efficiency, Reliability, Food, Service, Positive, Negative
Review: Great authentic Indian food. Good prices and childrens menu too (seems quite rare in Indian restaurants). I would definitely recommend going. The waiter service was good and waiting Tim's for food was minimal. We visited based on the good reviews on here and they seemed justified.
The only reason it isn't a 5 star was because me and my family found the lady who greeted us quite abrupt and rude and didn't allow me yo point out we had a table booked instead sent us to wait for a table to be ready in the waiting area.
@iqbalali
iqbalali / srm-simulator.py
Created April 14, 2022 11:51
Simulate SRM of A/B tests across various traffic volumes
from random import randint
from scipy.stats import chisquare
import statistics
import pandas as pd
def traffic_sim(num):
a,b =0,0
for x in range(num):
randbool = bool(randint(0,1))
if randbool:
@iqbalali
iqbalali / ssrm-false-positive.py
Last active April 26, 2022 09:08
Simulate continuous monitoring of experiments for SRM, using Chi Test. Return the Type I error rate.
from random import randint
from scipy.stats import chisquare
def traffic_sim(increment, checks):
traffic = []
a,b =0,0
for c in range(checks):
for i in range(increment):
if randint(0,1) == 1:
a +=1