Files
OpenRAM/compiler/characterizer/linear_regression.py
T

41 lines
1.1 KiB
Python
Raw Normal View History

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