Travis CI: Add pytest --doctest-modules machine_learning (#1016)

* Travis CI: Add pytest --doctest-modules neural_network

Fixes #987
```
neural_network/perceptron.py:123: in <module>
    sample.insert(i, float(input('value: ')))
../lib/python3.7/site-packages/_pytest/capture.py:693: in read
    raise IOError("reading from stdin while output is captured")
E   OSError: reading from stdin while output is captured
-------------------------------------------------------------------------------- Captured stdout --------------------------------------------------------------------------------
('\nEpoch:\n', 399)
------------------------

value:
```

* Adding fix from #1056 -- thanks @QuantumNovice

* if __name__ == '__main__':

* pytest --ignore=virtualenv  # do not test our dependencies
This commit is contained in:
Christian Clauss
2019-08-10 22:48:00 +02:00
committed by GitHub
parent 91c3c98d2b
commit 36684db278
5 changed files with 16 additions and 135 deletions

View File

@ -1,12 +1,14 @@
# Random Forest Regression
# Importing the libraries
import os
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Position_Salaries.csv')
script_dir = os.path.dirname(os.path.realpath(__file__))
dataset = pd.read_csv(os.path.join(script_dir, 'Position_Salaries.csv'))
X = dataset.iloc[:, 1:2].values
y = dataset.iloc[:, 2].values
@ -28,7 +30,7 @@ regressor = RandomForestRegressor(n_estimators = 10, random_state = 0)
regressor.fit(X, y)
# Predicting a new result
y_pred = regressor.predict(6.5)
y_pred = regressor.predict([[6.5]])
# Visualising the Random Forest Regression results (higher resolution)
X_grid = np.arange(min(X), max(X), 0.01)
@ -38,4 +40,4 @@ 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()
plt.show()