Python Forum
Join Predicted values with test dataset
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Join Predicted values with test dataset
#3
Thank you for the reply.
This is how I get the y_pred.
# split data 
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.25, random_state=0, shuffle=True)

# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)	

# Fitting SVM
from sklearn.svm import SVC
classifier = SVC(kernel = 'linear', random_state = 0)
classifier.fit(X_train, y_train)

# Predicting the Test
y_pred = classifier.predict(X_test)
This is my desired result dataset.
df1 = pd.concat([X_test.reset_index(drop='Tru‌​e'),y_pred.reset_index(drop='Tru‌​e')],axis=1)
I want to join the x_test+y_pred so that i can compare the predicted result one by one. By doing above concat, does each row of y_test and y_pred align in the same order as in x_test?
I am developing a model to classify the behavior of people so that necessary actions can be taken for each individual.
Reply


Messages In This Thread
Join Predicted values with test dataset - by bhuwan - Mar-25-2019, 04:21 PM
RE: Join Predicted values with test dataset - by bhuwan - Mar-26-2019, 03:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to test likelihood hypothesis on dataset? iiiioooo 0 947 Apr-18-2022, 01:00 PM
Last Post: iiiioooo
  Graph that shows predicted vs true values donnertrud 1 2,619 Jan-28-2020, 07:47 PM
Last Post: jefsummers
  Partitioning when splitting data into train and test-dataset Den0st 0 2,016 Dec-07-2019, 08:31 PM
Last Post: Den0st
  spread values of dataset equally over fixed number of bins moose_man 3 2,583 Oct-30-2019, 07:41 PM
Last Post: ichabod801
  How many unique values of quality are in this dataset? Jack_Sparrow 1 3,180 May-20-2018, 01:59 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

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