Skip to content

Instantly share code, notes, and snippets.

@b00033811
Last active May 28, 2018 00:56
Show Gist options
  • Save b00033811/6eac72401005bde25bf8c0d5490b8420 to your computer and use it in GitHub Desktop.
Save b00033811/6eac72401005bde25bf8c0d5490b8420 to your computer and use it in GitHub Desktop.
"""
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