psf/black code formatting (#1277)

This commit is contained in:
William Zhang
2019-10-05 01:14:13 -04:00
committed by Christian Clauss
parent 07f04a2e55
commit 9eac17a408
291 changed files with 6014 additions and 4571 deletions

View File

@ -8,7 +8,7 @@ import pandas as pd
# Importing the dataset
script_dir = os.path.dirname(os.path.realpath(__file__))
dataset = pd.read_csv(os.path.join(script_dir, 'Position_Salaries.csv'))
dataset = pd.read_csv(os.path.join(script_dir, "Position_Salaries.csv"))
X = dataset.iloc[:, 1:2].values
y = dataset.iloc[:, 2].values
@ -26,7 +26,8 @@ y_train = sc_y.fit_transform(y_train)"""
# Fitting Random Forest Regression to the dataset
from sklearn.ensemble import RandomForestRegressor
regressor = RandomForestRegressor(n_estimators = 10, random_state = 0)
regressor = RandomForestRegressor(n_estimators=10, random_state=0)
regressor.fit(X, y)
# Predicting a new result
@ -35,9 +36,9 @@ y_pred = regressor.predict([[6.5]])
# Visualising the Random Forest Regression results (higher resolution)
X_grid = np.arange(min(X), max(X), 0.01)
X_grid = X_grid.reshape((len(X_grid), 1))
plt.scatter(X, y, color = 'red')
plt.plot(X_grid, regressor.predict(X_grid), color = 'blue')
plt.title('Truth or Bluff (Random Forest Regression)')
plt.xlabel('Position level')
plt.ylabel('Salary')
plt.scatter(X, y, color="red")
plt.plot(X_grid, regressor.predict(X_grid), color="blue")
plt.title("Truth or Bluff (Random Forest Regression)")
plt.xlabel("Position level")
plt.ylabel("Salary")
plt.show()