"""
# 1) Initialization
"""
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

import os
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))

df= pd.read_csv('../input/salary/Salary.csv')
df.head()
"""
# 1) DataFrame Analyze
"""
df.info()
df.describe()
corrMatrix = df.corr()
sns.heatmap(corrMatrix, annot=True, cmap="coolwarm")
plt.show()
"""
# 2) Data vizualisation
"""
# Target distribution

sns.displot(df['Salary'],kde = True);
# Representation of Salary depending on Experience

plt.figure(figsize=(10,6))
plt.scatter(df['YearsExperience'],df['Salary'],s=50);
plt.title("Salary evolution with Years Experience")
plt.ylabel("Salary")
plt.xlabel("Experience")
plt.legend(["Years Experience"])
plt.show()
"""
# 3) Preprocessing
"""
# Define features and target

y = df['Salary']
x = df.drop(['Salary'], axis=1)
"""
# 4) Modeling
"""
from sklearn.linear_model import LinearRegression
lin_r = LinearRegression()
lin_r.fit(x,y)
lin_r.score(x,y)
"""
# 5) Prediction
"""
# Prediction for total experience
Experience = np.arange(1,40,1)

# Dataframe creation for LinearRegression model
df_predict_lin_r = pd.DataFrame({'Experience':Experience}) # initialisation of a dataframe for prediction
salary_lin_r = lin_r.predict(df_predict_lin_r) # predicted values
df_predict_lin_r.insert(1, "Salarypredicted", salary_lin_r) # merge with price predicted column

# Representation of prediction Salary depending on Experience
plt.figure(figsize=(15,10))
plt.scatter(df['YearsExperience'],df['Salary'],s=50);
plt.plot(df_predict_lin_r['Experience'],df_predict_lin_r['Salarypredicted'],c='orange');

plt.title("Salary evolution with Years Experience")
plt.ylabel("Salary")
plt.xlabel("Experience")
plt.show()