OpenRAM/compiler/characterizer/linear_regression.py

41 lines
1.1 KiB
Python
Raw Normal View History

# See LICENSE for licensing information.
#
2023-01-29 07:56:27 +01:00
# Copyright (c) 2016-2023 Regents of the University of California and The Board
# 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
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
class linear_regression(regression_model):
def __init__(self, sram, spfile, corner):
super().__init__(sram, spfile, corner)
def get_model(self):
return Ridge()
def generate_model(self, features, labels):
"""
Supervised training of model.
"""
2022-07-22 18:52:38 +02:00
#model = LinearRegression()
model = self.get_model()
model.fit(features, labels)
return model
2022-07-22 18:52:38 +02:00
def model_prediction(self, model, features):
"""
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
pred = model.predict(features)
return pred