Start working on project assess learners.

This commit is contained in:
2020-09-21 22:15:46 -04:00
parent 927c5eb9de
commit 9697add7a6
7 changed files with 677 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
import numpy as np
class DTLearner(object):
def __init__(self, leaf_size = 1, verbose = False):
pass # move along, these aren't the drones you're looking for
def author(self):
return 'felixm' # replace tb34 with your Georgia Tech username
def addEvidence(self, dataX, dataY):
"""
@summary: Add training data to learner
@param dataX: X values of data to add
@param dataY: the Y training values
"""
# slap on 1s column so linear regression finds a constant term
newdataX = np.ones([dataX.shape[0], dataX.shape[1]+1])
newdataX[:,0:dataX.shape[1]] = dataX
# build and save the model
self.model_coefs, residuals, rank, s = np.linalg.lstsq(newdataX,
dataY,
rcond=None)
def query(self,points):
"""
@summary: Estimate a set of test points given the model we built.
@param points: should be a numpy array with each row corresponding to a specific query.
@returns the estimated values according to the saved model.
"""
return (self.model_coefs[:-1] * points).sum(axis = 1) + self.model_coefs[-1]
if __name__=="__main__":
print("the secret clue is 'zzyzx'")