<jupyter_start><jupyter_text>The Notebook is for understaning Multi Linear Regression This Data set is about 50 startups and there profit and loss statements  Importing the libraries<jupyter_code>import numpy as np 
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from sklearn.linear_model import LinearRegression<jupyter_output><empty_output><jupyter_text>Reading the dataset (50 startups with the statement of there profit and loss)<jupyter_code>dataset = pd.read_csv("./50_Startups.csv")
print (dataset.head())
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:,4].values<jupyter_output>R&D Spend  Administration  Marketing Spend       State     Profit
0  165349.20       136897.80        471784.10    New York  192261.83
1  162597.70       151377.59        443898.53  California  191792.06
2  153441.51       101145.55        407934.54     Florida  191050.39
3  144372.41       118671.85        383199.62    New York  182901.99
4  142107.34        91391.77        366168.42     Florida  166187.94<jupyter_text>As we can see, "State" column is the categorical data. Therefore it needs to be converted in mathematical representation. In order to convert the categorical data into the matematical representation oneHotEncoding will be used.<jupyter_code>labelencoder_X = LabelEncoder()
X[:, 3] = labelencoder_X.fit_transform(X[:,3])
onehotencoder = OneHotEncoder(categorical_features=[3])
X = onehotencoder.fit_transform(X).toarray()<jupyter_output>/usr/local/lib/python3.6/dist-packages/sklearn/preprocessing/_encoders.py:415: FutureWarning: The handling of integer data will change in version 0.22. Currently, the categories are determined based on the range [0, max(values)], while in the future they will be determined based on the unique values.
If you want the future behaviour and silence this warning, you can specify "categories='auto'".
In case you used a LabelEncoder before this OneHotEncoder to convert the categories to integers, then you can now use the OneHotEncoder directly.
  warnings.warn(msg, FutureWarning)
/usr/local/lib/python3.6/dist-packages/sklearn/preprocessing/_encoders.py:451: DeprecationWarning: The 'categorical_features' keyword is deprecated in version 0.20 and will be removed in 0.22. You can use the ColumnTransformer instead.
  "use the ColumnTransformer instead.", DeprecationWarning)<jupyter_text>Avoiding the dummy variable trap<jupyter_code>X = X[:, 1:]<jupyter_output><empty_output><jupyter_text>Splitting the data into training and testing set<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)<jupyter_output><empty_output><jupyter_text>With the above step of data splitting we are now ready for the multi-linear regression  For the purpose of Multi-linear-regression we will again use Linear Regressor because Multi-linear-regression is nothing but linear regression with multiple slope<jupyter_code>regressor = LinearRegression()
regressor.fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>From the above lie we have trained a multi-linear regresson and is ready for the testing<jupyter_code>y_pred = regressor.predict(X_test)
y_hat = pd.DataFrame(y_pred, columns=["calculated"])
y_act = pd.DataFrame(y_test, columns=["actual"])

output = pd.concat([y_act, y_hat], axis=1)
output<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07850521436848204, 'fraction_numerical': 0.05793742757821553, 'mean_word_length': 5.3010948905109485, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '481426', 'license': 'MIT', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1051, 'n_words': 337, 'path': 'regression/multi-linear-regression/.ipynb_checkpoints/Multi Linear Regression-checkpoint.ipynb', 'repo_name': 'akki6843/data_dive', 'size': '3452'}