com.intel.analytics.bigdl.ppml.fl.psi.Utils Maven / Gradle / Ivy
/*
* Copyright 2016 The BigDL Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intel.analytics.bigdl.ppml.fl.psi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
public class Utils {
private static final Logger logger = LoggerFactory.getLogger(Utils.class);
// TODO for XGboost
public ArrayList> partition(int partitionNum, ArrayList dataset) {
return new ArrayList<>();
}
public static void shuffle(List array,int seed){
Collections.shuffle(array,new Random(seed));
}
public static String getRandomUUID() {
return UUID.randomUUID().toString();
}
public static int getRandomInt() {
Random rand = new Random();
return rand.nextInt();
}
public static int getTotalSplitNum(List list, int splitSize) {
return (int)Math.ceil((double)list.size() / splitSize);
}
public static List getSplit(List list, int split, int totalSplitNum, int splitSize) {
if (split < totalSplitNum - 1) {
return list.subList(split * splitSize, (split + 1) * splitSize);
} else {
return list.subList(split * splitSize, list.size());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy