我正在使用數據集來查看工資與大學GPA之間的關係。我正在使用sklearn線性迴歸模型。我認爲這些係數應該是攔截和關閉的。相應功能的值。但該模型給出了單一的價值。sklearn線性迴歸係數具有單個值輸出
from sklearn.cross_validation import train_test_split
from sklearn.linear_model import LinearRegression
# Use only one feature : CollegeGPA
labour_data_gpa = labour_data[['collegeGPA']]
# salary as a dependent variable
labour_data_salary = labour_data[['Salary']]
# Split the data into training/testing sets
gpa_train, gpa_test, salary_train, salary_test = train_test_split(labour_data_gpa, labour_data_salary)
# Create linear regression object
regression = LinearRegression()
# Train the model using the training sets (first parameter is x)
regression.fit(gpa_train, salary_train)
#coefficients
regression.coef_
The output is : Out[12]: array([[ 3235.66359637]])
感謝您的教程鏈接! – MaxU