Tree
1.Tree Definition
//Tree Declaration
struct TreeNode
{
int val;
TreeNode* left;
TreeNode* right;
TreeNode():val(0),left(nullptr),right(nullptr){};
TreeNode(int x):val(x),left(nullptr),right(nullptr){};
TreeNode(int x, TreeNode* l,TreeNode* r):val(x),left(l),right(r){};
};
//Tree Initializaiton with default value zero
TreeNode *root = new TreeNode(0, nullptr, nullptr);
Clustering K-Means
ML - Clustering K-Means
Clustering
Clustering is an unsupervised machine learning method that is used when you do not have labels for your data. The goal of clustering algorithms is to segment similar data points into groups; to extract meaning from the data.
Sort Algorithm implemented in C++ and Python
Quick Sort
- Python
kth-nearest neighbor
Preparing the Dataset
import modules
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.colors import ListedColormap
cmap = ListedColormap(['#FF0000', '#00FF00', '#0000FF'])
from collections import Counter
Logistic Regression
Logistic Regression
Introduction to logistic Regression
This article discusses the basics of Logistic Regression and its implementation in Python. Logistic regression is basically a supervised classification algorithm. In a classification problem, the target variable(or output), y, can take only discrete values for given set of features(or inputs), X.
Contrary to popular belief, logistic regression IS a regression model. The model builds a regression model to predict the probability that a given data entry belongs to the category numbered as “1”. Just like Linear regression assumes that the data follows a linear function, Logistic regression models the data using the sigmoid function.
Linear Regression
Linear Regression
Linear Regression Workflow Diagram and Math
<img src=”https://raw.githubusercontent.com/hadleyhzy34/pytorch/master/resources/linear.png” alt=”drawing” width=85% height=85%/>
Linear Regression Implementation from Scratch
import modules
Support Vector Machine
Support Vector Machine
Resource
math explanation:
___
1.https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/tr-98-14.pdf
2.http://web.cs.iastate.edu/~honavar/smo-svm.pdf
3.https://ai6034.mit.edu/wiki/images/SVM_and_Boosting.pdf
smo implementation: ___ https://github.com/LasseRegin/SVM-w-SMO/blob/master/SVM.py