How can I check the correlation between features and target variable? I am trying to build a Regression model and I am looking for a way to check whether there's any correlation between features and target variables?

This is my sample dataset

     Loan_ID    Gender  Married Dependents  Education Self_Employed ApplicantIncome\    

0   LP001002    Male    No         0        Graduate      No            5849    
1   LP001003    Male    Yes        1        Graduate      No            4583    
2   LP001005    Male    Yes        0        Graduate     Yes            3000    
3   LP001006    Male    Yes        0        Not Graduate  No            2583    
4   LP001008    Male    No         0        Graduate      No            6000    

CoapplicantIncome  LoanAmount   Loan_Amount_Term  Credit_History Area Loan_Status
      0.0               123          360.0            1.0        Urban     Y
      1508.0          128.0          360.0            1.0        Rural     N
      0.0              66.0          360.0            1.0        Urban     Y
      2358.0          120.0          360.0            1.0        Urban     Y
      0.0             141.0          360.0            1.0        Urban     Y


I am trying to predict LoanAmount column based on the features available above.

I just want to see if there's a correlation between the features and target variable. I tried LinearRegression, GradientBoostingRegressor and I'm hardly getting a accuracy of around 0.30 - 0.40%. 

Any suggestions on algorithms, params etc that I should use for better prediction?
Your data can be put into a pandas DataFrame using

import pandas as pd
data = {'Loan ID': ['LP001002', 'LP001003', 'LP001005', 'LP001006', 'LP001008'],
        'Married': ['No', 'Yes', 'Yes', 'Yes', 'No'],
        'Dependents': [0, 1, 0, 0, 0],
        'Education': ['Graduate', 'Graduate', 'Graduate', 'Not Graduate', 'Graduate'],
        'Self_Employed': ['No', 'No', 'Yes', 'No', 'No'],
        'Income': [5849, 4583, 3000, 2583, 6000],
        'Coapplicant Income': [0, 1508, 0, 2358, 0],
        'LoanAmount': [123, 128, 66, 120, 141],
        'Area': ['Urban', 'Rural', 'Urban', 'Urban', 'Urban'],
        'Loan Status': ['Y', 'N', 'Y', 'Y', 'Y']} 
df = pd.DataFrame(data)


Now to get a correlation we need to convert our categorical features to numerical ones. Of course the choice of order will affect the correlation but luckily all of our categories seem to be binary. If this is not the case you will need to devise a custom ordering.

df = pd.DataFrame(data)
df['Married'] =df['Married'].astype('category').cat.codes
df['Education'] =df['Education'].astype('category').cat.codes
df['Self_Employed'] =df['Self_Employed'].astype('category').cat.codes
df['Area'] =df['Area'].astype('category').cat.codes
df['Loan Status'] =df['Loan Status'].astype('category').cat.codes


Now we can get the correlation between the 'LoanAmount' and all the other features.

df[df.columns[1:]].corr()['LoanAmount'][:]






Now using some machine learning on this data is not likely to work. There just is not sufficient data to extract some relevant information between your large number of features and the loan amount.

You need at at least 10 times more instances than features in order to expect to get some good results.



To only obtain the correlation between a feature and a subset of the features you can do 

df[['Income', 'Education', 'LoanAmount']].corr()['LoanAmount'][:]


This will take a subset of the DataFrame and then apply the same corr() function as above. Make sure that the subset of columns selected includes the column with which you want to calculate the correlation, in this example that's 'LoanAmount'.