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('Salaries.csv') | |
| X = dataset.iloc[:,1:2].values | |
| Y = dataset.iloc[:,2].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.linear_model import LinearRegression | |
| lin_reg = LinearRegression() | |
| lin_reg.fit(X,Y) |
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 , Y, color = 'red') | |
| plt.plot(X , lin_reg_2.predict( poly_reg.fit_transform(X)), color = 'blue') | |
| plt.title("Polynomial Regression") | |
| plt.xlabel("Position level") | |
| 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 , Y, color = 'red') | |
| plt.plot(X , lin_reg.predict(X), color = 'blue') | |
| plt.title("Linear Regression") | |
| plt.xlabel("Position level") | |
| 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
| from sklearn.metrics import confusion_matrix | |
| cm = confusion_matrix(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
| y_pred = classifier.predict(X_test) |
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 LogisticRegression | |
| classifier = LogisticRegression(random_state = 0) | |
| classifier.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
| from sklearn.preprocessing import StandardScaler | |
| sc = StandardScaler() | |
| X_train = sc.fit_transform(X_train) | |
| X_test = sc.transform(X_test) |
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
| dataset = pd.read_csv('Purchase.csv') | |
| X = dataset.iloc[:, [1, 2]].values | |
| y = dataset.iloc[:, 3].values |