<jupyter_start><jupyter_text>Startups Profit Predictions Using Multiple Linear Regression  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>data= pd.read_csv('Startups.csv')
data.head()<jupyter_output><empty_output><jupyter_text>'State' is Categorical Variable Encoding the Categorical Variable 'State'<jupyter_code>from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder = LabelEncoder()
data['State'] = labelencoder.fit_transform(data['State'])
data['State'] = data['State'].astype('category')
data.head()
data.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 50 entries, 0 to 49
Data columns (total 5 columns):
R&D Spend          50 non-null float64
Administration     50 non-null float64
Marketing Spend    50 non-null float64
State              50 non-null category
Profit             50 non-null float64
dtypes: category(1), float64(4)
memory usage: 1.8 KB<jupyter_text>Splitting into Training & Test set<jupyter_code>X = data.iloc[:, :-1].values
y = data.iloc[:, 4].values
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 101)<jupyter_output><empty_output><jupyter_text>Fitting Multiple Linear Regression model to Training set<jupyter_code>from sklearn.linear_model import LinearRegression
lm = LinearRegression()
lm.fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>Predicting the Test set results<jupyter_code>y_pred = lm.predict(X_test)
y_pred<jupyter_output><empty_output><jupyter_text>Accuracy<jupyter_code>lm.score(X_test,y_test)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10221465076660988, 'fraction_numerical': 0.021578648495173196, 'mean_word_length': 7.350710900473934, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '565843', 'license': 'Apache-2.0', 'n_tokens_mistral': 636, 'n_tokens_neox': 598, 'n_words': 129, 'path': 'Profits of Startups.ipynb', 'repo_name': 'harshitkhare13/Startups-Profit-Predictions', 'size': '1761'}