Re: [scikit-learn] merging the predicted labels with original dataframe

2017-07-20 Thread Ruchika Nayyar
Hi Tom This was also the first thing that came to my mind, but I thought sincr your_df is X_train+X_test it may complain that values do not match with the given indices. Thanks, Ruchika On Thu, Jul 20, 2017 at 12:19 PM, Tom Augspurger wrote: > Something like > > your_df['prediction'] = pd

Re: [scikit-learn] merging the predicted labels with original dataframe

2017-07-20 Thread Tom Augspurger
Something like your_df['prediction'] = pd.Series(clf.predict(X_test), index=X_test.index) should handle all the alignment. On Thu, Jul 20, 2017 at 11:04 AM, Ruchika Nayyar wrote: > The original dataset contains both trainng/testing, I have predictions > only on testing dataset. If I do wha

Re: [scikit-learn] merging the predicted labels with original dataframe

2017-07-20 Thread Ruchika Nayyar
The original dataset contains both trainng/testing, I have predictions only on testing dataset. If I do what you suggest will it preserve indexing? Thanks, Ruchika On Thu, Jul 20, 2017 at 11:37 AM, Julio Antonio Soto de Vicente < ju...@esbet.es> wrote: > Hi Ruchika, > > The predictions outputte

Re: [scikit-learn] merging the predicted labels with original dataframe

2017-07-20 Thread Julio Antonio Soto de Vicente
Hi Ruchika, The predictions outputted by all sklearn models are just 1-d Numpy arrays, so it should be trivial to add it to any existing DataFrame: your_df["prediction"] = clf.predict(X_test) -- Julio > El 20 jul 2017, a las 17:23, Ruchika Nayyar escribió: > > Hi Scikit-learn Users, > > I

[scikit-learn] merging the predicted labels with original dataframe

2017-07-20 Thread Ruchika Nayyar
Hi Scikit-learn Users, I am analyzing some proxy logs to use Machine learning to classify the events recorded as either "OBSERVED" or "BLOCKED". This is a little snippet of my code: The input file is a csv with tokenized string fields. ** # load the file M = pd.read_csv("output100k.cs