How to extract true positives data (complete row with data) after training and testing from test dataset?
One thing you can do is browse your prediction vector, get the indexes of &quot;1&quot; responses, and then check those indexes in y_test. if your y_test[index] is also a &quot;1&quot; class, then select the row by index in X_test
I tested this, it works for me. In my case, my X and y are pandas.DataFrame.
    import pandas as pd
    from sklearn.linear_model import LogisticRegression
    import numpy as np
    
    X_train = pd.read_csv(&quot;saves/cv_sets/X_train1.csv&quot;, sep=&quot;;&quot;, encoding=&quot;latin1&quot;)
    X_test = pd.read_csv(&quot;saves/cv_sets/X_test1.csv&quot;, sep=&quot;;&quot;, encoding=&quot;latin1&quot;)
    y_train = pd.read_csv(&quot;saves/cv_sets/y_train1.csv&quot;, sep=&quot;;&quot;, encoding=&quot;latin1&quot;)
    y_test = pd.read_csv(&quot;saves/cv_sets/y_test1.csv&quot;, sep=&quot;;&quot;, encoding=&quot;latin1&quot;)
    
    clf = LogisticRegression(class_weight=&quot;balanced&quot;, solver='lbfgs', C=0.1)
    model = clf.fit(X_train, y_train)
    
    pred = model.predict(X_test)
    
    pred1 = np.where(pred==1)
    
    TP_Indexes = []
    for k in pred1[0]:
        if(y_test.iloc[k][0] == 1):
            TP_Indexes.append(k)
    
    
    X_test_TP = X_test.iloc[TP_Indexes]