We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Enter your code here. Read input from STDIN. Print output to STDOUTfromsklearn.linear_modelimportLinearRegressionfromsklearn.preprocessingimportPolynomialFeaturesF,N=map(int,input().split())x=[]y=[]for_inrange(N):data=list(map(float,input().split()))x.append(data[:-1])y.append(data[-1])T=int(input())x_test=[]for_inrange(T):data=list(map(float,input().split()))x_test.append(data)poly=PolynomialFeatures(degree=3)xpoly=poly.fit_transform(x)x_testpoly=poly.transform(x_test)model=LinearRegression()model.fit(xpoly,y)predicted=model.predict(x_testpoly)forpinpredicted:print(str(round(p,2)))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Polynomial Regression: Office Prices
You are viewing a single comment's thread. Return to all comments →