Last active
May 28, 2018 00:56
-
-
Save b00033811/6eac72401005bde25bf8c0d5490b8420 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
Polynomial Class | |
@author: Abdullah Alnuaimi | |
""" | |
class Poly(): | |
def __init__(self,a,k): | |
self.a=a | |
self.k=k | |
self.A =lambda x,a=a,k=k:[[a*n**k for a,k in zip(a,k)] for n in x] | |
self.V=None | |
def fit(self,x): | |
self.V=self.A(x) | |
def evaluate(self): | |
assert self.V != None, "No data to evaluate, please fit\ | |
data using the poly.fit() method" | |
return [sum(i) for i in self.V] | |
def poly_features(self): | |
assert self.V != None, "No data to generate matrix, please fit\ | |
data using the poly.fit() method" | |
return self.V |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment