使用随机创建的数据集在Python中创建线性回归模型。
# python library to generate random numbers
from random import randint
# the limit within which random numbers are generated
TRAIN_SET_LIMIT = 1000
# to create exactly 100 data items
TRAIN_SET_COUNT = 100
# list that contains input and corresponding output
TRAIN_INPUT = list()
TRAIN_OUTPUT = list()
# loop to create 100 data items with three columns each
for i in range(TRAIN_SET_COUNT):
a = randint(0, TRAIN_SET_LIMIT)
b = randint(0, TRAIN_SET_LIMIT)
c = randint(0, TRAIN_SET_LIMIT)
# creating the output for each data item
op = a + (2 * b) + (3 * c)
TRAIN_INPUT.append([a, b, c])
# adding each output to output list
TRAIN_OUTPUT.append(op)








暂无数据