Posts

Showing posts from May, 2021

Performance Analysis of Classification model

Image
 Performance Analysis of Classification models In a machine learning Algorithm once the model is built, the next step is the  use of various performance criteria to evaluate Machine learning Models. In the Classification model output is a discrete value therefore for classification performance analysis following methods are used    Confusion matrix Accuracy Precision Recall (sensitivity) Specificity ROC curve (AUC) ROC Area Under Curve is useful when we are not concerned about whether the small dataset/class of dataset is positive or not, in contrast to F1 score where the class being positive is important. F-score( F1 score is useful when the size of the positive class is relatively small ) Performance metrics should be chosen based on the problem domain, project goals, and objectives.  A confusion matrix A confusion matrix is a table that is  used to  describe the performance of algorithm (or "classifier") on a set of test data for which the true values/targ

Performance of Regression model and Classification model

  Performance of Regression model and Classification model In a machine learning Algorithm once the model is built, the next step is the  use of various performance criteria to evaluate Machine learning Models. Various performance Matrix/Criteria used for regression model and Classification models are different and are listed below. Regression Model: In Regression analysis output is continuous value, therefore for Regression performance following methods are used Mean squared error (MSE) Mean average error(MAE) Root mean squared error (RMSE) R Square Classification Model:   In the classification model output is Discret form and for classification performance following methods are used Confusion matrix Accuracy Precision Recall (sensitivity) Specificity  ROC curve (AUC) ROC Area Under Curve is useful when we are not concerned about   whether the small dataset/class of dataset is positive or not, in contrast to F1 score where the class being positive is important. F-score( F1 score i

SVM Algorithm for Python Code

  For every Machine Learning Algorithm following are the major steps to build the Model: 1. Collection of data          2. Divide data into training and testing           3. Build the Network 5. Performance Analysis and Accuracy calculations Step1 : Load dataset #Import scikit-learn dataset library from sklearn import datasets  Ex. cancer = datasets.load_breast_cancer()   Step 2:Split dataset into a training set and test set Import train_test_split function from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(cancer.data, cancer.target, test_size=0.3,random_state=109) # 70% training and 30% test Step3:Create a svm Classifier   Import svm model from sklearn import svm clf = svm.SVC(kernel='linear') # Linear Kernel clf = svm.SVC(kernel='linear') # Linear Kernel   Step4:Train the model using the training sets clf.fit(X_train, y_train)   Step5:Predict the response for test dataset y_pred = clf.predict(X_t

MCQ's on Linear Regession, Logistic Regression,Neural Network,Deep Neural Network and Convolution Neural Network

  MCQ's  on Linear Regession, Logistic Regression,Neural Network,Deep Neural Network,Convolution Neural Network Q.1) Linear   Regression is a type of --------- a)Supervised learning b)Unsupervised learning c) Reinforcement learning Correct Answer a)Supervised learning Q.2) ------------------variable is   Predictive variable a)Dependent   b)Independent Correct Answer a)Dependent Q.3) The name multinomial logistic regression is usually reserved for the case when the ------variable has three or more unique values, such as cloudy, Rainy, hotor cold. a.)Dependent b.)Independent Correct Answer – a) Dependent Q.4.Logistic regression does not assume a linear relationship between the dependents and the independents.    a)False b)True        Correct Answer – b)True         Q.5.Dependent   variable is categorical: a)Y Ԑ(0,1) b) Y Ԑ(-1,1)   Correct Answer – a) )Y Ԑ(0,1) Q.6. To   Predict whether mail on mail box is spam or not spam------algorithm is

Non Linear SVM and Kernal function

Image
  Non-Linear SVM and Kernal function Non Linear Data : If a data set or given sample can not be separated by a single line then it is non linear data. Non Linear SVM: To separate non linear data , non linear SVM is used. Trick Kernel Function: To separate non linear data Trick Kernals are used. Both non linear data and Trick Kernals are related to each other. Non Linear Data: Figure 2 shows non linear data. Single line or straight line can not separate these data. Straight line gives less than 50% accuracy.         Figure1: Non Linear Data Solution to this problem is use of Trick Kernel. Trick Kernel takes input low dimensional feature space and convert into high dimensional feature space so that non separable data get separated   Two dimensional data converted into three dimensional data using kernel as shown in figure 1 and it become seperable. ·          Following are the different kernel used in SVM: Ø   Liner Kernel ·       A linear kernel is a dot product of any two given obs

Mathematical representation of SVM

Image
Mathematical representation of SVM In the previous blog we have seen basics of support vector machine. In this blog we have to see maths intuition behind the support vector machine. The most important in case of SVM is creat hyperplane and calculate marginal distance between positive hyperplane and negative hyperplane, so that it is easy to classify data. First step is to calculate or marginal distance between   +ve hyperplane and – ve hyperplane. Consider following example. Ex.   Suppose their are two points     (-5,0) & (5,5). Figure1: SVM Classifier A straight line which divides these  two points is having slop -1 and passes through origin Solution   Equation of of hyper plane   y is either +1 or -1 depending on class 1 or class 2 Hear  slope = -1  Therefore  m = -1and   &  b = 0, As line passes through origin Putting it in equation 2 we get For point (-5,0)   calculate y value.  In this m = -1 and b=0      Any point left to the line is always -ve For point