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.
importsysimportpandasaspdfromsklearnimportlinear_modelif__name__=='__main__':timeCharged=float(input().strip())dataset=pd.read_csv('trainingdata.txt',header=None)# According to the chart, we must remove items with a # duration of time greater than eight.dataset=dataset[dataset.iloc[:,1]<8]# Add biasdataset.insert(0,len(dataset.columns),0)# Separe variables dependet and independentX=dataset.iloc[:,0:2]Y=dataset.iloc[:,2]# Create the classifier modelmodel=linear_model.LinearRegression()model.fit(X,Y)# Set new value to predictresult=model.predict([[0,timeCharged]])ifresult[0]>8:print(8.0)else:print(round(result[0],2))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Laptop Battery Life
You are viewing a single comment's thread. Return to all comments →