Skip to content

Commit

Permalink
update jaccard comp plot
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Friedland committed Feb 19, 2019
1 parent a51d378 commit 0f26eb3
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions python_bindings/tests/jaccard_comparison_plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pandas as pd
import sys
import statsmodels.api as sm
from plotnine import ggplot, geom_point, aes, stat_smooth, geom_line, scale_x_log10, \
scale_y_log10, theme, element_text, ylim


if __name__ == "__main__":
df = pd.read_csv(sys.argv[1])
df["space_nbits"] = df.space.astype(str) + "_" + df.nbits.astype(str)
df.memory = df.memory.astype(float)
df.time = df.time.astype(float)
print(df.info())

for col in ["time", "memory"]:
funcs = []
for space_nbits in df.space_nbits.unique():
sub_df = df.loc[df.space_nbits == space_nbits]
model = sm.OLS(sub_df.num_elems, sm.add_constant(sub_df[col]))
params = model.fit().params
func = lambda x: params.const + x * getattr(params, col)
funcs.append(func)

p = (ggplot(df, aes("num_elems", col, color="space_nbits"))
+ geom_point() + geom_line()
+ scale_x_log10(limits=[10000,10000000])
+ scale_y_log10(limits=[3,10000])
+ theme(axis_text_x=element_text(rotation=90, hjust=1)))
p.save(filename=col + ".png", height=5, width=5, units='in', dpi=300)

# p = ggplot(aes(x="num_elems", y=col, color="space_nbits"), data=df) + geom_line() + geom_point() + stat_function(fun=funcs[0])
# p.make()

# fig = plt.gcf()
# ax = plt.gca()
# plt.gca().set_xscale('log')
# plt.gca().set_yscale('log')
#
# ggsave(plot=p, filename=col + ".png")

0 comments on commit 0f26eb3

Please sign in to comment.