import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression
df = pd.read_excel('C:\Data.xlsx')
#print (df.head())
x_train = df['Father'].values[0:15]
y_train = df['Son'].values[0:15]
x_test = df['Father'].values[15:]
#print (x_test)
lm = linear_model.LinearRegression()
lm.fit(x_train, y_train)
-----------------------------------------
lm = linear_model.LinearRegression()
NameError: name 'linear_model' is not defined
答案 0 :(得分:2)
在导入这样的模块时:
import foo
您需要这样调用函数:
foo.bar()
但是在导入这样的模块时:
from foo import bar
您调用如下函数:
bar()
答案 1 :(得分:1)
将其放入您的代码中:
import sklearn
from sklearn import linear_model