Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created October 2, 2021 11:37
Show Gist options
  • Save amankharwal/0e46dd5b82f101fdde9471f72251410c to your computer and use it in GitHub Desktop.
Save amankharwal/0e46dd5b82f101fdde9471f72251410c to your computer and use it in GitHub Desktop.
x = np.array(data[["Age", "EstimatedSalary"]])
y = np.array(data[["Purchased"]])
xtrain, xtest, ytrain, ytest = train_test_split(x, y, test_size=0.10, random_state=42)
decisiontree = DecisionTreeClassifier()
logisticregression = LogisticRegression()
knearestclassifier = KNeighborsClassifier()
svm_classifier = SVC()
bernoulli_naiveBayes = BernoulliNB()
passiveAggressive = PassiveAggressiveClassifier()
knearestclassifier.fit(xtrain, ytrain)
decisiontree.fit(xtrain, ytrain)
logisticregression.fit(xtrain, ytrain)
passiveAggressive.fit(xtrain, ytrain)
data1 = {"Classification Algorithms": ["KNN Classifier", "Decision Tree Classifier",
"Logistic Regression", "Passive Aggressive Classifier"],
"Score": [knearestclassifier.score(x,y), decisiontree.score(x, y),
logisticregression.score(x, y), passiveAggressive.score(x,y) ]}
score = pd.DataFrame(data1)
score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment