“Algorytm regresji logistycznej” Kod odpowiedzi

Algorytm regresji logistycznej w Pythonie

# import the class
from sklearn.linear_model import LogisticRegression

# instantiate the model (using the default parameters)
logreg = LogisticRegression()

# fit the model with data
logreg.fit(X_train,y_train)

#
y_pred=logreg.predict(X_test)
Wide-eyed Whale

Algorytm regresji logistycznej w Pythonie

print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
print("Precision:",metrics.precision_score(y_test, y_pred))
print("Recall:",metrics.recall_score(y_test, y_pred))
Wide-eyed Whale

Algorytm regresji logistycznej

# Import the necessary modules
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix, classification_report

# Create training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.4, random_state=42)

# Create the classifier: logreg
logreg = LogisticRegression()

# Fit the classifier to the training data
logreg.fit(X_train, y_train)

# Predict the labels of the test set: y_pred
y_pred = logreg.predict(X_test)

# Compute and print the confusion matrix and classification report
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
josh.ipynb

Algorytm regresji logistycznej w Pythonie

# import the metrics class
from sklearn import metrics
cnf_matrix = metrics.confusion_matrix(y_test, y_pred)
cnf_matrix
Wide-eyed Whale

Odpowiedzi podobne do “Algorytm regresji logistycznej”

Pytania podobne do “Algorytm regresji logistycznej”

Więcej pokrewnych odpowiedzi na “Algorytm regresji logistycznej” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu