<jupyter_start><jupyter_text>Company Profit Prediction  Importing the libraries<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd<jupyter_output><empty_output><jupyter_text>Importing the dataset<jupyter_code>dataset = pd.read_csv('Companies.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values<jupyter_output><empty_output><jupyter_text>Encoding categorical data<jupyter_code>from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
ct = ColumnTransformer(transformers=[('encoder', OneHotEncoder(), [3])], remainder='passthrough')
X = np.array(ct.fit_transform(X))<jupyter_output><empty_output><jupyter_text>Splitting the dataset into the Training set and Test set<jupyter_code>from sklearn.model_selection import train_test_split
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>Training the Multiple Linear Regression model on the Training set<jupyter_code>from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>Predicting the Test set results<jupyter_code>y_pred = regressor.predict(X_test)
np.set_printoptions(precision=2)
print(np.concatenate((y_pred.reshape(len(y_pred),1), y_test.reshape(len(y_test),1)),1))<jupyter_output>[[103015.2  103282.38]
 [132582.28 144259.4 ]
 [132447.74 146121.95]
 [ 71976.1   77798.83]
 [178537.48 191050.39]
 [116161.24 105008.31]
 [ 67851.69  81229.06]
 [ 98791.73  97483.56]
 [113969.44 110352.25]
 [167921.07 166187.94]]<jupyter_text>Making a single prediction (for example the profit of a company with R&D Spend = 160000, Administration Spend = 130000, Marketing Spend = 300000 and State = 'California')<jupyter_code>print(regressor.predict([[1, 0, 0, 160000, 130000, 300000]]))<jupyter_output>[181566.92]<jupyter_text>Therefore, our model predicts that the profit of a Californian startup which spent 160000 in R&D, 130000 in Administration and 300000 in Marketing is $ 181566,92.  Evaluating the Model Performance<jupyter_code>from sklearn.metrics import r2_score
r2_score(y_test, y_pred)<jupyter_output><empty_output><jupyter_text>Getting the final linear regression equation with the values of the coefficients<jupyter_code>print(regressor.coef_)
print(regressor.intercept_)<jupyter_output>[ 8.66e+01 -8.73e+02  7.86e+02  7.73e-01  3.29e-02  3.66e-02]
42467.52924854249
{'fraction_non_alphanumeric': 0.11008437123342708, 'fraction_numerical': 0.11329851345922057, 'mean_word_length': 7.7368421052631575, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '467112', 'license': 'MIT', 'n_tokens_mistral': 1100, 'n_tokens_neox': 900, 'n_words': 187, 'path': 'Startup-company-Profit-Prediction/Profit_Prediction.ipynb', 'repo_name': 'Abhishek-Aditya-bs/Machine-Learning-Projects', 'size': '2489'}