Skip to content

Instantly share code, notes, and snippets.

View hitvoice's full-sized avatar

Runqi Yang hitvoice

View GitHub Profile
@hitvoice
hitvoice / compare.ipynb
Last active January 9, 2023 08:49
Compare sample efficiency
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hitvoice
hitvoice / ReadMe.md
Last active November 17, 2017 18:53
Implementation of BNS scaling

Implementation of BNS Scaling

Limitations:

  • for binary classification/OVR/OVO only
  • suitable for documents that are not too long

Advantage:

  • take class label into consideration, correct the inappropriate scaling by IDF
  • better than TF-IDF in most benchmarks

Pratical advice:

@hitvoice
hitvoice / plot_confusion_matrix.png
Last active February 21, 2024 19:51
Generate matrix plot for confusion matrix with pretty annotations.
plot_confusion_matrix.png
@hitvoice
hitvoice / histogram_animation.py
Created November 17, 2017 18:19
example for making a video for graph changes
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.animation as manimation
FFMpegWriter = manimation.writers['ffmpeg']
writer = FFMpegWriter(fps=5)
fig = plt.figure(figsize=(12, 8))
@hitvoice
hitvoice / histogram_recover.py
Last active March 3, 2022 03:18
Example for plotting precomputed histogram in matplotlib
import numpy as np
import matplotlib.pyplot as plt
# here's the precomputed histogram via `plt.hist` or `np.histogram`
bins = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]).astype(float)
counts = np.array([5, 3, 4, 5, 6, 1, 3, 7]).astype(float)
assert len(bins) == len(counts) + 1
# recover
centroids = (bins[1:] + bins[:-1]) / 2
counts_, bins_, _ = plt.hist(centroids, bins=len(counts),