Answers ( 2 )

  1. # First import the necessary libraries
    import pandas as pd
    from sklearn.model_selection import train_test_split

    # Load the Dataset
    data = pd.read_csv(‘filename.csv’)

    # create target variable and features – suppose your target variable is Rent
    y = data.Rent
    x = data.drop(‘Rent’,axis=1)

    # create the train and test split
    x_train,x_test,y_train,y_test = train_test_split(x,y,test_size = 0.3, random_state=42)

    # The ordering of variables is important in the above line of code
    # test_size will keep 30% data in the test set
    # random_state will help in keeping the same samples in the train and test set.

  2. Sorry it a private answer.

Leave an answer

Browse
Browse