Posts

Showing posts from October, 2022

Code

[09/11, 7:29 am] Reva Chandan: import numpy as np  import pandas as pd  import pandas as pd df = pd.read_csv('Salary.csv') print(df.to_string())  import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression df.head() X = df.iloc[:, :-1].values    # Features => Years of experience => Independent Variable y = df.iloc[:, -1].values     # Target => Salary => Dependent Variable X y # divide the dataset in some amount of training and testing data from sklearn.model_selection import train_test_split import sklearn.metrics as sm # random_state => seed value used by random number generator X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) from sklearn.linear_model import LinearRegression model = LinearRegression() model.fit(X_train, y_train) predictions = model.predict(X_test) predictions y_test import seaborn as sns sns.distplot(predictions-y_test) plt.scatter(X_train, y_train, color='red') plt.pl...