<jupyter_start><jupyter_text>Steps:    01- Introduction02- Import Main Libraries03- Load Data04- Clean data - Feature Engineering05- Exploratory data analysis06- Creating a Linear Regression Model07- Train Linear Regression Model08- Test Linear Regression Model09- Find Model Acuracy  01- Introduction **Graduate Admission 2**Predicting admission from important parametershttps://www.kaggle.com/mohansacharya/graduate-admissions 02- Import Main Libraries<jupyter_code>import numpy as np
# Powerful n-dimensional arrays. Numerical computing tools. Interoperable:

import pandas as pd
# python powerfull library used for data manipulating and data analysis:

import matplotlib.pyplot as plt
# mayplotlib is a ploting library we can use this to make awesome graphs:

import seaborn as sns
# seaborn also a ploting library we can use this to make awesome graphs:

%matplotlib inline
# %matplotlib inline sets the backend of matplotlib to the inline:
# Linear Regression Model 
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
import random
from sklearn import metrics<jupyter_output><empty_output><jupyter_text>03- Load Data<jupyter_code># Load data:

data = pd.read_csv('../input/graduate-admissions/Admission_Predict_Ver1.1.csv')
# showing first five rows of data:
data.head()<jupyter_output><empty_output><jupyter_text>04- Clean data - Feature Engineering<jupyter_code>## first we can chek our data info using info function:
data.info()
# first we check our columns name using df.columns function:
data.columns<jupyter_output><empty_output><jupyter_text>in our data set no any kind of missing values . but one thing is noteable that in our dataset"Serial No" column is useless this column get us error in model development session because here we want to predict the "Chance of admit" . and "chance of admit" not depend on your serial no so this column is useless for us.first we can remove this column using df.drop() so lets GO **now we can select 'Serial No.' column and remove this from our dataset.**<jupyter_code>data.drop('Serial No.',axis=1,inplace=True)

# axis = 1 because of its by default axis=0 . axis  = 0 means row wise , axis = 1 means column wise 
# so here we want to remove a column so we uset axis = 1 .

# inplace = True . mean we want this changing in our main dataset -<jupyter_output><empty_output><jupyter_text>**now you can see 'Serial No.' removed from our dataset.**<jupyter_code>data.columns<jupyter_output><empty_output><jupyter_text>05- Exploratory data analysis    First we can describe our data . using descriptive statics funtion help called **df.describe()**<jupyter_code>data.describe()

# using this function we can simply find [count,mean,std,min,25%,50%,75%,max]
data.corr()

# dataframe.corr() is used to find the pairwise correlation of all columns in the dataframe. 
# Any na values are automatically excluded. For any non-numeric data type columns in the dataframe 
# it is ignored.<jupyter_output><empty_output><jupyter_text>now we can find correlations between x and y variabls . in x variabls we have independent variables and in y variable we have dependent variables. we can change this corr table into a graph usng seaborn heatmap through for simply understanding.<jupyter_code>sns.heatmap(data.corr(),annot=True)

# now you can simple check out correlation between x and y variables:<jupyter_output><empty_output><jupyter_text>as u can see ['CGPA','GRE Score','TOEFL Score'] are strongly correlated with dependent variable - 'Chance of Admit '<jupyter_code>sns.distplot(data['CGPA'])<jupyter_output><empty_output><jupyter_text>CGPA VS Chance of Admit<jupyter_code>sns.regplot(x='CGPA',y='Chance of Admit ',data=data,ci=None)<jupyter_output><empty_output><jupyter_text>GRE Score VS Chance of Admit<jupyter_code>sns.regplot(x='GRE Score',y='Chance of Admit ',data=data,ci=None)<jupyter_output><empty_output><jupyter_text>TOEFL Score VS Chance of Admit<jupyter_code>sns.regplot(x='TOEFL Score',y='Chance of Admit ',data=data,ci=None)<jupyter_output><empty_output><jupyter_text>now we can use these columns in model for Chance of Admit prediction  06- Creating a Linear Regression Model now we can split our variables in 2 variables x and y :+  x = independent variables+ y = dependent variablesindependent variables are  [CGPA,GRE Score,TOEFL Score] we put these variables in X = [CGPA,GRE Score,TOEFL Score]dependent variable are  [Chance of Admit] now we go to predict this variabl so y = [Chance of Admit]<jupyter_code>x = data[['CGPA','GRE Score','TOEFL Score']]
y = data[['Chance of Admit ']]<jupyter_output><empty_output><jupyter_text>from sklearn.linear_model import LinearRegressionfrom sklearn.model_selection import train_test_splitimport randomthese libraries we can use for create our model . so we already import these libraries . lets start working on model.<jupyter_code># Split data for test and train the model.
x_train, x_test, y_train, y_test = train_test_split(x,y,random_state=0,test_size=.20)
# x shape
x.shape
# x_train shape 80% of data from x - 20% other data for test
x_train.shape
# x_train first five rows:
x_train.head()<jupyter_output><empty_output><jupyter_text>07- Train Linear Regression Model<jupyter_code>#object
linreg = LinearRegression()
# fiting our data for training
linreg.fit(x_train,y_train)<jupyter_output><empty_output><jupyter_text>08- Test Linear Regression Model<jupyter_code># our model is ready to predict y.
y_predict = linreg.predict(x_test)
# our model prediction
y_predict[:10]<jupyter_output><empty_output><jupyter_text>09- Find Model Acuracy : Evaluating the performance First we can compare y_predict and y_test<jupyter_code># y predict
y_predict[:10]
# y test
y_test[:10]<jupyter_output><empty_output><jupyter_text>from sklearn import metricswe can use this for find evaluating the performance<jupyter_code># from sklearn import metrics
# already imported
metrics.mean_absolute_error(y_test,y_predict)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08181666388378694, 'fraction_numerical': 0.010853230923359493, 'mean_word_length': 6.225572979493365, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '17', 'dir': 'jupyter-structured-clean-dedup', 'id': '248336', 'license': 'MIT', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1827, 'n_words': 654, 'path': 'graduate-admission-prediction-linearregression.ipynb', 'repo_name': 'DashTerence/Graddd', 'size': '5989'}