Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. class SharedScalerModel:
  2.  
  3. def __init__(self, scaler, lm):
  4. self.scaler = scaler
  5. self.lm = lm
  6. self.coef_ = lm.coef_
  7. self.intercept_ = lm.intercept_
  8.  
  9. def predict(self, X):
  10. return self.lm.predict(self.scaler.transform(X))
  11.  
  12. def fit_linear_model(x, y):
  13. lr = Ridge()
  14. lr.fit(shared_scaler.transform(x), y)
  15. return SharedScalerModel(shared_scaler, lr)
  16.  
  17. def load_model(well_id, path):
  18. files = os.listdir(path)
  19. for name in files:
  20. if name.startswith(well_id) and name.endswith('.joblib'):
  21. return joblib.load(path+name)
  22.  
  23. def load_param(well_id, path):
  24. files = os.listdir(path)
  25. for name in files:
  26. if name.startswith(well_id) and name.endswith('.txt'):
  27. data = pd.read_csv(path+name, delimiter = '\t')
  28. return data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement