Mercurial > hg > chourdakisreiss2018smc
view demo/rel.py @ 13:16066f0a7127 tip
fixed the problem with brat
author | Emmanouil Theofanis Chourdakis <e.t.chourdakis@qmul.ac.uk> |
---|---|
date | Sat, 08 Dec 2018 11:02:40 +0000 |
parents | 90155bdd5dd6 |
children |
line wrap: on
line source
#!/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)