Input Python

 avatar
unknown
python
3 years ago
765 B
3
Indexable
import numpy as np 
#list1=[1,2]
f_count,r_count =list(map(int,input().split()))
x=[]
y=[]

for i in range(r_count):
    row=list(map(float,input().split()))
    x.append(row[:f_count])
    y.append(row[f_count])
#print(y)
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
poly_reg = PolynomialFeatures(degree = 3)
X_poly = poly_reg.fit_transform(x)
regressor = LinearRegression()
regressor.fit(X_poly,y)


test = []

# Extracting values of the features for the test set
for i in range(int(input())):
    test.append(list(map(float, input().split())))

test_p=poly_reg.fit_transform(test)
result = regressor.predict(test_p)
for i in range(len(result)):
    print(round(result[i],2))
Editor is loading...