This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Cout | |
| // #include <iostream> | |
| // using namespace std; | |
| // int main() | |
| // { | |
| // char sample[] = "Electronics Club"; | |
| // cout << sample << " , IIT Kanpur"; | |
| // return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Let’s start with importing libraries: | |
| import numpy as np | |
| import pandas as pd | |
| import matplotlib.pyplot as plt #data visualization | |
| from sklearn.datasets import make_blobs #synthetic dataset | |
| from sklearn.neighbors import KNeighborsClassifier #kNN classifier | |
| from sklearn.model_selection import train_test_split #train and test sets |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Non-Linear SVM Example | |
| #For this example, we'll use a slightly more complicated dataset to show one of the areas SVMs shine in. Let's import some packages. | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from sklearn import datasets | |
| from sklearn import svm | |
| #This set of imports is similar to those in the linear example, except it imports one more thing. Now we can use a dataset directly from the Scikit-learn library. | |
| # non-linear data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # We'll start by importing a few libraries that will make it easy to work with most machine learning projects. | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from sklearn import svm | |
| # For a simple linear example, we'll just make some dummy data and that will act in the place of importing a dataset. | |
| # linear data | |
| X = np.array([1, 5, 1.5, 8, 1, 9, 7, 8.7, 2.3, 5.5, 7.7, 6.1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| #Loading dataset – User_Data | |
| dataset = pd.read_csv('...\\User_Data.csv') | |
| #Now, to predict whether a user will purchase the product or not, one needs to find out the relationship between Age and Estimated Salary. Here User ID and Gender are not important factors for finding out this. | |
| # input | |
| x = dataset.iloc[:, [2, 3]].values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # imports | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.metrics import mean_squared_error, r2_score | |
| # generate random data-set | |
| np.random.seed(0) | |
| x = np.random.rand(100, 1) | |
| y = 2 + 3 * x + np.random.rand(100, 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # imports | |
| import numpy as np | |
| class LinearRegressionUsingGD: | |
| """Linear Regression Using Gradient Descent. | |
| Parameters | |
| ---------- | |
| eta : float | |
| Learning rate |