TutorMe homepage
Subjects
PRICING
COURSES
Start Free Trial
Naman S.
Research Assistant in Data Science at UIUC
Tutor Satisfaction Guarantee
Python Programming
TutorMe
Question:

Example application of support vector machine from sklearn package.

Naman S.

Here is a small demonstration of svm classifier. 1. import all the necessary libraries: import numpy as np from sklearn import preprocessing, svm from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split 2. Enter Labels (as 'y') and Features (as 'x') : x = [1,23,4,5,3245,2,34,52,345,2,3] y = [3,23,22,34,45,234,5,234,52,345,1] Note: features could be of any size with length same as labels. 3. Separate the data into train and test categories: x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2) 4. Perform SVM classification: clf = svm() clf.fit(x_train, y_train) 5. Test the classifier's accuracy: accuracy = clf.score(x_test, y_test) print(accuracy) And we are done!

MATLAB
TutorMe
Question:

How can I create $$m\times m$$ symmetric matrix in MATLAB efficiently?

Naman S.

Here's one of my code for creating the matrix: K = zeros(M,M); for row = 1:M for col = 1:row K(row,col) = value you want to insert end end K = K + K'; % Dividing the diagonal element by 2 since it has been added to itself for row = 1:(M) The above code will only fill the values in the lower diagonal elements (including the diagonal). Then, we will add the same matrix K with K-transpose to duplicate all the symmetric entries. Then divide the diagonal elements by 2 because we have added the same thing twice. And we are done!

Calculus
TutorMe
Question:

Integrate: $$\int x \sqrt{x+1} dx$$

Naman S.

By looking at this problem, it feels like this integral could be solved by integration by parts method. Unfortunately, integration by parts does not seem to applicable directly. Therefore, substitution is required. Substitute : $$u = x +1$$ New equation: $$\int x \sqrt{x+1} dx = \int u-1 \sqrt{u} du$$ Now we can apply integration by parts. $$= \int u^{\frac{3}{2}} - u^{\frac{1}{2}} du$$ $$= \frac{2}{5}u^{\frac{5}{2}} - \frac{2}{3}u^{\frac{3}{2}} + c$$ Now, convert the above equation in terms of $$x$$ by re-substituting. $$= \frac{2}{5}(x+1)^{\frac{5}{2}} - \frac{2}{3}(x+1)^{\frac{3}{2}} + c$$ And we are done !

Send a message explaining your
needs and Naman will reply soon.
Contact Naman