mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-09-28 21:45:27 +08:00
Re-enable the four scikit-learn machine-learning examples and the
neural-network perceptron that had been disabled (renamed to
.broken.txt / .DISABLED), and modernize them so they import and run
cleanly on current scikit-learn and pass the doctest CI:
machine_learning/gaussian_naive_bayes.py
machine_learning/random_forest_classifier.py
- Replace the removed sklearn.metrics.plot_confusion_matrix with
ConfusionMatrixDisplay.from_estimator (removed in scikit-learn 1.2).
- Drop the artificial time.sleep() calls.
machine_learning/gradient_boosting_regressor.py
machine_learning/random_forest_regressor.py
- Replace the removed load_boston dataset (removed in scikit-learn
1.2 for ethical reasons) with the bundled load_diabetes dataset so
the examples run offline.
- Avoid an unused-variable lint (RUF059).
neural_network/perceptron.py
- Use a dedicated seeded random.Random instance instead of the global
random state, so training is reproducible and thread-safe under the
parallel test runner.
- Cap training at epoch_number epochs so it always terminates even on
non-linearly-separable data (previously an unbounded while True).
- Have training() and sort() return their results instead of printing,
per the contribution guidelines, and update the doctests accordingly.
Requested by @cclauss in #8029; perceptron follow-up to #15206.