19 lines
504 B
Python
19 lines
504 B
Python
from sklearn.linear_model import LinearRegression
|
|
|
|
def perform_regression(data, data_name, target_name):
|
|
X = data[data_name]
|
|
y = data[target_name]
|
|
|
|
if not isinstance(y.iloc[0], (int, float)):
|
|
raise ValueError("The target variable should be numeric (continuous) for regression.")
|
|
|
|
model = LinearRegression()
|
|
model.fit(X, y)
|
|
|
|
return model
|
|
|
|
def make_prediction(model, feature_names, input_values):
|
|
prediction = model.predict([input_values])
|
|
|
|
return prediction[0]
|