Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
sklearn pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
ntapiam committed Apr 2, 2021
1 parent 5737288 commit 5ef2b31
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions iss/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from ._sklearn import *
from .o3iss import *
35 changes: 35 additions & 0 deletions iss/_sklearn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from .o3iss import compute
from sklearn.base import BaseEstimator, ClassifierMixin, TransformerMixin
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
import numpy as np


class IssTransformer(BaseEstimator, TransformerMixin):
def __init__(self, level=4):
self.level = level

def fit(self, X, y=None):
return self

def transform(self, X):
return np.array([compute(x, self.level) for x in X])


class IssClassifier(BaseEstimator, ClassifierMixin):
def __init__(self, level=4):
self.level = level
self.pipeline = Pipeline(
[
("scale", StandardScaler()),
("iss", IssTransformer(level=level)),
("logit", LogisticRegression()),
]
)

def fit(self, X, y):
return self.pipeline.fit(X, y)

def predict(self, X):
return self.pipeline.predict(X)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = iss
version = 0.1.1
version = 0.1.2
author = Nikolas Tapia
author_email = tapia@wias-berlin.de
description = Iterated-sums signature in Rust
Expand Down

0 comments on commit 5ef2b31

Please sign in to comment.