Posts

Showing posts with the label Polynomials

Cannot Understand With Sklearn's PolynomialFeatures

Image
Answer : If you have features [a, b, c] the default polynomial features(in sklearn the degree is 2) should be [1, a, b, c, a^2, b^2, c^2, ab, bc, ca] . 2.61576000e+03 is 37.8x62.2=2615,76 ( 2615,76 = 2.61576000 x 10^3 ) In a simple way with the PolynomialFeatures you can create new features. There is a good reference here. Of course there are and disadvantages("Overfitting") of using PolynomialFeatures (see here). Edit: We have to be careful when using the polynomial features. The formula for calculating the number of the polynomial features is N(n,d)=C(n+d,d) where n is the number of the features, d is the degree of the polynomial, C is binomial coefficient(combination). In our case the number is C(3+2,2)=5!/(5-2)!2!=10 but when the number of features or the degree is height the polynomial features becomes too many. For example: N(100,2)=5151 N(100,5)=96560646 So in this case you may need to apply regularization to penalize some of the weights. It is...

Basis Of The Polynomial Vector Space

Answer : A basis for a polynomial vector space P = { p 1 , p 2 , … , p n } P=\{ p_1,p_2,\ldots,p_n \} P = { p 1 ​ , p 2 ​ , … , p n ​ } is a set of vectors (polynomials in this case) that spans the space, and is linearly independent. Take for example, S = { 1 , x , x 2 } . S=\{ 1,x,x^2 \}. S = { 1 , x , x 2 } . This spans the set of all polynomials ( P 2 P_2 P 2 ​ ) of the form a x 2 + b x + c , ax^2+bx+c, a x 2 + b x + c , and one vector in S S S cannot be written as a multiple of the other two. The vector space { 1 , x , x 2 , x 2 + 1 } \{ 1,x,x^2,x^2+1 \} { 1 , x , x 2 , x 2 + 1 } on the other hand spans the space, but the 4th vector can be written as a multiple of the first and third (not linearly independent), thus it is not a basis. The simplest possible basis is the monomial basis: { 1 , x , x 2 , x 3 , … , x n } \{1,x,x^2,x^3,\ldots,x^n\} { 1 , x , x 2 , x 3 , … , x n } . Recall the definition of a basis. The key property is that some linear combination of basis vec...