Classification algorithms in Data Science
Data Science

Classification algorithms in Data Science

Logistic regression :

The Logistic regression produces results in a binary product which is used to predict the outcome of a categorical dependent variable. So the outcome should be categorical/discrete. It is a classification algorithm which is used in machine learning .Using a logistic function the probabilities describing the possible results of a single trial are modeled in this algorithm. The gain of Logistic regression is designed for this purpose , and is most useful for understanding the influence of several independent variables on a single outcome variable. The drawback of Logistic regression works only when the predicted variable is binary, assumes all predictors are independent of each other, and assumes data is free of missing values.

from sklearn.linear_model import LogisticRegression model=LogisticRegression() 
model.fit(x_train,y_train)
y_pred = model.predict(x_test)

K nearest neighbors :

K nearest neighbors(KNN) is the simplest supervised machine learning algorithm used for classification. It classifies a data point based on how its neighbors are classified.

from sklearn.neighbors import KNeighborsClassifier
knn = KneighborsClassifier(n_neighbors=15)
knn.fit(x_train,y_train)
y_pred=knn.predict(x_test)

Decision tree :

The Decision tree is a type of classification algorithm which concerned the supervised learning technique. It is the graphical representation of all the possible solutions . Decisions are based on some conditions. The advantage of Decision Tree is simple to understand and visualize, requires little data preparation, and can handle both numerical and categorical data.

from sklearn.tree import DecisionTreeClassifier
dtree=DecisionTreeClassifier(max_depth=10,random_state=101,max_features=None,min_samples_leaf =15)
dtree.fit(x_train,y_train)
y_pred=dtree.predict(x_test)

Support Vector Machine :

Support vector machine is a supervised machine learning algorithm that has become extremely popular with extreme effective results and also it is a discriminative classifier that is formally designed by a separative hyperplane. It is a representation of examples as points in space that are mapped so that the points of different categories are separated by a gap as wide as possible.

from sklearn.svm import SVC
svm = SVC(kernal=”linear”,C=0.025,random_state=101)
svm.fit(x_train,y_train)
y_pred=svm.predict(x_test)

Author: STEPS

Leave a Reply

Your email address will not be published. Required fields are marked *