Last active
November 27, 2018 15:30
-
-
Save hbredin/94dccde8a5aa39f134eda2852c02c757 to your computer and use it in GitHub Desktop.
Pipeline 101
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyannote.pipeline import Pipeline | |
import chocolate | |
class MyPipeline(Pipeline): | |
def __int__(self): | |
super().__init__() | |
self.damping = chocolate.uniform(...) | |
self.preference = chocolate.uniform(...) | |
def __call__(self, item): | |
# item = (X, y_true) | |
X = item[0] | |
y_pred = clustering(X, self.damping, self.preference) | |
return y_pred | |
def loss(self, item, y_pred) | |
y_true = item[1] | |
return f(y_true, y_pred) | |
from pyannote.pipeline import Optimizer | |
optimizer = Optimizer(MyPipeline(), '/tmp/toto.db') | |
result = optimizer.tune([(X1, y1), (X2, y2), (X3, y3)], n_iterations=100) | |
print(result['best']['loss']) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also use
pyannote.pipeline.blocks.clustering.AffinityPropagationClustering
as a "sub-pipeline".Its hyper-parameters will automatically be added to the main pipeline: