Reputation: 53
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
Upvotes: 2
Views: 38949
Reputation: 39
Put this to your Code:
import sklearn
from sklearn import linear_model
Upvotes: 2
Reputation: 101
When you are importing modules like this:
import foo
you need to call the function like this:
foo.bar()
But when you are importing modules like this:
from foo import bar
you call functions like this:
bar()
Upvotes: 4