Python Forum
Merge Predictions with whole data set
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Merge Predictions with whole data set
#1
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 ?



#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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to save predictions made by an autoencoder Glasgow1988 0 1,540 Jul-03-2020, 12:43 PM
Last Post: Glasgow1988
  Utilize input predictions for Supervised Learning donnertrud 2 1,856 May-20-2020, 12:45 PM
Last Post: donnertrud
  Basic data analysis and predictions mates 15 6,750 Mar-14-2020, 09:06 PM
Last Post: mates

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020