A very basic question. We have dataset with experience and salary
now i wanted to merge my predictions and create an output with experience and the predicted salary, How do I do this in python.
below is my code. what should i change here ?
YearsExperience Salary
1.1 39343.0
1.3 46205.0
1.5 37731.0
2.0 43525.0
2.2 39891.0
2.9 56642.0
3.0 60150.0
3.2 54445.0
3.2 64445.0
now i wanted to merge my predictions and create an output with experience and the predicted salary, How do I do this in python.
below is my code. what should i change here ?
#Importing Libraries import pandas as pd import numpy as np import matplotlib.pyplot as mp #Import Dataset data = pd.read_csv('H:\Data\Simple_Linear_Regression\Salary_Data.csv') x = data.iloc[:, :-1].values y = data.iloc[:, 1:2] #Split into train and test from sklearn.cross_validation import train_test_split xtrain, xtest, ytrain, ytest = train_test_split(x,y, test_size = 1/3, random_state = 0) #Fit Linear Regression Model from sklearn.linear_model import LinearRegression regressor = LinearRegression() regressor.fit(xtrain,ytrain) regressor.score(xtrain,ytrain) #Predict Salary ypred = regressor.predict(xtest)DataSet:
YearsExperience Salary
1.1 39343.0
1.3 46205.0
1.5 37731.0
2.0 43525.0
2.2 39891.0
2.9 56642.0
3.0 60150.0
3.2 54445.0
3.2 64445.0