<jupyter_start><jupyter_text>Here we are using the find S Algorithm to predict the values. Here we are storing the training and testing data in a list and then implementing the Algorithm. In this model we are considering the features city,industry vertical and amount from the traing data to predict the amount for the given test data containg the features city,industry vertical .<jupyter_code>import pandas as pd
import numpy as np
from sklearn.preprocessing import LabelEncoder
import random
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn import metrics
from statistics import mean



fullData = pd.read_csv("/Users/jeshwanth/Desktop/Final_startup_funding.csv");#Importing file
#Dropping irrelevant columns
fullData = fullData.drop('Startup Name', 1);
fullData = fullData.drop('Investors Name', 1);
fullData = fullData.drop('Date dd/mm/yyyy', 1);



train, test = fullData[0:int(len(fullData)*0.7)], fullData[int(len(fullData)*0.7):]#Splitting the dataset to tran and test wrt a ratio of 70:30

train['Type']='Train';#Classifying the values if they are used for training by introducing a new feature called type
test['Type']='Test';#Classifying the values if they are used for testing by introducing a new feature called type

ID_col = ['Sr No']#Columns that only have id's
target_col = ["Amount"]#Our target dataframe

other_col=['Type'] #Test and Train Data set identifier
cols = ['Industry Vertical','City  Location','InvestmentnType'];#All categorial value columns 

for var in cols:#Label encoding the categorical columns
 number = LabelEncoder()
 fullData[var] = number.fit_transform(fullData[var].astype('str'))#Converting to a integer

y= fullData.Amount#Dataframe having only Amount
 

x=fullData.drop('Amount',axis=1)#Dataframe having all features except amount
 
#splitting
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2)
 
#printing shapes of testing and training sets :


random.seed(1000)
rf = RandomForestClassifier(n_estimators=1000, random_state=0)#Using RandomForestClassifier with 1000 trees and random_state set to 0 
rf.fit(x_train, y_train);#Fitting the data
y_pred = rf.predict(x_test)#Predicting the outcome with x_test


#y_pred = np.array(y_pred)#Converting to a numpy array
y_pred = [abs(k) for k in y_pred]#Converting negative to positive numbers




#Root Mean Squared Error
print('Root Mean Squared Error:', np.sqrt(metrics.mean_squared_error(y_test, y_pred)));

#Mean Absolute Error
print('Mean Absolute Error:', metrics.mean_absolute_error(y_test, y_pred));

#Mean Squared Error
print('Mean Squared Error:', metrics.mean_squared_error(y_test, y_pred));<jupyter_output>/var/folders/b2/0fc3pcn131b29kny5l2j9mt40000gn/T/ipykernel_10679/1983828700.py:14: FutureWarning: In a future version of pandas all arguments of DataFrame.drop except for the argument 'labels' will be keyword-only
  fullData = fullData.drop('Startup Name', 1);
/var/folders/b2/0fc3pcn131b29kny5l2j9mt40000gn/T/ipykernel_10679/1983828700.py:15: FutureWarning: In a future version of pandas all arguments of DataFrame.drop except for the argument 'labels' will be keyword-only
  fullData = fullData.drop('Investors Name', 1);
/var/folders/b2/0fc3pcn131b29kny5l2j9mt40000gn/T/ipykernel_10679/1983828700.py:16: FutureWarning: In a future version of pandas all arguments of DataFrame.drop except for the argument 'labels' will be keyword-only
  fullData = fullData.drop('Date dd/mm/yyyy', 1);
/var/folders/b2/0fc3pcn131b29kny5l2j9mt40000gn/T/ipykernel_10679/1983828700.py:22: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexe[...]<jupyter_text>A random forest is a machine learning technique thats used to solve regression and classification problems. Here we are performing RandomForests to find the amount for our given tyest data. I achieved this by label encoding the categorical features and then fitting the model with the relevant features and our goal is to predict the amount for the given features.<jupyter_code>import pandas as pd
import numpy as np
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn import metrics
from statistics import mean
from sklearn.linear_model import LinearRegression



fullData = pd.read_csv("/Users/jeshwanth/Desktop/Final_startup_funding.csv");#Importing file
#Dropping irrelevant columns
fullData = fullData.drop('Startup Name', 1);
fullData = fullData.drop('Investors Name', 1);
fullData = fullData.drop('Date dd/mm/yyyy', 1);



train, test = fullData[0:int(len(fullData)*0.7)], fullData[int(len(fullData)*0.7):]#Splitting the dataset to tran and test wrt a ratio of 70:30

train['Type']='Train';#Classifying the values if they are used for training by introducing a new feature called type
test['Type']='Test';#Classifying the values if they are used for testing by introducing a new feature called type

ID_col = ['Sr No']#Columns that only have id's
target_col = ["Amount"]#Our target dataframe

other_col=['Type'] #Test and Train Data set identifier
cols = ['Industry Vertical','City  Location','InvestmentnType'];#All categorial value columns 

for var in cols:#Label encoding the categorical columns
 number = LabelEncoder()
 fullData[var] = number.fit_transform(fullData[var].astype('str'))#Converting to a integer

y= fullData.Amount#Dataframe having only Amount
 

x=fullData.drop('Amount',axis=1)#Dataframe having all features except amount
 
#splitting for testing and traing
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2)
 
#Creating the linear model
model = LinearRegression()
#Fitting the linear model with relevant features
model.fit(x_train,y_train);
#Predicting using x_test which we got by splitting
y_pred = model.predict(x_test)

y_pred = np.array(y_pred)#Converting to a numpy array
y_pred = [abs(k) for k in y_pred]#Converting negative to positive numbers





#Root Mean Squared Error
print('Root Mean Squared Error:', np.sqrt(metrics.mean_squared_error(y_test, y_pred)));

#Mean Absolute Error
print('Mean Absolute Error:', metrics.mean_absolute_error(y_test, y_pred));

#Mean Squared Error
print('Mean Squared Error:', metrics.mean_squared_error(y_test, y_pred));<jupyter_output>Root Mean Squared Error: 80983974.9173598
Mean Absolute Error: 24937343.2512565
Mean Squared Error: 6558404193415561.0
{'fraction_non_alphanumeric': 0.0894917368256938, 'fraction_numerical': 0.03523542251325226, 'mean_word_length': 6.348224513172966, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '247874', 'license': 'MIT', 'n_tokens_mistral': 2191, 'n_tokens_neox': 1957, 'n_words': 657, 'path': 'Jupyter files/Models.ipynb', 'repo_name': 'Suhasr76/Startup-funding-prediction', 'size': '6414'}