This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dataset = pd.read_csv('Salary_Data.csv') | |
X = dataset.iloc[:,:-1].values | |
Y = dataset.iloc[:,1].values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.model_selection import train_test_split | |
X_train,X_test,Y_train,Y_test = train_test_split(X,Y, test_size=0.25, random_state = 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.linear_model import LinearRegression | |
from sklearn.metrics import r2_score | |
regressor = LinearRegression() | |
regressor.fit(X_train,Y_train) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y_pred = regressor.predict(X_test) | |
print(r2_score(Y_test,y_pred)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.scatter(X_train,Y_train, color = 'red') | |
plt.plot(X_train , regressor.predict(X_train), color='blue') | |
plt.title('Salary vs Experience') | |
plt.xlabel('Years of Experience') | |
plt.ylabel('Salary') | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.scatter(X_test,Y_test, color = 'red') | |
plt.plot(X_train , regressor.predict(X_train), color='blue') | |
plt.title('Salary vs Experience') | |
plt.xlabel('Years of Experience') | |
plt.ylabel('Salary') | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nltk | |
import urllib | |
import bs4 as bs | |
import pandas as pd | |
import re | |
from nltk.corpus import stopwords |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "" | |
for paragraph in soup.find_all('p'): | |
text += paragraph.text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = re.sub(r'\[[0-9]*\]',' ',text) | |
text = re.sub(r'\s+',' ',text) | |
text = text.lower() | |
text = re.sub(r'\d',' ',text) | |
text = re.sub(r'\s+',' ',text) |
OlderNewer