Coder Social home page Coder Social logo

Comments (3)

richard-lane avatar richard-lane commented on July 2, 2024 1

here's the diff needed to replace numpy.float and numpy.int with float and int respectively:

diff --git a/hep_ml/commonutils.py b/hep_ml/commonutils.py
index b888c69..bf46e75 100755
--- a/hep_ml/commonutils.py
+++ b/hep_ml/commonutils.py
@@ -222,7 +222,7 @@ def compute_knn_indices_of_same_class(X, y, n_neighbours=50):
     :rtype numpy.array, shape [len(dataframe), knn], each row contains indices of closest signal events
     """
     assert len(X) == len(y), "different size"
-    result = numpy.zeros([len(X), n_neighbours], dtype=numpy.int)
+    result = numpy.zeros([len(X), n_neighbours], dtype=int)
     for label in set(y):
         is_signal = y == label
         label_knn = compute_knn_indices_of_signal(X, is_signal, n_neighbours)
diff --git a/hep_ml/losses.py b/hep_ml/losses.py
index e1e079a..89fc18f 100644
--- a/hep_ml/losses.py
+++ b/hep_ml/losses.py
@@ -727,7 +727,7 @@ class AbstractFlatnessLossFunction(AbstractLossFunction):
 
     def _compute_fl_derivatives(self, y_pred):
         y_pred = numpy.ravel(y_pred)
-        neg_gradient = numpy.zeros(len(self.y), dtype=numpy.float)
+        neg_gradient = numpy.zeros(len(self.y), dtype=float)
 
         for label in self.uniform_label:
             label_mask = self.label_masks[label]
diff --git a/hep_ml/metrics_utils.py b/hep_ml/metrics_utils.py
index b705f7a..e00c7e2 100644
--- a/hep_ml/metrics_utils.py
+++ b/hep_ml/metrics_utils.py
@@ -67,7 +67,7 @@ def compute_bin_indices(X_part, bin_limits=None, n_bins=20):
             variable_data = X_part[:, variable_index]
             bin_limits.append(numpy.linspace(numpy.min(variable_data), numpy.max(variable_data), n_bins + 1)[1: -1])
 
-    bin_indices = numpy.zeros(len(X_part), dtype=numpy.int)
+    bin_indices = numpy.zeros(len(X_part), dtype=int)
     for axis, bin_limits_axis in enumerate(bin_limits):
         bin_indices *= (len(bin_limits_axis) + 1)
         bin_indices += numpy.searchsorted(bin_limits_axis, X_part[:, axis])
diff --git a/tests/test_gradientboosting.py b/tests/test_gradientboosting.py
index fbec64a..c77ac68 100644
--- a/tests/test_gradientboosting.py
+++ b/tests/test_gradientboosting.py
@@ -112,7 +112,7 @@ def test_constant_fitting(n_samples=1000, n_features=5):
     Testing if initial constant fitted properly
     """
     X, y = generate_sample(n_samples=n_samples, n_features=n_features)
-    y = y.astype(numpy.float) + 1000.
+    y = y.astype(float) + 1000.
     for loss in [MSELossFunction(), losses.MAELossFunction()]:
         gb = UGradientBoostingRegressor(loss=loss, n_estimators=10)
         gb.fit(X, y)

(i didn't run the tests because I couldn't get them to immediately work)

from hep_ml.

arogozhnikov avatar arogozhnikov commented on July 2, 2024

(i didn't run the tests because I couldn't get them to immediately work)

Those are all safe changes, can you open PR anyways?

from hep_ml.

arogozhnikov avatar arogozhnikov commented on July 2, 2024

Merged, thanks Richard!

from hep_ml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.