<jupyter_start><jupyter_text>Import Libraries<jupyter_code>import warnings
warnings.filterwarnings('ignore')
import csv
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import accuracy_score, log_loss, confusion_matrix
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import r2_score<jupyter_output><empty_output><jupyter_text>Dataset<jupyter_code>allen1 = pd.read_csv("Dataset1.csv")
allen3 = pd.read_csv("Dataset2.csv")
allen1.head()
allen3.head()
allen1.describe()
allen3.describe()<jupyter_output><empty_output><jupyter_text>Dataset.csv - Label Encoding   Company<jupyter_code>l1 = preprocessing.LabelEncoder()
f1 = l1.fit_transform(allen1['company']) 
f1 = pd.DataFrame(data=f1, columns=['company'])<jupyter_output><empty_output><jupyter_text>Area<jupyter_code>l2 = preprocessing.LabelEncoder()
f2 = l2.fit_transform(allen1['Area of work']) 
f2 = pd.DataFrame(data=f2, columns=['Area of work'])<jupyter_output><empty_output><jupyter_text>Gender<jupyter_code>l3 = preprocessing.LabelEncoder()
f3 = l3.fit_transform(allen1['Gender']) 
f3 = pd.DataFrame(data=f3, columns=['Gender'])<jupyter_output><empty_output><jupyter_text>Qualification<jupyter_code>l4 = preprocessing.LabelEncoder()
f4 = l4.fit_transform(allen1['Qualification']) 
f4 = pd.DataFrame(data=f4, columns=['Qualification'])<jupyter_output><empty_output><jupyter_text>Updation<jupyter_code>allen1['company'] = f1['company']
allen1['Area of work'] = f2['Area of work']
allen1['Gender'] = f3['Gender']
allen1['Qualification'] = f4['Qualification']<jupyter_output><empty_output><jupyter_text>Dataset.csv - MinMaxScaler<jupyter_code>ms = MinMaxScaler()
columns = ['Age ','no of experience in years']
allen1[columns] = ms.fit_transform(allen1[columns])
allen1.head()<jupyter_output><empty_output><jupyter_text>Dataset.csv - Index<jupyter_code>print(list(l1.inverse_transform([0,1,2,3,4,5,6,7])))
print(list(l2.inverse_transform([0,1,2,3])))
print(list(l3.inverse_transform([0,1])))
print(list(l4.inverse_transform([0,1])))<jupyter_output>['B.E', 'M.E']<jupyter_text>Training<jupyter_code>x = allen1.drop(['S.No','salary package per month'],axis=1)
x.head()
y = allen1['salary package per month']
xtrain, xtest, ytrain, ytest = train_test_split(x,y,test_size=0.48,random_state=1)
model = LinearRegression()
model.fit(xtrain,ytrain)
p = model.predict(xtest)
print(r2_score(ytest, p))<jupyter_output>0.8081462969225229<jupyter_text>Test.csv - Creation Assignment Q1<jupyter_code>companies = list(l1.inverse_transform([0,1,2,3,4,5,6,7]))
allen2 = 0
allen2 = pd.DataFrame(columns=['company','Age ','Gender','Qualification','no of experience in years','Area of work'])
for i in range(0,len(companies)):
    init = {"company": companies[i], 
            "Age ": 35,
            "Gender": "F",
            "Qualification": "B.E",
            "no of experience in years": 12,
            "Area of work": "cloud server management"
    }
    allen2 = allen2.append(init, ignore_index=True)
print(allen2.to_string())<jupyter_output>company Age  Gender Qualification no of experience in years             Area of work
0          ABBB   35      F           B.E                        12  cloud server management
1         Bashh   35      F           B.E                        12  cloud server management
2          Link   35      F           B.E                        12  cloud server management
3          Oxon   35      F           B.E                        12  cloud server management
4           TSC   35      F           B.E                        12  cloud server management
5  neuromorphic   35      F           B.E                        12  cloud server management
6          palm   35      F           B.E                        12  cloud server management
7      penguin    35      F           B.E                        12  cloud server management<jupyter_text>Test.csv - Label Encoding  Company<jupyter_code>l5 = preprocessing.LabelEncoder()
f5 = l5.fit_transform(allen2['company']) 
f5 = pd.DataFrame(data=f5, columns=['company'])<jupyter_output><empty_output><jupyter_text>Area<jupyter_code>l6 = preprocessing.LabelEncoder()
f6 = l6.fit_transform(allen2['Area of work']) 
f6 = pd.DataFrame(data=f6, columns=['Area of work'])<jupyter_output><empty_output><jupyter_text>Gender<jupyter_code>l7 = preprocessing.LabelEncoder()
f7 = l7.fit_transform(allen2['Gender']) 
f7 = pd.DataFrame(data=f7, columns=['Gender'])<jupyter_output><empty_output><jupyter_text>Qualification<jupyter_code>l8 = preprocessing.LabelEncoder()
f8 = l8.fit_transform(allen2['Qualification']) 
f8 = pd.DataFrame(data=f8, columns=['Qualification'])<jupyter_output><empty_output><jupyter_text>Updation<jupyter_code>allen2['company'] = f5['company']
allen2['Area of work'] = f6['Area of work']
allen2['Gender'] = f7['Gender']
allen2['Qualification'] = f8['Qualification']<jupyter_output><empty_output><jupyter_text>Test.csv - MinMaxScaler<jupyter_code>ms = MinMaxScaler()
columns = ['Age ','no of experience in years']
allen2[columns] = ms.fit_transform(allen2[columns])<jupyter_output><empty_output><jupyter_text>Test.csv - Prediction<jupyter_code>allen2.head(8)
p2 = model.predict(allen2)
allen2['salary'] = p2
allen2.head(8)<jupyter_output><empty_output><jupyter_text>Test.csv - Index<jupyter_code>print(l5.inverse_transform(f5['company']))
allen2['company'] = l5.inverse_transform(f5['company'])
print(l6.inverse_transform(f6['Area of work']))
allen2['Area of work'] = l6.inverse_transform(f6['Area of work'])
print(l7.inverse_transform(f7['Gender']))
allen2['Gender'] = l7.inverse_transform(f7['Gender'])
print(l8.inverse_transform(f8['Qualification']))
allen2['Qualification'] = l8.inverse_transform(f8['Qualification'])
print(ms.inverse_transform(allen2[columns]))
allen2[columns] = ms.inverse_transform(allen2[columns])
allen2.head(8)<jupyter_output><empty_output><jupyter_text>Test.csv - Save<jupyter_code>allen2.to_csv('Test.csv')<jupyter_output><empty_output><jupyter_text>Validation.csv - Creation Assignment Q2<jupyter_code>allen3 = pd.read_csv("Dataset2.csv")
allen4 = pd.read_csv("Dataset2.csv")
allen3.head(8)
allen3["company"] = companies[0]
for i in range(1,len(companies)):
    allen4["company"] = companies[i]
    allen3 = pd.concat([allen3, allen4], ignore_index = True)
allen3.head(64)<jupyter_output><empty_output><jupyter_text>Validation.csv - Label Encoding  Company<jupyter_code>l9 = preprocessing.LabelEncoder()
f9 = l9.fit_transform(allen3['company']) 
f9 = pd.DataFrame(data=f9, columns=['company'])<jupyter_output><empty_output><jupyter_text>Area<jupyter_code>l10 = preprocessing.LabelEncoder()
f10 = l10.fit_transform(allen3['Area of work']) 
f10 = pd.DataFrame(data=f10, columns=['Area of work'])<jupyter_output><empty_output><jupyter_text>Gender<jupyter_code>l11 = preprocessing.LabelEncoder()
f11 = l11.fit_transform(allen3['Gender']) 
f11 = pd.DataFrame(data=f11, columns=['Gender'])<jupyter_output><empty_output><jupyter_text>Qualification<jupyter_code>l12 = preprocessing.LabelEncoder()
f12 = l12.fit_transform(allen3['Qualification']) 
f12 = pd.DataFrame(data=f12, columns=['Qualification'])<jupyter_output><empty_output><jupyter_text>Updation<jupyter_code>allen3['company'] = f9['company']
allen3['Area of work'] = f10['Area of work']
allen3['Gender'] = f11['Gender']
allen3['Qualification'] = f12['Qualification']<jupyter_output><empty_output><jupyter_text>Validation.csv - MinMaxScaler<jupyter_code>ms = MinMaxScaler()
columns = ['Age ','no of experience in years']
allen3[columns] = ms.fit_transform(allen3[columns])<jupyter_output><empty_output><jupyter_text>Validation.csv - Prediction<jupyter_code>allen3 = allen3.drop(['S.No','person','salary package per month'],axis=1)
allen3 = allen3[['company','Age ','Gender','Qualification','no of experience in years','Area of work']]
allen3.head(64)
p3 = model.predict(allen3)
allen3['salary'] = p3
allen3.head(64)
print(allen3.to_string())<jupyter_output>company      Age   Gender  Qualification  no of experience in years  Area of work         salary
0         0  0.000000       0              0                      0.000             2   54824.880146
1         0  0.461538       1              0                      0.500             1  208400.793430
2         0  0.615385       0              1                      0.375             0  145345.375236
3         0  1.000000       1              1                      1.000             1  352574.982362
4         0  0.538462       0              1                      0.500             0  214053.480747
5         0  0.384615       0              0                      0.500             1  228060.728687
6         0  0.307692       1              0                      0.500             0  240177.728006
7         0  0.153846       0              1                      0.000             0   48344.838040
8         1  0.000000       0              0                      0.000             2   487[...]<jupyter_text>Validation.csv - Index<jupyter_code>allen3['company'] = l9.inverse_transform(f9['company'])
allen3['Area of work'] = l10.inverse_transform(f10['Area of work'])
allen3['Gender'] = l11.inverse_transform(f11['Gender'])
allen3['Qualification'] = l12.inverse_transform(f12['Qualification'])
allen3[columns] = ms.inverse_transform(allen3[columns])
allen3.head(64)
print(allen3.to_string())<jupyter_output>company  Age  Gender Qualification  no of experience in years             Area of work         salary
0           ABBB  22.0      F           B.E                        1.0              programming   54824.880146
1           ABBB  28.0      M           B.E                        5.0      predictive analysis  208400.793430
2           ABBB  30.0      F           M.E                        4.0  cloud server management  145345.375236
3           ABBB  35.0      M           M.E                        9.0      predictive analysis  352574.982362
4           ABBB  29.0      F           M.E                        5.0  cloud server management  214053.480747
5           ABBB  27.0      F           B.E                        5.0      predictive analysis  228060.728687
6           ABBB  26.0      M           B.E                        5.0  cloud server management  240177.728006
7           ABBB  24.0      F           M.E                        1.0  cloud server management   48344.838040
8[...]<jupyter_text>Validation.csv - Save<jupyter_code>allen3.to_csv('Validation.csv')<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup