<jupyter_start><jupyter_text>Importing Values<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns<jupyter_output><empty_output><jupyter_text>Importing Data set<jupyter_code>df = pd.read_csv("50_Startups.csv")
X = df.iloc[:,:-1].values
y = df.iloc[:,-1].values
X

y
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))
X<jupyter_output><empty_output><jupyter_text>Splitting the dataset into training set and testing 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.20,random_state = 1)<jupyter_output><empty_output><jupyter_text>X_train<jupyter_code>X_test<jupyter_output><empty_output><jupyter_text>Training  ML Model Using Random Forest Regressor<jupyter_code>from sklearn.ensemble import RandomForestRegressor
regressor = RandomForestRegressor()
regressor.fit(X_train,y_train)<jupyter_output><empty_output><jupyter_text>Prediction<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))
regressor.predict([[1,0,0,160000,30000,300000]])<jupyter_output><empty_output><jupyter_text>To Check R2_Score<jupyter_code>from sklearn.metrics import r2_score
r2_score(y_test,y_pred)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11555842479018721, 'fraction_numerical': 0.023240800516462233, 'mean_word_length': 12.135593220338983, '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': '121111', 'license': 'Apache-2.0', 'n_tokens_mistral': 616, 'n_tokens_neox': 587, 'n_words': 81, 'path': 'Profit Prediction Model.ipynb', 'repo_name': 'nitinvh/Profit-Prediction.github.ipy', 'size': '1549'}