Created
October 19, 2019 18:05
-
-
Save MCMXCIII/cb479bc4b5fc26baaada5970771eda0a to your computer and use it in GitHub Desktop.
Regression for multiline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#FOR MULTILINES | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sasbornInstance | |
from sklearn.model_selection | |
import train_test_split | |
from sklearn.linear_model import LinearRegression | |
from sklearn import metrixcs | |
%matplotlib inline | |
dataset = pd.read_csv() | |
dataset.shape | |
dataset.describe | |
#clean null values | |
dataset.isnull().any() | |
dataset = dataset.fillna(method='ffill') | |
#divid the data | |
X= dataset[[]].values | |
y= dataset[].values | |
#Check average values of the column | |
plt.figure(figsize=(15,10)) | |
plt.tight_layout() | |
seabornInstance.distplot(dataset['qualitly']) | |
#spilt the data 80/20 for train/test | |
X_train,X_test, y_train, y_test = train_test_spilt(X,y, test_size=0.2, random_state=0) | |
#WE A TRAIN DEM | |
regressor = LinearRegression() | |
regressor.fit(X_train,, y_train) | |
#for multi-line looking for the most effecient CoEf | |
coeff_df = pd.DataFrame(regressor.coef_,X.columns,columns=['Coefficent']) | |
coeff_df | |
#guessing games | |
y_pred = regressor.predict(X_test) | |
#check the difference between actual value and predicited value | |
df = pd.DataFrame({'Actual': y_test, 'Predicted': y_pred}) | |
df1 = df.head(25) | |
#plot this | |
df1.plot(kind='bar' ,figsize=(10,8)) | |
plt.grid(which='major', linestyle='-', linewidth='0.5',color='green') | |
plt.grid(which='minor'),linestyle='-', linewidth='0.5',color='black') | |
plt.show() | |
''' | |
#evaluate the performance of the algo | |
print('Mean Absolute Error:', 0.0) | |
print('Mean squared error':, 0.0) | |
print('Root Mean Sqaured Error': 0.0) | |
''' | |
#Done? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment