“Algoritma regresi logistik” Kode Jawaban

Algoritma regresi logistik dalam python

# 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

Algoritma regresi logistik dalam python

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

Algoritma regresi logistik

# 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

Algoritma regresi logistik dalam python

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

Jawaban yang mirip dengan “Algoritma regresi logistik”

Pertanyaan yang mirip dengan “Algoritma regresi logistik”

Lebih banyak jawaban terkait untuk “Algoritma regresi logistik” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya