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 necessary modules | |
| from sklearn.metrics import classification_report | |
| from sklearn.metrics import confusion_matrix | |
| # Create training and test set | |
| X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.4, random_state=42) | |
| # Instantiate a k-NN classifier: knn | |
| knn = KNeighborsClassifier(n_neighbors=6) |
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 necessary modules | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.model_selection import cross_val_score | |
| # Create a linear regression object: reg | |
| reg = LinearRegression() | |
| # Perform 3-fold CV | |
| cvscores_3 = cross_val_score(reg, X, y, cv=3) | |
| print(np.mean(cvscores_3)) |
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 Lasso | |
| from sklearn.linear_model import Lasso | |
| # Instantiate a lasso regressor: lasso | |
| lasso = Lasso(alpha=0.4, normalize=True) | |
| # Fit the regressor to the data | |
| lasso.fit(X, y) | |
| # Compute and print the coefficients |
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
| # /etc/systemd/system/oracle-rdbms.service | |
| # Ivan Kartik http://ivan.kartik.sk | |
| # Invoking Oracle scripts to start/shutdown Instances defined in /etc/oratab | |
| # and starts Listener | |
| [Unit] | |
| Description=Oracle Database(s) and Listener | |
| Requires=network.target | |
| [Service] |
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 necessary modules | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.metrics import mean_squared_error | |
| from sklearn.model_selection import train_test_split | |
| # Create training and test sets | |
| X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state=42) | |
| # Create the regressor: reg_all | |
| reg_all = LinearRegression() |
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 LinearRegression | |
| from sklearn.linear_model import LinearRegression | |
| # Create the regressor: reg | |
| reg = LinearRegression() | |
| # Create the prediction space | |
| prediction_space = np.linspace(min(X_fertility), max(X_fertility)).reshape(-1,1) | |
| # Fit the model to the data |
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
| sns.heatmap(df.corr(), square=True, cmap='RdYlGn') |
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 and pandas | |
| import numpy as np | |
| import pandas as pd | |
| # Read the CSV file into a DataFrame: df | |
| df = pd.read_csv('gapminder.csv') | |
| # Create arrays for features and target variable | |
| y = df['life'].values | |
| X = df['fertility'].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
| import matplotlib.pyplot as plt | |
| # Setup arrays to store train and test accuracies | |
| neighbors = np.arange(1, 9) | |
| train_accuracy = np.empty(len(neighbors)) | |
| test_accuracy = np.empty(len(neighbors)) | |
| # Loop over different values of k | |
| for i, k in enumerate(neighbors): | |
| # Setup a k-NN Classifier with k neighbors: knn |
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 necessary modules | |
| from sklearn.neighbors import KNeighborsClassifier | |
| from sklearn.model_selection import train_test_split | |
| # Create feature and target arrays | |
| X = digits.data | |
| y = digits.target | |
| # Split into training and test set | |
| X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state=42, stratify=y) |