from sklearn.linear_model import LogisticRegression


class AssertiveClassifier:
    def __init__(self, vectorizer, threshold=0.5):
        self.vectorizer = vectorizer
        self.model = LogisticRegression(max_iter=1000)
        self.threshold = threshold

    def fit(self, texts, labels):
        X = self.vectorizer.transform(texts)
        self.model.fit(X, labels)

    def predict(self, text):
        X = self.vectorizer.transform([text])
        prob = self.model.predict_proba(X)[0][1]
        return int(prob >= self.threshold)
