Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- from sklearn.linear_model import LinearRegression
- #X = np.array(([1, 1], [1, 2], [2, 2], [2,3]))
- #y = np.array(([ 6, 8, 9, 11]))
- rows = int(input("Input number of rows: "))
- cols = int(input("Input number of features (not including label): "))
- print("input table (with y)")
- X = list()
- y = list()
- for i in range(rows):
- inp = list(map(int, input().split()))
- X.append(inp[:-1])
- y.append(inp[-1])
- X = np.array(tuple(X))
- y = np.array((y))
- #print(tuple([y]))
- reg = LinearRegression().fit(X, y)
- print("score", reg.score(X, y))
- print("intercept", reg.intercept_)
- print("coeff", reg.coef_)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement