<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Regression
1. Information Generation
Simulation of values to train and test the linear regression model.
Step1:  2. ages_train vs ages_test relationship
Is there a trend we can model ?
Step2:  3. Model Creation and Predictions
Model fitting
<ASSISTANT_TASK:>
Python Code:
# importing packages
import numpy
import random
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
# setting ageNetWorthData
def ageNetWorthData():
    random.seed(42)
    numpy.random.seed(42)
    ages = []
    for ii in range(100):
        ages.append( random.randint(20,65))
    net_worths = [ii * 6.25 + numpy.random.normal(scale=40.) for ii in ages]
    ages       = numpy.reshape( numpy.array(ages), (len(ages), 1))
    net_worths = numpy.reshape( numpy.array(net_worths), (len(net_worths), 1))
    from sklearn.cross_validation import train_test_split
    ages_train, ages_test, net_worths_train, net_worths_test = train_test_split(ages, net_worths)
    return ages_train, ages_test, net_worths_train, net_worths_test
# using ageNetWorthData
ages_train, ages_test, net_worths_train, net_worths_test = ageNetWorthData()
Explanation: Regression
1. Information Generation
Simulation of values to train and test the linear regression model.
End of explanation
# Plot ages_train vs net_worths_train
plt.scatter(ages_train,net_worths_train)
# Setting axis labels
plt.xlabel('Ages')
plt.ylabel('Net_worths')
plt.show()
Explanation: 2. ages_train vs ages_test relationship
Is there a trend we can model ?
End of explanation
%matplotlib inline
reg = LinearRegression()
reg.fit(ages_train, net_worths_train)
fig = plt.figure()
ax = fig.add_subplot(111)
plt.scatter(ages_train,net_worths_train)
plt.plot(ages_test, reg.predict(ages_test), color='blue',linewidth=3)
intercep = reg.intercept_
slope = reg.coef_
ax.text(20, 400, r' $Net worths =' + str(round(intercep.item(0),2)) +' + ' 
                                   + str(round(slope.item(0),2)) + '(Age) $', fontsize=10)
Explanation: 3. Model Creation and Predictions
Model fitting:  $y = a + bx$
parameters: $a,b$
Independent variable: $x$
End of explanation
<END_TASK>