33
loading...
This website collects cookies to deliver better user experience
1. Head to [Anaconda](https://www.anaconda.com/products/individual) Site
2. On the page download Anaconda for your operating system.
3. Install the Anaconda package to your computer.
4. Visit [https://downgit.github.io/](https://downgit.github.io/).
5. Paste `https://github.com/Daltonic/predictive/tree/main/model` in the field thereon and click on the download button.
6. Unzip **model.zip** and place contents in a unique folder. You should have something like this.
# Importing Libraries
import pandas as pd
import numpy as np
# Importing Dataset
dataset = pd.read_csv('hirable.csv')
# Cleaning up dataset
dataset = dataset.drop([
"sl_no",
"ssc_p",
"ssc_b",
"hsc_p",
"hsc_b",
"hsc_s",
"specialisation",
"salary",
"degree_t"
], axis=1)
dataset = dataset.rename(columns = {'degree_p': 'bsc', 'mba_p': 'msc'})
dataset['gender'] = dataset.gender.replace(['M', 'F'], [1, 2])
dataset['workex'] = dataset.workex.replace(['Yes', 'No'], [1, 0])
dataset['status'] = dataset.status.replace(['Placed', 'Not Placed'], [1, 0])
# Downscalling Method For BSc & MSc grades
def downscale(score):
return score/10/2
degrees = ['bsc', 'msc']
for col in degrees:
dataset[col] = downscale(dataset[col])
# Separating into dependent and independent variables
X = dataset.drop(['status'], axis=1)
y = dataset.status
# Splitting dataset into trainig and testing
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y,train_size=0.8,random_state=1)
# Fitting with random forest model
from sklearn.ensemble import RandomForestClassifier
model=RandomForestClassifier(n_estimators=100)
model.fit(X_train,y_train)
# Prediction and testing
y_pred=model.predict(X_test)
# Report and Accuracy Score
from sklearn import metrics
from sklearn.metrics import classification_report
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
print("Classification Report RF:\n",classification_report(y_test,y_pred))
# Model testing on new data
# [[gender, bsc, workex, etest_p, msc]]
# Sample 1
sample = np.array([[0, 2.9, 1, 78.50, 3.7]])
model.predict(sample)
# Sample 2
sample = np.array([[0, 2.9, 1, 78.50, 3.7]])
model.predict(sample)
# Saving model
import pickle
pickle.dump(model, open('hireable.pkl', 'wb'))
loaded_model = pickle.load(open('hireable.pkl', 'rb'))
result = loaded_model.score(X_test, y_test)
print(result)