baf8c13aedeb135b38cce9831b1be7034a95d8e9,numerox/report.py,Report,out_of_five,#Report#,157
Before Change
cols = ["N", "0/5", "1/5", "2/5", "3/5", "4/5", "5/5", "mean/5"]
df = pd.DataFrame(columns=cols)
lb = self.lb[round1:round2]
rounds = lb["round"].unique()
nan = np.nan
for r in rounds:
d = lb[lb["round"] == r]
if not d["resolved"].any():
fraction = [0, nan, nan, nan, nan, nan, nan, nan]
else:
idx = (d.groupby("user").count()["round"] == 5)
idx = idx[idx]
idx = d.user.isin(idx.index)
d = d[idx]
d["pass"] = d["live"] < LOGLOSS_BENCHMARK
s = d.groupby("user").sum()
rep = s.groupby("pass").count()
rep = rep["round"].to_frame("count")
count = rep["count"].sum()
fraction = 1.0 * rep["count"] / count
mean = np.dot(fraction, np.array([0, 1, 2, 3, 4, 5]))
fraction = fraction.tolist()
fraction.insert(0, count)
fraction.insert(7, mean)
df.loc[r] = fraction
df.loc["mean"] = df.mean()
df["N"] = df["N"].astype(int)
return df
After Change
cols = ["N", "0/5", "1/5", "2/5", "3/5", "4/5", "5/5", "mean/5"]
df = pd.DataFrame(columns=cols)
lb = self.lb[round1:round2]
rounds = np.sort(lb["round"].unique())
nan = np.nan
for r in rounds:
d = lb[lb["round"] == r]
if not d["resolved"].any():
fraction = [0, nan, nan, nan, nan, nan, nan, nan]
else:
idx = (d.groupby("user").count()["round"] == 5)
idx = idx[idx]
idx = d.user.isin(idx.index)
d = d[idx]
d["pass"] = d["live"] < LOGLOSS_BENCHMARK
s = d.groupby("user").sum()
rep = s.groupby("pass").count()
rep = rep["round"].to_frame("count")
count = rep["count"].sum()
fraction = 1.0 * rep["count"] / count
mean = np.dot(fraction, np.array([0, 1, 2, 3, 4, 5]))
fraction = fraction.tolist()
fraction.insert(0, count)
fraction.insert(7, mean)
df.loc[r] = fraction
df.loc["mean"] = df.mean()
df["N"] = df["N"].astype(int)
return df
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances
Project Name: kwgoodman/numerox
Commit Name: baf8c13aedeb135b38cce9831b1be7034a95d8e9
Time: 2018-10-23
Author: kwgoodman@gmail.com
File Name: numerox/report.py
Class Name: Report
Method Name: out_of_five
Project Name: kwgoodman/numerox
Commit Name: baf8c13aedeb135b38cce9831b1be7034a95d8e9
Time: 2018-10-23
Author: kwgoodman@gmail.com
File Name: numerox/report.py
Class Name: Report
Method Name: whatif
Project Name: kwgoodman/numerox
Commit Name: baf8c13aedeb135b38cce9831b1be7034a95d8e9
Time: 2018-10-23
Author: kwgoodman@gmail.com
File Name: numerox/report.py
Class Name: Report
Method Name: pass_rate