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 STDOUTimportnumpyasnpfromsklearn.preprocessingimportPolynomialFeaturesfromsklearn.linear_modelimportLinearRegressionF,N=map(int,input().split())train_data=[]foriinrange(N):rows=list(map(float,input().split()))train_data.append(rows)T=int(input())test_data=[list(map(float,input().split()))for_inrange(T)]X_train=[]y_train=[]forrowintrain_data:X_train.append(row[:F])y_train.append(row[F])X_train=np.array(X_train)#Converttonumpyarrayformodelinputy_train=np.array(y_train)X_test=np.array(test_data)#print(X_test)poly=PolynomialFeatures(degree=3)X_train_poly=poly.fit_transform(X_train)X_test_poly=poly.transform(X_test)model=LinearRegression()model.fit(X_train_poly,y_train)y_pred=model.predict(X_test_poly)forprediny_pred:print(pred)
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 →