2020-12-15 21:08:31 +01:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2024-01-03 23:32:44 +01:00
|
|
|
# Copyright (c) 2016-2024 Regents of the University of California and The Board
|
2020-12-15 21:08:31 +01:00
|
|
|
# of Regents for the Oklahoma Agricultural and Mechanical College
|
|
|
|
|
# (acting for and on behalf of Oklahoma State University)
|
|
|
|
|
# All rights reserved.
|
|
|
|
|
#
|
2021-02-26 20:00:21 +01:00
|
|
|
from sklearn.linear_model import Ridge
|
2020-12-15 21:08:31 +01:00
|
|
|
from sklearn.linear_model import LinearRegression
|
2022-11-27 22:01:20 +01:00
|
|
|
from openram import debug
|
|
|
|
|
from openram import OPTS
|
|
|
|
|
from .regression_model import regression_model
|
2020-12-15 21:08:31 +01:00
|
|
|
|
|
|
|
|
|
2021-01-19 23:19:50 +01:00
|
|
|
class linear_regression(regression_model):
|
2020-12-15 21:08:31 +01:00
|
|
|
|
|
|
|
|
def __init__(self, sram, spfile, corner):
|
|
|
|
|
super().__init__(sram, spfile, corner)
|
2021-01-13 22:04:34 +01:00
|
|
|
|
2021-06-05 00:04:52 +02:00
|
|
|
def get_model(self):
|
|
|
|
|
return Ridge()
|
|
|
|
|
|
2020-12-15 21:08:31 +01:00
|
|
|
def generate_model(self, features, labels):
|
|
|
|
|
"""
|
|
|
|
|
Supervised training of model.
|
|
|
|
|
"""
|
2022-07-22 18:52:38 +02:00
|
|
|
|
2021-02-26 20:00:21 +01:00
|
|
|
#model = LinearRegression()
|
2021-06-05 00:04:52 +02:00
|
|
|
model = self.get_model()
|
2020-12-15 21:08:31 +01:00
|
|
|
model.fit(features, labels)
|
|
|
|
|
return model
|
2022-07-22 18:52:38 +02:00
|
|
|
|
|
|
|
|
def model_prediction(self, model, features):
|
2020-12-15 21:08:31 +01:00
|
|
|
"""
|
|
|
|
|
Have the model perform a prediction and unscale the prediction
|
|
|
|
|
as the model is trained with scaled values.
|
|
|
|
|
"""
|
2022-07-22 18:52:38 +02:00
|
|
|
|
2020-12-15 21:08:31 +01:00
|
|
|
pred = model.predict(features)
|
|
|
|
|
return pred
|