This is first attempt to create blog posts using my personal website.

In [5]:

from sklearn.linear_model import LogisticRegression

from sklearn.datasets import make_classification

from sklearn.model_selection import train_test_split


# Generate a synthetic binary classification dataset

X, y = make_classification(

    n_samples=100,

    n_features=2,

    n_informative=2,

    n_redundant=0,

    n_repeated=0,

    n_classes=2,

    random_state=42

)


# Split into train and test sets

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)


# Create and fit logistic regression model

model = LogisticRegression()

model.fit(X_train, y_train)


# Predict on test set

y_pred = model.predict(X_test)


# Print accuracy

print("Accuracy:", model.score(X_test, y_test))


Accuracy: 0.95


Back to Home