Fixed Google Colab link in week 3 day 4, and latest week 8 updates
This commit is contained in:
29
week8_wip/agents/ensemble_agent.py
Normal file
29
week8_wip/agents/ensemble_agent.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import pandas as pd
|
||||
from sklearn.linear_model import LinearRegression
|
||||
import joblib
|
||||
|
||||
from agents.specialist_agent import SpecialistAgent
|
||||
from agents.frontier_agent import FrontierAgent
|
||||
from agents.random_forest_agent import RandomForestAgent
|
||||
|
||||
class EnsembleAgent:
|
||||
|
||||
def __init__(self, collection):
|
||||
self.specialist = SpecialistAgent()
|
||||
self.frontier = FrontierAgent(collection)
|
||||
self.random_forest = RandomForestAgent()
|
||||
self.model = joblib.load('ensemble_model.pkl')
|
||||
|
||||
def price(self, description):
|
||||
specialist = self.specialist.price(description)
|
||||
frontier = self.frontier.price(description)
|
||||
random_forest = self.random_forest.price(description)
|
||||
X = pd.DataFrame({
|
||||
'Specialist': [specialist],
|
||||
'Frontier': [frontier],
|
||||
'RandomForest': [random_forest],
|
||||
'Min': [min(specialist, frontier, random_forest)],
|
||||
'Max': [max(specialist, frontier, random_forest)],
|
||||
})
|
||||
y = self.model.predict(X)
|
||||
return y[0]
|
||||
Reference in New Issue
Block a user