@@ -0,0 +1,1602 @@
+from abc import abstractmethod%0A%0Aimport numpy as np%0Afrom seizures.prediction.PredictorBase import PredictorBase%0Afrom sklearn.ensemble import AdaBoostClassifier%0Afrom sklearn.tree import DecisionTreeClassifier%0A%0Aclass AdaBoostTrees(PredictorBase):%0A    %22%22%22%22%0A    AdaBoost + Decision trees.%0A    See http://scikit-learn.org/stable/auto_examples/ensemble/plot_adaboost_twoclass.html %0A%0A    @author: Wittawat%0A    %22%22%22%0A%0A    def __init__(self, **options):%0A        %22%22%22%0A        options is a dictionary to be used as arguments to DecisionTreeClassifier.%0A        %22%22%22%0A        # No strong justification why max_depth=5. Change if needed.%0A        self.clf = AdaBoostClassifier(DecisionTreeClassifier(max_depth=5, **options),%0A                algorithm=%22SAMME%22,%0A                n_estimators=100 )%0A%0A    def fit(self, X, y):%0A        %22%22%22%0A        Parameters:%0A        X - 2d numpy array of training data. X.shape = %5Bn_samples, d_features%5D%0A        y - 1d numpy array of training labels%0A        %22%22%22%0A        self.clf = self.clf.fit(X, y)%0A%0A    def predict(self, X):%0A        %22%22%22%0A        Method to apply the model data%0A%0A        Parameters:%0A        X - 2d numpy array of test data%0A        %22%22%22%0A        # %5B:, 1%5D to get the second column, which contains the probabilies of %0A        # of class being 1%0A        return self.clf.predict_proba(X)%5B:, 1%5D%0A%0A%0Adef main():%0A    N = 399 %0A    D = 20%0A    X = np.random.rand(N, D)%0A    y = np.random.randint(0, 2, N)%0A%0A    predictor = AdaBoostTrees(max_features=10)%0A    predictor.fit(X, y)%0A%0A    x = np.random.rand(1, D)%0A    pred = predictor.predict(x)%0A%0A    print pred%0A%0Aif __name__ == '__main__':%0A    main()%0A%0A

Add AdaBoostTrees for prediction