Skip to content

Instantly share code, notes, and snippets.

@titipata
Last active April 14, 2017 23:40
Show Gist options
  • Save titipata/1dcab5cbac39e98610eeb11929b93a4a to your computer and use it in GitHub Desktop.
Save titipata/1dcab5cbac39e98610eeb11929b93a4a to your computer and use it in GitHub Desktop.

So called NostradaTul

This is the class of NostradaTul (Nostradamus + Tulakan = NostradaTul). I created this class because Tul always correctly predict the successful rate of me on hitting up a girl randomly selected from population of Thai girls (prediction is either successful or unsuccessful). This prediction class I wrote is dedicated to Tulakan, I called it NostradaTul predictor.

class NostradaTul():
    def __init__(self, precision=0.99, recall=0.99):
        self.precision = precision
        self.recall = recall
        self.f_score = 2 * precision * recall / (precision + recall)
    def fit(self, X):
         print("NostraTul doesn't need training data for predicting successful rate. He knows the outcome.")
         return 
    def predict(self, X):
        print("You don't need to give us testing data, ask NostradaTul directly for the prediction")
        return None
    def fit_predict(self, X, y):
        print("The prediction is exact. Always. Cause this is NostradaTul")
        y_pred = y
        return y_pred # always true, one-on-one mapping to output

example usage:

import numpy as np
nostra = NostradaTul()
X, y = np.random.randn(10,10), np.random.randn(10)
nostra.fit_predict(X, y) # "The prediction is exact. Always. Cause this is NostradaTul"
print(nostra.f_score) # return 0.99, always (leave 0.01 just to make it a little more trustworthy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment