diff demo/rel.py @ 0:4dad87badb0c

initial commit
author Emmanouil Theofanis Chourdakis <e.t.chourdakis@qmul.ac.uk>
date Wed, 16 May 2018 17:56:10 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/rel.py	Wed May 16 17:56:10 2018 +0100
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Mon Apr 30 17:49:36 2018
+
+@author: Emmanouil Theofanis Chourdakis
+"""
+
+from sklearn.svm import LinearSVC
+from sklearn.feature_extraction import DictVectorizer
+
+class RelModel(LinearSVC):
+    ## TODO: Add more LinearSVC parameters here
+    def __init__(self):
+        super(RelModel, self).__init__()
+        self.dv = DictVectorizer()
+        
+    def fit(self, X, y, sample_weight=None):
+        
+        # Transform data and save transformer
+        x = self.dv.fit_transform(X)
+        
+        return super(RelModel, self).fit(x, y, sample_weight)
+    
+    def predict(self, X):
+        # Transform data with transformer
+        x = self.dv.transform(X)
+        
+        return super(RelModel, self).predict(x)