├── .gitignore ├── LICENSE ├── README.md ├── assembly ├── pom.xml └── src │ └── main │ └── assembly │ ├── assembly.xml │ ├── bin │ ├── dump.sh │ ├── start-client.sh │ ├── start-coordinator.sh │ ├── start-manager.sh │ ├── start-worker.sh │ ├── stop-service.sh │ └── stop.sh │ ├── conf │ ├── client.properties │ ├── coordinator.properties │ ├── logback.xml │ ├── manager.properties │ └── worker.properties │ └── readme │ ├── enviroment.txt │ └── readme.txt ├── client ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── jdt │ │ │ └── fedlearn │ │ │ └── client │ │ │ ├── HttpApp.java │ │ │ ├── cache │ │ │ ├── InferenceDataCache.java │ │ │ ├── ModelCache.java │ │ │ └── TrainDataCache.java │ │ │ ├── constant │ │ │ └── Constant.java │ │ │ ├── dao │ │ │ ├── CsvReader.java │ │ │ ├── DataReader.java │ │ │ ├── EmptyReader.java │ │ │ ├── HdfsReader.java │ │ │ ├── HttpReader.java │ │ │ ├── IdMatchProcessor.java │ │ │ ├── ModelDao.java │ │ │ └── MysqlReader.java │ │ │ ├── entity │ │ │ ├── Feature.java │ │ │ ├── HttpData.java │ │ │ ├── HttpResp.java │ │ │ ├── inference │ │ │ │ ├── FetchRemote.java │ │ │ │ ├── InferencePrepareRes.java │ │ │ │ ├── InferenceRequest.java │ │ │ │ ├── PutRemote.java │ │ │ │ └── SingleInference.java │ │ │ ├── local │ │ │ │ ├── AuthToken.java │ │ │ │ ├── ConfigQueryReq.java │ │ │ │ ├── ConfigUpdateReq.java │ │ │ │ ├── InferenceStart.java │ │ │ │ ├── SingleConfig.java │ │ │ │ └── UpdateDataSource.java │ │ │ ├── prepare │ │ │ │ ├── KeyGenerateRequest.java │ │ │ │ └── MatchRequest.java │ │ │ ├── source │ │ │ │ ├── ClientConfig.java │ │ │ │ ├── CsvSourceConfig.java │ │ │ │ ├── DataSourceConfig.java │ │ │ │ ├── DbConfig.java │ │ │ │ ├── DbSourceConfig.java │ │ │ │ ├── DubboSourceConfig.java │ │ │ │ ├── EmptySourceConfig.java │ │ │ │ ├── HdfsSourceConfig.java │ │ │ │ └── HttpSourceConfig.java │ │ │ ├── system │ │ │ │ └── Metadata.java │ │ │ └── train │ │ │ │ ├── QueryProgress.java │ │ │ │ └── TrainRequest.java │ │ │ ├── exception │ │ │ ├── ForbiddenException.java │ │ │ ├── NotAcceptableException.java │ │ │ ├── ServerNotFoundException.java │ │ │ └── UnauthorizedException.java │ │ │ ├── multi │ │ │ └── TrainProcess.java │ │ │ ├── netty │ │ │ ├── ConnectionListener.java │ │ │ ├── SocketClient.java │ │ │ ├── SocketClientHandler.java │ │ │ └── SocketClientInitializer.java │ │ │ ├── service │ │ │ ├── InferenceService.java │ │ │ ├── LocalService.java │ │ │ ├── PrepareService.java │ │ │ ├── SystemService.java │ │ │ └── TrainService.java │ │ │ ├── type │ │ │ ├── ApiEnum.java │ │ │ └── SourceType.java │ │ │ └── util │ │ │ ├── AuthUtil.java │ │ │ ├── ConfigUtil.java │ │ │ ├── DbUtil.java │ │ │ ├── JdChainUtils.java │ │ │ ├── PacketUtil.java │ │ │ └── RequestCheck.java │ └── resources │ │ ├── client.properties │ │ ├── logback.xml │ │ └── name-dict.properties │ └── test │ ├── java │ └── com │ │ └── jdt │ │ └── fedlearn │ │ └── client │ │ ├── cache │ │ ├── InferenceDataCacheTest.java │ │ ├── ModelCacheTest.java │ │ └── TrainDataCacheTest.java │ │ ├── dao │ │ ├── CsvReaderTest.java │ │ ├── HttpReaderTest.java │ │ ├── InferenceDataDaoTest.java │ │ ├── ModelDaoTest.java │ │ └── TrainDataDaoTest.java │ │ ├── db │ │ ├── DbTest.java │ │ └── MysqlReaderTest.java │ │ ├── entity │ │ └── HttpRespTest.java │ │ ├── inference │ │ └── InferenceTest.java │ │ ├── service │ │ ├── AppTest.java │ │ ├── TestDistributedKeyGene.java │ │ └── TrainServiceTest.java │ │ ├── train │ │ ├── MultiThreadTest.java │ │ └── TrainTest.java │ │ ├── type │ │ └── RunningTypeTest.java │ │ └── util │ │ ├── CastUtilTest.java │ │ ├── ConfigUtilTest.java │ │ └── RequestCheckTest.java │ └── resources │ ├── client.properties │ ├── data │ └── cl1_train.csv │ ├── logback_test.xml │ ├── model │ ├── 1-SecureBoost-123456.model │ └── 111-FederatedGB-210119152702.model │ └── testFileA.csv ├── common ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── jdt │ │ └── fedlearn │ │ └── common │ │ ├── constant │ │ ├── AppConstant.java │ │ ├── CacheConstant.java │ │ ├── JdChainConstant.java │ │ ├── ResponseConstant.java │ │ └── TaskPriorityConstant.java │ │ ├── entity │ │ ├── CommonResultStatus.java │ │ ├── Job.java │ │ ├── JobReq.java │ │ ├── JobResult.java │ │ ├── SingleParameter.java │ │ ├── Task.java │ │ ├── TaskResultData.java │ │ ├── TokenDTO.java │ │ ├── TrainRequest.java │ │ ├── WorkerStatus.java │ │ ├── WorkerUnit.java │ │ ├── core │ │ │ ├── ClientInfo.java │ │ │ ├── Message.java │ │ │ ├── feature │ │ │ │ ├── Features.java │ │ │ │ └── SingleFeature.java │ │ │ └── type │ │ │ │ ├── AlgorithmType.java │ │ │ │ └── ReduceType.java │ │ ├── jdchain │ │ │ ├── ClientInfoFeatures.java │ │ │ ├── JdChainConfig.java │ │ │ ├── JdchainClientInfo.java │ │ │ ├── JdchainCreateFeatures.java │ │ │ ├── JdchainFeature.java │ │ │ └── JdchainTask.java │ │ ├── netty │ │ │ └── NettyMessage.java │ │ └── project │ │ │ ├── FeatureDTO.java │ │ │ ├── MatchPartnerInfo.java │ │ │ ├── PartnerDTO.java │ │ │ ├── PartnerInfoNew.java │ │ │ ├── ProjectInfo.java │ │ │ └── SingleFeatureDTO.java │ │ ├── enums │ │ ├── BusinessTypeEnum.java │ │ ├── DbType.java │ │ ├── ExceptionEnum.java │ │ ├── FedLearningReqEnum.java │ │ ├── LocalUrlType.java │ │ ├── ManagerCommandEnum.java │ │ ├── ResultTypeEnum.java │ │ ├── RunStatusEnum.java │ │ ├── RunningType.java │ │ ├── TaskTypeEnum.java │ │ ├── UrlType.java │ │ └── WorkerCommandEnum.java │ │ ├── exception │ │ ├── BusinessException.java │ │ ├── ConfigParseException.java │ │ ├── DeserializeException.java │ │ ├── NotAcceptableException.java │ │ └── SerializeException.java │ │ └── intf │ │ └── IAlgorithm.java │ └── test │ ├── java │ └── com │ │ └── jdt │ │ └── fedlearn │ │ └── common │ │ ├── entity │ │ ├── TaskTest.java │ │ └── TrainRequestTest.java │ │ ├── enums │ │ ├── LocalUrlTypeTest.java │ │ ├── ResultTypeEnumTest.java │ │ ├── RunStatusEnumTest.java │ │ ├── TaskTypeEnumTest.java │ │ └── WorkerCommandEnumTest.java │ │ └── exception │ │ └── BusinessExceptionTest.java │ └── resources │ ├── conf │ ├── logback.xml │ └── manager.properties │ └── file │ └── mo17k_test.csv ├── coordinator ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── jdt │ │ │ └── fedlearn │ │ │ └── coordinator │ │ │ ├── HttpApp.java │ │ │ ├── allocation │ │ │ ├── ChainMultiTrain.java │ │ │ ├── MultiAutoTrain.java │ │ │ ├── MultiInference.java │ │ │ ├── MultiMatch.java │ │ │ ├── MultiTrain.java │ │ │ └── ResourceManager.java │ │ │ ├── constant │ │ │ ├── Constant.java │ │ │ └── RequestConstant.java │ │ │ ├── dao │ │ │ ├── UniversalMapper.java │ │ │ ├── db │ │ │ │ ├── InferenceLogMapper.java │ │ │ │ ├── MatchMapper.java │ │ │ │ └── TrainMapper.java │ │ │ └── jdchain │ │ │ │ ├── ChainInferenceMapper.java │ │ │ │ ├── ChainMatchMapper.java │ │ │ │ ├── ChainTaskMapper.java │ │ │ │ └── ChainTrainMapper.java │ │ │ ├── entity │ │ │ ├── DbConfig.java │ │ │ ├── common │ │ │ │ ├── BaseResp.java │ │ │ │ ├── CommonQuery.java │ │ │ │ └── ResponseStd.java │ │ │ ├── inference │ │ │ │ ├── InferenceDto.java │ │ │ │ ├── InferenceFetchDTO.java │ │ │ │ ├── InferenceInfoCache.java │ │ │ │ ├── InferenceInfoDto.java │ │ │ │ ├── InferenceRequest.java │ │ │ │ ├── InferenceRes.java │ │ │ │ ├── InferenceResp.java │ │ │ │ ├── PushRsultDTO.java │ │ │ │ ├── QueryPredict.java │ │ │ │ ├── RemotePredict.java │ │ │ │ └── SingleInferenceRes.java │ │ │ ├── jdchain │ │ │ │ ├── JdChainTaskStatus.java │ │ │ │ ├── JdChainTrainRequest.java │ │ │ │ └── JdchainTrainInfo.java │ │ │ ├── metric │ │ │ │ ├── ArrayMetric.java │ │ │ │ ├── FeatureMetric.java │ │ │ │ ├── Metric.java │ │ │ │ ├── MetricPair.java │ │ │ │ └── SingleMetric.java │ │ │ ├── prepare │ │ │ │ ├── AlgorithmQuery.java │ │ │ │ ├── CommonParameterRes.java │ │ │ │ ├── KeyGenerateReq.java │ │ │ │ ├── MatchDetailRes.java │ │ │ │ ├── MatchListRes.java │ │ │ │ ├── MatchQueryReq.java │ │ │ │ └── MatchStartReq.java │ │ │ ├── system │ │ │ │ ├── DeleteModelReq.java │ │ │ │ ├── FeatureMapDTO.java │ │ │ │ ├── FeatureReq.java │ │ │ │ ├── FeaturesDTO.java │ │ │ │ └── FeaturesDatasetDTO.java │ │ │ ├── table │ │ │ │ ├── InferenceEntity.java │ │ │ │ ├── MatchEntity.java │ │ │ │ ├── PartnerProperty.java │ │ │ │ └── TrainInfo.java │ │ │ ├── train │ │ │ │ ├── AutoTrain.java │ │ │ │ ├── CommonTrainQuery.java │ │ │ │ ├── StartTrain.java │ │ │ │ ├── StartValues.java │ │ │ │ ├── StateChangeSignal.java │ │ │ │ ├── TrainContext.java │ │ │ │ ├── TrainListRes.java │ │ │ │ ├── TrainParameterQuery.java │ │ │ │ ├── TrainParameterRes.java │ │ │ │ ├── TrainProgressRes.java │ │ │ │ └── TrainStatus.java │ │ │ ├── uniqueId │ │ │ │ ├── InferenceId.java │ │ │ │ ├── MappingId.java │ │ │ │ ├── TrainId.java │ │ │ │ └── UniqueId.java │ │ │ └── validate │ │ │ │ └── ValidateRequest.java │ │ │ ├── exception │ │ │ ├── ForbiddenException.java │ │ │ ├── NotAcceptableException.java │ │ │ ├── NotExistException.java │ │ │ ├── UnauthorizedException.java │ │ │ ├── UnknownInterfaceException.java │ │ │ └── jdchain │ │ │ │ ├── RandomServerException.java │ │ │ │ └── StartTrainException.java │ │ │ ├── network │ │ │ ├── OkHttpUtil.java │ │ │ └── SendAndRecv.java │ │ │ ├── service │ │ │ ├── AbstractDispatchService.java │ │ │ ├── CommonService.java │ │ │ ├── IAbstractDispatchService.java │ │ │ ├── IDispatchService.java │ │ │ ├── InferenceService.java │ │ │ ├── TrainService.java │ │ │ ├── inference │ │ │ │ ├── InferenceBatchServiceImpl.java │ │ │ │ ├── InferenceCommonService.java │ │ │ │ ├── InferenceLogQueryServiceImpl.java │ │ │ │ ├── InferenceProgressServiceImpl.java │ │ │ │ └── InferenceRemoteServiceImpl.java │ │ │ ├── match │ │ │ │ ├── MatchDeleteImpl.java │ │ │ │ └── MatchDetailImpl.java │ │ │ ├── prepare │ │ │ │ ├── AlgorithmParameterImpl.java │ │ │ │ ├── CommonParameterImpl.java │ │ │ │ ├── MatchListImpl.java │ │ │ │ ├── MatchProgressImpl.java │ │ │ │ ├── MatchStartImpl.java │ │ │ │ └── SecureKeyGeneImpl.java │ │ │ ├── system │ │ │ │ ├── CheckFeatureServiceImpl.java │ │ │ │ ├── ModelDeleteServiceImpl.java │ │ │ │ ├── SystemDatasetServiceImpl.java │ │ │ │ └── SystemServiceImpl.java │ │ │ ├── train │ │ │ │ ├── StateChangeServiceImpl.java │ │ │ │ ├── TrainAutoServiceImpl.java │ │ │ │ ├── TrainCommonServiceImpl.java │ │ │ │ ├── TrainListServiceImpl.java │ │ │ │ ├── TrainParameterServiceImpl.java │ │ │ │ ├── TrainStartServiceImpl.java │ │ │ │ ├── TrainStatusServiceImpl.java │ │ │ │ ├── inner │ │ │ │ │ └── TrainProgressInnerServiceImpl.java │ │ │ │ └── jdchain │ │ │ │ │ ├── ChainStateChangeServiceImpl.java │ │ │ │ │ ├── ChainTrainCommonServiceImpl.java │ │ │ │ │ ├── ChainTrainProgressInnerServiceImpl.java │ │ │ │ │ ├── ChainTrainRandomServiceImpl.java │ │ │ │ │ └── ChainTrainStartServiceImpl.java │ │ │ └── validate │ │ │ │ ├── ValidateBatchServiceImpl.java │ │ │ │ ├── ValidateCommonServiceImpl.java │ │ │ │ └── ValidateService.java │ │ │ ├── type │ │ │ ├── APIEnum.java │ │ │ └── TuneType.java │ │ │ └── util │ │ │ ├── ConfigUtil.java │ │ │ ├── DbUtil.java │ │ │ ├── JdChainUtils.java │ │ │ ├── LogbackConfigLoader.java │ │ │ ├── PacketUtil.java │ │ │ └── RemoveRepeatUtil.java │ └── resources │ │ ├── coordinator.properties │ │ ├── fl.db │ │ └── logback.xml │ └── test │ ├── java │ └── com │ │ └── jdt │ │ └── fedlearn │ │ └── coordinator │ │ ├── Inference │ │ └── InferenceTest.java │ │ ├── db │ │ └── DbTest.java │ │ ├── entity │ │ ├── ResponseInternalTest.java │ │ ├── StartTrainTest.java │ │ ├── TrainContextTest.java │ │ ├── common │ │ │ └── ResponseConstructTest.java │ │ ├── inference │ │ │ └── TestInferenceRequest.java │ │ ├── metric │ │ │ ├── TestArrayMetric.java │ │ │ ├── TestFeatureMetric.java │ │ │ ├── TestMetric.java │ │ │ └── TestSingleMetric.java │ │ ├── prepare │ │ │ └── AlgorithmQueryTest.java │ │ ├── system │ │ │ ├── DeleteModelReqTest.java │ │ │ ├── FeatureReqTest.java │ │ │ ├── FeaturesDTOTest.java │ │ │ └── FeaturesDatasetDTOTest.java │ │ ├── table │ │ │ └── TestTrainInfo.java │ │ ├── task │ │ │ └── CreateQueryTest.java │ │ ├── train │ │ │ ├── TrainListResTest.java │ │ │ ├── TrainParameterResTest.java │ │ │ ├── TrainProgressResQueryTest.java │ │ │ └── TrainProgressResTest.java │ │ └── uniqueId │ │ │ ├── TestInferenceId.java │ │ │ ├── TestMappingId.java │ │ │ └── TestTrainId.java │ │ ├── exception │ │ ├── ForbiddenExceptionTest.java │ │ ├── NotAcceptableExceptionTest.java │ │ ├── UnauthorizedExceptionTest.java │ │ ├── UnknownInterfaceExceptionTest.java │ │ └── jdchain │ │ │ ├── RandomServerExceptionTest.java │ │ │ └── StartTrainExceptionTest.java │ │ ├── jdchain │ │ ├── JdChainTest.java │ │ └── JdchainTaskTest.java │ │ ├── network │ │ └── SendAndRecvTest.java │ │ ├── service │ │ ├── CommonServiceTest.java │ │ ├── inference │ │ │ ├── InferenceCommonServiceTest.java │ │ │ └── InferenceLogQueryServiceImplTest.java │ │ ├── prepare │ │ │ ├── AlgorithmParameterImplTest.java │ │ │ ├── CommonParameterImplTest.java │ │ │ ├── MatchProgressImplTest.java │ │ │ └── MatchStartImplTest.java │ │ ├── system │ │ │ ├── ModelDeleteServiceImplTest.java │ │ │ └── SystemDatasetServiceImplTest.java │ │ ├── train │ │ │ ├── TrainListServiceImplTest.java │ │ │ ├── TrainParameterServiceImplTest.java │ │ │ ├── TrainStartServiceImplTest.java │ │ │ ├── TrainStatusServiceImplTest.java │ │ │ └── inner │ │ │ │ └── TrainProgressInnerServiceImplTest.java │ │ └── validate │ │ │ ├── ValidateBatchServiceImplTest.java │ │ │ └── ValidateServiceTest.java │ │ ├── train │ │ └── TrainTest.java │ │ ├── type │ │ └── RunningTypeTest.java │ │ └── util │ │ ├── ConfigUtilTest.java │ │ ├── DbUtilTest.java │ │ ├── HttpUtilTest.java │ │ ├── JsonUtilTest.java │ │ ├── LogbackConfigLoaderTest.java │ │ ├── LogbackConfigTest.java │ │ ├── PacketUtilTest.java │ │ └── RemoveRepeatUtilTest.java │ └── resources │ ├── coordinator.properties │ ├── logback-test.xml │ └── testTXT.txt ├── core ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── jdt │ │ │ └── fedlearn │ │ │ └── core │ │ │ ├── App.java │ │ │ ├── dispatch │ │ │ ├── DistributedKeyGeneCoordinator.java │ │ │ ├── FederatedGB.java │ │ │ ├── FederatedKernel.java │ │ │ ├── HorizontalFedAvg.java │ │ │ ├── MixGBoost.java │ │ │ ├── RandomForest.java │ │ │ ├── VerticalFDNN.java │ │ │ ├── VerticalLinearRegression.java │ │ │ ├── VerticalLogisticRegression.java │ │ │ ├── common │ │ │ │ ├── Control.java │ │ │ │ └── DispatcherFactory.java │ │ │ └── mixLinear │ │ │ │ └── LinearRegression.java │ │ │ ├── encryption │ │ │ ├── Decryptor.java │ │ │ ├── DiffieHellman.java │ │ │ ├── Encryptor.java │ │ │ ├── LibGMP │ │ │ │ ├── GInteger.java │ │ │ │ ├── GMP.java │ │ │ │ ├── LibGMP.java │ │ │ │ ├── MPZMemory.java │ │ │ │ └── mpz_t.java │ │ │ ├── README.md │ │ │ ├── RsaUtil.java │ │ │ ├── common │ │ │ │ ├── Ciphertext.java │ │ │ │ ├── EncryptionTool.java │ │ │ │ ├── GeneralUtil.java │ │ │ │ ├── PrivateKey.java │ │ │ │ └── PublicKey.java │ │ │ ├── differentialPrivacy │ │ │ │ ├── DifferentialPrivacyFactory.java │ │ │ │ ├── Exponential.java │ │ │ │ ├── GammaDP.java │ │ │ │ ├── GaussianDP.java │ │ │ │ ├── IDifferentialPrivacy.java │ │ │ │ ├── Laplace.java │ │ │ │ ├── ObjectivePerturbDPImpl.java │ │ │ │ ├── OutputPerturbDPImpl.java │ │ │ │ └── RandomDP.java │ │ │ ├── distributedPaillier │ │ │ │ ├── DistributedPaillier.java │ │ │ │ ├── DistributedPaillierKeyGenerator.java │ │ │ │ ├── DistributedPaillierNative.java │ │ │ │ ├── HomoEncryptionDebugUtil.java │ │ │ │ ├── HomoEncryptionUtil.java │ │ │ │ └── comm │ │ │ │ │ ├── HttpClientUtil.java │ │ │ │ │ ├── JsonUtil.java │ │ │ │ │ ├── MockSendRecv.java │ │ │ │ │ ├── PacketUtil.java │ │ │ │ │ ├── Response.java │ │ │ │ │ └── SendAndRecv.java │ │ │ ├── fake │ │ │ │ ├── FakeCiphertext.java │ │ │ │ ├── FakePriKey.java │ │ │ │ ├── FakePubKey.java │ │ │ │ └── FakeTool.java │ │ │ ├── javallier │ │ │ │ ├── JSerializer.java │ │ │ │ ├── JavallierCiphertext.java │ │ │ │ ├── JavallierPriKey.java │ │ │ │ ├── JavallierPubKey.java │ │ │ │ └── JavallierTool.java │ │ │ └── nativeLibLoader.java │ │ │ ├── entity │ │ │ ├── base │ │ │ │ ├── Double2dArray.java │ │ │ │ ├── DoubleArray.java │ │ │ │ ├── EmptyMessage.java │ │ │ │ ├── Int2dArray.java │ │ │ │ ├── IntArray.java │ │ │ │ ├── SingleElement.java │ │ │ │ ├── StringArray.java │ │ │ │ └── UniversalArray.java │ │ │ ├── boost │ │ │ │ ├── BoostN1Res.java │ │ │ │ ├── BoostP1Req.java │ │ │ │ ├── BoostP2Res.java │ │ │ │ ├── BoostP3Req.java │ │ │ │ ├── BoostP3Res.java │ │ │ │ ├── BoostP4Req.java │ │ │ │ ├── BoostP5Res.java │ │ │ │ ├── Bucket.java │ │ │ │ ├── EncryptedGradHess.java │ │ │ │ ├── FeatureLeftGH.java │ │ │ │ ├── GainOutput.java │ │ │ │ ├── LeftTreeInfo.java │ │ │ │ ├── QueryEntry.java │ │ │ │ └── SubModel.java │ │ │ ├── common │ │ │ │ ├── CommonRequest.java │ │ │ │ ├── CommonResponse.java │ │ │ │ ├── InferenceInit.java │ │ │ │ ├── InferenceInitRes.java │ │ │ │ ├── MetricValue.java │ │ │ │ ├── PredictRes.java │ │ │ │ └── TrainInit.java │ │ │ ├── delphiInference │ │ │ │ └── DelphiMsg.java │ │ │ ├── distributed │ │ │ │ ├── InitResult.java │ │ │ │ └── SplitResult.java │ │ │ ├── distributedKeyGeneMsg │ │ │ │ ├── EmptyKeyGeneMsg.java │ │ │ │ ├── KeyGeneClientInitInfo.java │ │ │ │ ├── KeyGeneMsg.java │ │ │ │ ├── LongTypeMsg.java │ │ │ │ ├── PiQiAndLongTypeMsg.java │ │ │ │ ├── PiQiSharesFromParty.java │ │ │ │ ├── SbArrayListMsg.java │ │ │ │ ├── SbArrayMsg.java │ │ │ │ ├── SelectedIdxMsg.java │ │ │ │ └── Shares4AllOtherParties.java │ │ │ ├── horizontalZoo │ │ │ │ ├── HorizontalZooDataUtils.java │ │ │ │ └── HorizontalZooMsgStream.java │ │ │ ├── kernelLinearRegression │ │ │ │ ├── DataUtils.java │ │ │ │ ├── InferenceReqAndRes.java │ │ │ │ ├── TrainReq.java │ │ │ │ └── TrainRes.java │ │ │ ├── localModel │ │ │ │ ├── LocalLinearModel.java │ │ │ │ ├── LocalModel.java │ │ │ │ └── LocalNullModel.java │ │ │ ├── mixGBoost │ │ │ │ ├── BoostBodyReq.java │ │ │ │ ├── BoostBodyRes.java │ │ │ │ ├── BoostInferDecRes.java │ │ │ │ ├── BoostInferEncRes.java │ │ │ │ ├── BoostInferQueryReq.java │ │ │ │ ├── BoostInferQueryReqBody.java │ │ │ │ ├── BoostInferQueryRes.java │ │ │ │ ├── BoostInferQueryResBody.java │ │ │ │ ├── BoostInferScoreReq.java │ │ │ │ └── BoostInferScoreRes.java │ │ │ ├── mixedLinearRegression │ │ │ │ ├── CypherMessage.java │ │ │ │ ├── CypherMessage2D.java │ │ │ │ ├── CypherMessage2DList.java │ │ │ │ ├── CypherMessageList.java │ │ │ │ ├── LinearRegressionInferInitOthers.java │ │ │ │ ├── LinearRegressionTrainInitOthers.java │ │ │ │ ├── PartialDecMessage.java │ │ │ │ └── TwoCypherMessage.java │ │ │ ├── mpc │ │ │ │ ├── PartyA.java │ │ │ │ └── PartyB.java │ │ │ ├── psi │ │ │ │ ├── DhMatchReq1.java │ │ │ │ ├── DhMatchReq2.java │ │ │ │ ├── DhMatchRes1.java │ │ │ │ ├── DhMatchRes2.java │ │ │ │ ├── FreedmanEncryption.java │ │ │ │ ├── FreedmanPassiveIdx.java │ │ │ │ ├── FreedmanPassiveIdxMap.java │ │ │ │ ├── FreedmanPassiveResult.java │ │ │ │ ├── FreedmanPassiveUidMap.java │ │ │ │ ├── MatchInit.java │ │ │ │ ├── MatchInitRes.java │ │ │ │ ├── MatchRSA1.java │ │ │ │ ├── MatchRSA2.java │ │ │ │ ├── MatchRSA3.java │ │ │ │ ├── MatchResRSA4.java │ │ │ │ ├── MatchResourceLinReg.java │ │ │ │ └── MatchTransit.java │ │ │ ├── randomForest │ │ │ │ ├── DataUtils.java │ │ │ │ ├── RandomForestInferMessage.java │ │ │ │ ├── RandomForestLoss.java │ │ │ │ ├── RandomForestTrainReq.java │ │ │ │ ├── RandomForestTrainRes.java │ │ │ │ ├── SubModel.java │ │ │ │ ├── TreeNodeRF.java │ │ │ │ └── TypeRandomForest.java │ │ │ ├── secureInference │ │ │ │ ├── SecureInferenceInitReq.java │ │ │ │ ├── SecureInferenceInitRes.java │ │ │ │ ├── SecureInferenceReq1.java │ │ │ │ ├── SecureInferenceReq2.java │ │ │ │ ├── SecureInferenceRes1.java │ │ │ │ └── SecureInferenceRes2.java │ │ │ ├── serialize │ │ │ │ ├── BinarySerializer.java │ │ │ │ ├── HyperParameterAdapter.java │ │ │ │ ├── JsonSerializer.java │ │ │ │ └── MessageAdapter.java │ │ │ ├── verticalFDNN │ │ │ │ ├── VFDNNInferenceData.java │ │ │ │ ├── VFDNNMessage.java │ │ │ │ └── VerticalFDNNUtils.java │ │ │ └── verticalLinearRegression │ │ │ │ ├── GradientsMetric.java │ │ │ │ ├── LinearP1Request.java │ │ │ │ ├── LinearP1Response.java │ │ │ │ ├── LinearP2Request.java │ │ │ │ └── LossGradients.java │ │ │ ├── example │ │ │ ├── CommonRun.java │ │ │ ├── CommonRunKeyGene.java │ │ │ └── fgb │ │ │ │ ├── RunDistributedFederatedGB.java │ │ │ │ ├── RunFederatedGB.java │ │ │ │ └── TestFederatedGBWithDP.java │ │ │ ├── exception │ │ │ ├── NotImplementedException.java │ │ │ ├── NotMatchException.java │ │ │ ├── UnsupportedAlgorithmException.java │ │ │ └── WrongValueException.java │ │ │ ├── loader │ │ │ ├── boost │ │ │ │ └── BoostTrainData.java │ │ │ ├── common │ │ │ │ ├── AbstractInferenceData.java │ │ │ │ ├── AbstractTestData.java │ │ │ │ ├── AbstractTrainData.java │ │ │ │ ├── CommonInferenceData.java │ │ │ │ ├── CommonLoad.java │ │ │ │ ├── CommonTestData.java │ │ │ │ ├── CommonTrainData.java │ │ │ │ ├── Data.java │ │ │ │ ├── InferenceData.java │ │ │ │ ├── LibsvmTrainData.java │ │ │ │ ├── TestData.java │ │ │ │ └── TrainData.java │ │ │ ├── horizontalZoo │ │ │ │ └── HorizontalDataFrame.java │ │ │ ├── kernelLinearRegression │ │ │ │ └── KernelLinearRegressionTrainData.java │ │ │ ├── linearRegression │ │ │ │ ├── LinearInferenceData.java │ │ │ │ └── LinearTrainData.java │ │ │ ├── mixGBoost │ │ │ │ ├── MixGBInferenceData.java │ │ │ │ └── MixGBTrainData.java │ │ │ ├── randomForest │ │ │ │ ├── RFInferenceData.java │ │ │ │ └── RFTrainData.java │ │ │ ├── secureInference │ │ │ │ ├── DelphiInferenceData.java │ │ │ │ └── TreeInferenceData.java │ │ │ └── verticalLinearRegression │ │ │ │ └── VerticalLinearTrainData.java │ │ │ ├── math │ │ │ ├── ExpressionToTree.java │ │ │ ├── MathExt.java │ │ │ ├── Matrix.java │ │ │ ├── Normalizer.java │ │ │ ├── NormalizerOutPackage.java │ │ │ ├── Scalar.java │ │ │ ├── SelectFeatures.java │ │ │ ├── Vector.java │ │ │ ├── base │ │ │ │ ├── FlMatrix.java │ │ │ │ ├── FlScalar.java │ │ │ │ └── FlVector.java │ │ │ ├── ejml │ │ │ │ └── EjMatrix.java │ │ │ └── package-info.java │ │ │ ├── metrics │ │ │ ├── Analysis.java │ │ │ └── Metric.java │ │ │ ├── model │ │ │ ├── DistributedFederatedGBModel.java │ │ │ ├── DistributedRandomForestModel.java │ │ │ ├── FederatedGBModel.java │ │ │ ├── FederatedKernelModel.java │ │ │ ├── HorizontalFedAvgModel.java │ │ │ ├── MixGBModel.java │ │ │ ├── Model.java │ │ │ ├── RandomForestModel.java │ │ │ ├── VerticalFDNNModel.java │ │ │ ├── VerticalLRModel.java │ │ │ ├── VerticalLinearModel.java │ │ │ ├── common │ │ │ │ ├── CommonModel.java │ │ │ │ ├── Regularization.java │ │ │ │ ├── loss │ │ │ │ │ ├── ActivationFunction.java │ │ │ │ │ ├── LogisticLoss.java │ │ │ │ │ ├── Loss.java │ │ │ │ │ ├── SquareLoss.java │ │ │ │ │ └── crossEntropy.java │ │ │ │ └── tree │ │ │ │ │ ├── InferTreeNode.java │ │ │ │ │ ├── MixTreeNode.java │ │ │ │ │ ├── Tree.java │ │ │ │ │ ├── TreeNode.java │ │ │ │ │ └── sampling │ │ │ │ │ ├── ColSampler.java │ │ │ │ │ └── RowSampler.java │ │ │ ├── mixLinear │ │ │ │ ├── LinearRegressionModel.java │ │ │ │ └── idmatcher │ │ │ │ │ ├── LinRegMatcher.java │ │ │ │ │ └── LinregMatchAlg.java │ │ │ └── serialize │ │ │ │ ├── FgbModelSerializer.java │ │ │ │ ├── KernelJavaSerializer.java │ │ │ │ ├── LinearModelSerializer.java │ │ │ │ ├── MSerializer.java │ │ │ │ ├── MixGBSerializer.java │ │ │ │ ├── ModelSerializer.java │ │ │ │ └── SerializerUtils.java │ │ │ ├── optimizer │ │ │ ├── BatchGD.java │ │ │ ├── Newton.java │ │ │ ├── Optimizer.java │ │ │ ├── StochasticGD.java │ │ │ └── bfgs │ │ │ │ ├── BFGS.java │ │ │ │ ├── MixedBFGSSolver.java │ │ │ │ ├── WeightedLinRegBFGSSolver.java │ │ │ │ ├── WeightedLinRegLossNonprivClient.java │ │ │ │ └── WeightedLinRegLossPriv.java │ │ │ ├── parameter │ │ │ ├── DelphiParameter.java │ │ │ ├── FederatedKernelParameter.java │ │ │ ├── FgbParameter.java │ │ │ ├── HorizontalFedAvgPara.java │ │ │ ├── HyperParameter.java │ │ │ ├── LinearParameter.java │ │ │ ├── MixGBParameter.java │ │ │ ├── RandomForestParameter.java │ │ │ ├── TreeInferenceParameter.java │ │ │ ├── VerticalFDNNParameter.java │ │ │ ├── VerticalLRParameter.java │ │ │ ├── VerticalLinearParameter.java │ │ │ └── common │ │ │ │ ├── CategoryParameter.java │ │ │ │ ├── CommonParameter.java │ │ │ │ ├── MultiParameter.java │ │ │ │ ├── NumberParameter.java │ │ │ │ └── ParameterField.java │ │ │ ├── preprocess │ │ │ ├── FeatureEngineering.java │ │ │ ├── FeatureProcess.java │ │ │ ├── InferenceFilter.java │ │ │ ├── MissingValueFilling.java │ │ │ ├── Scaler.java │ │ │ ├── Scaling.java │ │ │ ├── TargetValueEncoder.java │ │ │ ├── TrainTestSplit.java │ │ │ └── package-info.java │ │ │ ├── psi │ │ │ ├── CommonPrepare.java │ │ │ ├── MatchResult.java │ │ │ ├── Prepare.java │ │ │ ├── PrepareClient.java │ │ │ ├── diffieHellman │ │ │ │ ├── DiffieHellmanMatch.java │ │ │ │ └── DiffieHellmanMatchClient.java │ │ │ ├── empty │ │ │ │ ├── EmptyMatch.java │ │ │ │ └── EmptyMatchClient.java │ │ │ ├── freedman │ │ │ │ ├── FreedmanMatch.java │ │ │ │ └── FreedmanMatchClient.java │ │ │ ├── md5 │ │ │ │ ├── Md5Match.java │ │ │ │ └── Md5MatchClient.java │ │ │ └── rsa │ │ │ │ ├── RsaMatch.java │ │ │ │ └── RsaMatchClient.java │ │ │ ├── research │ │ │ ├── ScoreCard.java │ │ │ ├── mpc │ │ │ │ ├── EasyScheme.java │ │ │ │ ├── EasySharing.java │ │ │ │ ├── GF256.java │ │ │ │ ├── GF256Scheme.java │ │ │ │ ├── Mpc.java │ │ │ │ ├── MpcModel.java │ │ │ │ └── QueryAuditor.java │ │ │ └── secureInference │ │ │ │ ├── DelphiInferenceClient.java │ │ │ │ ├── DelphiInferenceServer.java │ │ │ │ ├── TreeInferenceClient.java │ │ │ │ └── TreeInferenceServer.java │ │ │ ├── type │ │ │ ├── AnalysisType.java │ │ │ ├── BitLengthType.java │ │ │ ├── DifferentialPrivacyType.java │ │ │ ├── EncryptionType.java │ │ │ ├── FGBDispatchPhaseType.java │ │ │ ├── FGBModelPhaseType.java │ │ │ ├── FeatureType.java │ │ │ ├── FirstPredictType.java │ │ │ ├── FreedmanType.java │ │ │ ├── HorDispatchPhaseType.java │ │ │ ├── HorModelPhaseType.java │ │ │ ├── HorizontalZooMsgType.java │ │ │ ├── InferMessageType.java │ │ │ ├── KernelDispatchPhaseType.java │ │ │ ├── KernelModelPhaseType.java │ │ │ ├── KeyGeneReqType.java │ │ │ ├── MappingType.java │ │ │ ├── MemoryUnitsType.java │ │ │ ├── MessageType.java │ │ │ ├── MetricType.java │ │ │ ├── NormalizationType.java │ │ │ ├── ObjectiveType.java │ │ │ ├── OptimizerType.java │ │ │ ├── ParameterType.java │ │ │ ├── RFDispatchPhaseType.java │ │ │ ├── RFModelPhaseType.java │ │ │ ├── VerFDMMDispatchPhaseType.java │ │ │ ├── VerFDNNModelPhaseType.java │ │ │ ├── VerLRDispatchPhaseType.java │ │ │ ├── VerLRModelPhaseType.java │ │ │ ├── VerLinDispatchPhaseType.java │ │ │ ├── VerLinModelPhaseType.java │ │ │ └── data │ │ │ │ ├── DoubleTuple2.java │ │ │ │ ├── IntDoubleTuple3.java │ │ │ │ ├── IntTuple3.java │ │ │ │ ├── KeyPair.java │ │ │ │ ├── NamedArg.java │ │ │ │ ├── Pair.java │ │ │ │ ├── StringTuple2.java │ │ │ │ ├── Tuple2.java │ │ │ │ └── Tuple3.java │ │ │ └── util │ │ │ ├── BigIntegerUtil.java │ │ │ ├── DataParseUtil.java │ │ │ ├── FileUtil.java │ │ │ ├── HashUtil.java │ │ │ ├── LagrangeInterpolation.java │ │ │ ├── PolynomialExpansion.java │ │ │ ├── StringToIntUtil.java │ │ │ ├── Tool.java │ │ │ └── TypeConvUtils.java │ ├── proto │ │ └── federatedlearning.proto │ └── resources │ │ ├── libDistpaillier.dylib │ │ ├── libDistpaillier.so │ │ ├── libDistpaillier.so.0.1 │ │ └── logback.xml │ └── test │ ├── java │ └── com │ │ └── jdt │ │ └── fedlearn │ │ └── core │ │ ├── dispatch │ │ ├── MixGBoostTest.java │ │ ├── TestDispatcherFactory.java │ │ ├── TestDistributedKeyGeneCoordinator.java │ │ ├── TestFederatedGB.java │ │ ├── TestFederatedKernel.java │ │ ├── TestHorizontalFedAvg.java │ │ ├── TestLinearRegression.java │ │ ├── TestMixGBoost.java │ │ ├── TestRandomForest.java │ │ ├── TestSecureTreeInference.java │ │ ├── TestVerticalLinearRegression.java │ │ └── TestVerticalLogisticRegression.java │ │ ├── encryption │ │ ├── CommonFunction.java │ │ ├── JavallierBenchmark.java │ │ ├── LibGMP │ │ │ └── TestGMP.java │ │ ├── PaillierBenchmark.java │ │ ├── TestDifferentialPrivacy.java │ │ ├── TestDiffieHellman.java │ │ ├── TestDistributedPaillier.java │ │ ├── TestFake.java │ │ ├── TestJavallier.java │ │ ├── differentialPrivacy │ │ │ ├── TestDifferentialPrivacyFactory.java │ │ │ ├── TestExponentialDP.java │ │ │ ├── TestGammaDP.java │ │ │ ├── TestGaussianDP.java │ │ │ ├── TestLaplace.java │ │ │ ├── TestObjectivePerturbDPImpl.java │ │ │ ├── TestOutputPerturbDPImpl.java │ │ │ └── TestRandomDP.java │ │ └── distributedPaillier │ │ │ ├── TestDistPaillierDistribute.java │ │ │ ├── TestDistPaillierStandalone.java │ │ │ └── TestDistributedPaillierNative.java │ │ ├── entity │ │ ├── TestClientInfo.java │ │ ├── base │ │ │ ├── TestDouble2Array.java │ │ │ ├── TestDoubleArray.java │ │ │ ├── TestInt2dArray.java │ │ │ ├── TestIntArray.java │ │ │ └── TestUniversalArray.java │ │ ├── boost │ │ │ ├── TestBoostN1Res.java │ │ │ ├── TestBoostP1Req.java │ │ │ ├── TestBoostP2Res.java │ │ │ ├── TestBoostP3Req.java │ │ │ ├── TestBoostP3Res.java │ │ │ ├── TestBoostP4Req.java │ │ │ ├── TestBoostP5Res.java │ │ │ ├── TestBucket.java │ │ │ ├── TestEncryptedGradHess.java │ │ │ ├── TestFeatureLeftGH.java │ │ │ ├── TestGainOutput.java │ │ │ ├── TestLeftTreeInfo.java │ │ │ └── TestQueryEntry.java │ │ ├── common │ │ │ ├── MetricValueTest.java │ │ │ ├── TestInferenceInit.java │ │ │ └── TestTrainInit.java │ │ ├── feature │ │ │ ├── TestFeatures.java │ │ │ ├── TestSingleFeature.java │ │ │ └── TestTargetValueEncoder.java │ │ ├── horizontalFedAvg │ │ │ ├── TestHorizontalZooDataUtils.java │ │ │ └── TestHorizontalZooMsgStream.java │ │ ├── kernelLinearRegression │ │ │ ├── TestDataUtils.java │ │ │ ├── TestInferenceReqAndRes.java │ │ │ ├── TestTrainReq.java │ │ │ └── TestTrainRes.java │ │ ├── linear │ │ │ ├── TestLinearP2Request.java │ │ │ └── TestLinearP2RequestBody.java │ │ ├── localModel │ │ │ ├── TestLocalLinearModel.java │ │ │ └── TestLocalNullModel.java │ │ ├── mixGB │ │ │ ├── BoostInferQueryReqBodyTest.java │ │ │ └── BoostInferQueryResTest.java │ │ ├── mixedLinearRegression │ │ │ ├── TestLinearRegressionInferInitOthers.java │ │ │ └── TestLinearRegressionTrainInitOthers.java │ │ ├── mpc │ │ │ ├── TestPartyA.java │ │ │ └── TestPartyB.java │ │ ├── psi │ │ │ ├── TestDhMatchReq1.java │ │ │ ├── TestDhMatchReq2.java │ │ │ ├── TestDhMatchRes1.java │ │ │ ├── TestMatchInit.java │ │ │ └── TestMatchInitRes.java │ │ ├── randomForest │ │ │ ├── RandomForestInferMessageTest.java │ │ │ ├── RandomForestLossTest.java │ │ │ ├── RandomForestTrainReqTest.java │ │ │ ├── RandomForestTrainResTest.java │ │ │ ├── TestDataFrame.java │ │ │ ├── TestDataUtils.java │ │ │ ├── TestProfiler.java │ │ │ ├── TreeNodeRFTest.java │ │ │ └── TypeRandomForestTest.java │ │ ├── serialize │ │ │ ├── TestJavaSerializer.java │ │ │ └── TestJsonSerialize.java │ │ ├── verticalFDNN │ │ │ └── TestFDNNMessage.java │ │ └── verticalLinearRegression │ │ │ ├── TestGradientsMetric.java │ │ │ ├── TestLinearP1Request.java │ │ │ ├── TestLinearP1Response.java │ │ │ ├── TestLinearP2Request.java │ │ │ └── TestLossGradients.java │ │ ├── exception │ │ ├── DeserializeExceptionTest.java │ │ ├── NotImplementedExceptionTest.java │ │ ├── NotMatchExceptionTest.java │ │ ├── SerializeExceptionTest.java │ │ ├── UnsupportedAlgorithmExceptionTest.java │ │ └── WrongValueExceptionTest.java │ │ ├── fake │ │ ├── DataGenerate.java │ │ └── StructureGenerate.java │ │ ├── integratedTest │ │ ├── TestDistributedKeyGene.java │ │ ├── horizontalFL │ │ │ ├── TestHorizontalOneFlowBert.java │ │ │ └── TestHorizontalZoo.java │ │ ├── kernel │ │ │ └── TestFederatedKernel.java │ │ ├── linearRegression │ │ │ ├── TestDifferentialPrivacyMixedLinR.java │ │ │ └── TestMixedLinearRegression.java │ │ ├── mapping │ │ │ ├── TestDHMatch.java │ │ │ ├── TestEmptyMatch.java │ │ │ ├── TestFreedmanMatch.java │ │ │ ├── TestMD5Match.java │ │ │ └── TestRSAMatch.java │ │ ├── mixGBoost │ │ │ ├── TestMixGBHori.java │ │ │ ├── TestMixGBMixData2.java │ │ │ ├── TestMixGBoostBinaryVertical.java │ │ │ ├── TestMixGBoostRegHouse.java │ │ │ └── TestMixGBoostRegVertical.java │ │ ├── randomForest │ │ │ ├── TestDisRandomForestBinary.java │ │ │ ├── TestDisRandomForestReg.java │ │ │ ├── TestRandomForestBinary.java │ │ │ └── TestRandomForestReg.java │ │ ├── verticalFDNN │ │ │ └── TestVerticalFDNN.java │ │ ├── verticalLinear │ │ │ ├── TestVerticalLinear.java │ │ │ ├── TestVerticalLinearAB.java │ │ │ └── TestVerticalLinearWithDP.java │ │ └── verticalLogistic │ │ │ ├── TestVerticalLR.java │ │ │ └── TestVerticalLROnlyLabel.java │ │ ├── loader │ │ ├── TestPreprocess.java │ │ ├── TestSplitData.java │ │ ├── boost │ │ │ └── TestBoostTrainData.java │ │ ├── common │ │ │ ├── TestCommonInferenceData.java │ │ │ ├── TestCommonTestData.java │ │ │ ├── TestCommonTrainData.java │ │ │ └── TestLibsvmTrainData.java │ │ ├── mixGBoost │ │ │ ├── MixGBInferenceDataTest.java │ │ │ └── MixGBTrainDataTest.java │ │ ├── randomForest │ │ │ ├── RFInferenceDataTest.java │ │ │ └── TestRFTrainData.java │ │ └── verticalLinearRegression │ │ │ └── TestVerticalLinearTrainData.java │ │ ├── math │ │ ├── ExpressionToTreeTest.java │ │ ├── SelectFeaturesTest.java │ │ ├── TestMathExt.java │ │ ├── TestMathExtX.java │ │ ├── base │ │ │ ├── TestFlMatrix.java │ │ │ ├── TestFlScalar.java │ │ │ └── TestFlVector.java │ │ └── ejml │ │ │ └── TestEjMatrix.java │ │ ├── metrics │ │ ├── AnalysisTest.java │ │ └── TestMetric.java │ │ ├── model │ │ ├── TestDistributedFederatedGBModel.java │ │ ├── TestDistributedRandomForestModel.java │ │ ├── TestFederatedGBModel.java │ │ ├── TestFederatedKernelModel.java │ │ ├── TestLinearRegressionModel.java │ │ ├── TestMixGBModel.java │ │ ├── TestRandomForestModel.java │ │ ├── TestVerticalLRModel.java │ │ ├── TestVerticalLinearModel.java │ │ ├── common │ │ │ ├── loss │ │ │ │ ├── TestCrossEntropy.java │ │ │ │ ├── TestLogisticLoss.java │ │ │ │ ├── TestSquareLoss.java │ │ │ │ └── crossEntropyTest.java │ │ │ └── tree │ │ │ │ └── TestSampling.java │ │ └── serialize │ │ │ └── MixGBSerializerTest.java │ │ ├── mpc │ │ ├── TestMpc.java │ │ └── TestMpcMill.java │ │ ├── multi │ │ ├── TestMultithread.java │ │ └── TestStream.java │ │ ├── optimizer │ │ ├── BatchGDTest.java │ │ └── StochasticGDTest.java │ │ ├── parameter │ │ ├── MixGBParameterTest.java │ │ ├── RandomForestParameterTest.java │ │ ├── TestCommonParameter.java │ │ └── TestFgbParameter.java │ │ ├── preprocess │ │ ├── TestMD5Match.java │ │ ├── TestMissingValueFilling.java │ │ ├── TestScaling.java │ │ └── TestTrainTestSplit.java │ │ ├── psi │ │ ├── diffieHellman │ │ │ ├── TestDHMatch.java │ │ │ └── TestDHMatchClient.java │ │ ├── freedman │ │ │ ├── FreedmanMatchClientTest.java │ │ │ └── FreedmanMatchTest.java │ │ └── rsa │ │ │ ├── TestRsaMatch.java │ │ │ └── TestRsaMatchClient.java │ │ ├── research │ │ └── mpc │ │ │ ├── TestEasySharing.java │ │ │ ├── TestMpc.java │ │ │ └── TestMpcModel.java │ │ ├── type │ │ ├── AlgorithmTypeTest.java │ │ ├── DifferentialPrivacyTypeTest.java │ │ ├── FGBDispatchPhaseTypeTest.java │ │ ├── FGBModelPhaseTypeTest.java │ │ ├── FeatureTypeTest.java │ │ ├── HorDispatchPhaseTypeTest.java │ │ ├── HorModelPhaseTypeTest.java │ │ ├── InferMessageTypeTest.java │ │ ├── KernelDispatchPhaseTypeTest.java │ │ ├── KernelModelPhaseTypeTest.java │ │ ├── MappingTypeTest.java │ │ ├── MemoryUnitsTypeTest.java │ │ ├── MessageTypeTest.java │ │ ├── MetricTypeTest.java │ │ ├── NormalizationTypeTest.java │ │ ├── OptimizerTypeTest.java │ │ ├── RFDispatchPhaseTypeTest.java │ │ ├── RFModelPhaseTypeTest.java │ │ ├── Tuple2Test.java │ │ ├── Tuple3Test.java │ │ ├── VerFDMMDispatchPhaseTypeTest.java │ │ ├── VerFDNNModelPhaseTypeTest.java │ │ ├── VerLRDispatchPhaseTypeTest.java │ │ ├── VerLRModelPhaseTypeTest.java │ │ ├── VerLinDispatchPhaseTypeTest.java │ │ └── VerLinModelPhaseTypeTest.java │ │ └── util │ │ ├── LagrangeInterpolationTest.java │ │ ├── TestTool.java │ │ ├── TestTypeTrans.java │ │ └── TestZip.java │ └── resources │ ├── HFL │ ├── hori │ │ ├── train0.csv │ │ ├── train1.csv │ │ ├── train2.csv │ │ └── trainall.csv │ └── mnist │ │ ├── mnistTest.csv │ │ ├── mnistTrain1078.csv │ │ ├── mnistTrain283.csv │ │ └── mnistTrain787.csv │ ├── classificationA │ ├── inference0.csv │ ├── inference1.csv │ ├── inference2.csv │ ├── readme.txt │ ├── train0.csv │ ├── train0_missing.csv │ ├── train1.csv │ └── train2.csv │ ├── classificationA_IDMatch │ ├── readme.txt │ ├── train0.csv │ ├── train1.csv │ └── train2.csv │ ├── classificationA_Small │ ├── inference0.csv │ ├── inference1.csv │ ├── inference2.csv │ ├── readme.txt │ ├── train0.csv │ ├── train0_missing.csv │ ├── train1.csv │ └── train2.csv │ ├── classificationA_Twopartner │ ├── inference0.csv │ ├── inference0_onlyLabel.csv │ ├── inference1.csv │ ├── inference1_onlyLabel.csv │ ├── readme.txt │ ├── train0.csv │ ├── train0_onlyLabel.csv │ ├── train1.csv │ └── train1_onlyLabel.csv │ ├── classificationA_numberID │ ├── readme.txt │ ├── train0.csv │ ├── train1.csv │ └── train2.csv │ ├── classificationB │ ├── digits_test1_mixed.csv │ ├── digits_test2_mixed.csv │ ├── digits_test3_mixed.csv │ ├── digits_test_clean.csv │ ├── digits_test_clean_clean.csv │ ├── digits_train1_mixed.csv │ ├── digits_train2_mixed.csv │ ├── digits_train3_mixed.csv │ ├── digits_train_clean.csv │ └── digits_train_clean_clean.csv │ ├── house │ ├── reg0_test.csv │ ├── reg0_train.csv │ ├── reg1_test.csv │ ├── reg1_train.csv │ ├── reg2_test.csv │ └── reg2_train.csv │ ├── json │ └── linearp2.json │ ├── libsvm │ └── mushroom.csv │ ├── match │ ├── readme.txt │ ├── train1.csv │ ├── train2.csv │ └── train3.csv │ ├── multiClassificationA │ ├── inference0.csv │ ├── inference1.csv │ ├── inference2.csv │ ├── readme.txt │ ├── train0.csv │ ├── train1.csv │ └── train2.csv │ ├── multiClassificationB │ ├── inference0.csv │ ├── inference1.csv │ ├── inference2.csv │ ├── readme.txt │ ├── train0.csv │ ├── train1.csv │ └── train2.csv │ ├── regressionA │ ├── inference0.csv │ ├── inference1.csv │ ├── inference1_removefeature.csv │ ├── inference2.csv │ ├── readme.txt │ ├── train0.csv │ ├── train1.csv │ ├── train1_removefeature.csv │ └── train2.csv │ ├── regressionA_TwoPartner │ ├── inference0.csv │ ├── inference1.csv │ ├── readme.txt │ ├── train0.csv │ └── train1.csv │ ├── regressionB │ ├── data0_test10.csv │ ├── data0_train50.csv │ ├── data1_test10.csv │ ├── data1_train50.csv │ ├── data2_test10.csv │ ├── data2_train50.csv │ ├── test0.csv │ ├── test1.csv │ ├── test2.csv │ ├── train0.csv │ ├── train1.csv │ └── train2.csv │ ├── regressionC │ ├── data1.csv │ ├── data2.csv │ ├── data3.csv │ └── readme.txt │ ├── regressionD │ ├── readme.txt │ ├── train0.csv │ ├── train1.csv │ └── train2.csv │ ├── regressionE │ ├── data00_01_100.csv │ ├── data00_02_100.csv │ ├── data00_03_100.csv │ ├── inference0.csv │ ├── inference1.csv │ ├── inference2.csv │ ├── readme.txt │ ├── reference0.csv │ ├── reference2.csv │ ├── train0.csv │ ├── train1.csv │ └── train2.csv │ ├── regressionF │ ├── readme.txt │ ├── test0.csv │ ├── test1.csv │ ├── test2.csv │ ├── train0.csv │ ├── train1.csv │ └── train2.csv │ ├── regressionG │ ├── inference1.csv │ ├── inference2.csv │ ├── inference3.csv │ ├── readme.txt │ ├── train1.csv │ ├── train2.csv │ └── train3.csv │ └── regression_7333_7333 │ ├── df_reg_0_700_test.csv │ ├── df_reg_0_700_test_withLabel.csv │ ├── df_reg_0_700_train.csv │ ├── df_reg_1_700_test.csv │ ├── df_reg_1_700_test_withLabel.csv │ ├── df_reg_1_700_train.csv │ ├── df_reg_2_700_test.csv │ ├── df_reg_2_700_test_withLabel.csv │ └── df_reg_2_700_train.csv ├── manager ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── jdt │ │ │ └── fedlearn │ │ │ └── manager │ │ │ ├── ManagerHttpApp.java │ │ │ ├── ManagerLocalApp.java │ │ │ ├── service │ │ │ ├── CacheManager.java │ │ │ ├── JobManager.java │ │ │ ├── TaskManager.java │ │ │ └── TrainMessageSplitService.java │ │ │ ├── spring │ │ │ ├── Constant.java │ │ │ ├── SpringBean.java │ │ │ └── SpringUtil.java │ │ │ ├── task │ │ │ ├── Executor.java │ │ │ └── local │ │ │ │ └── impl │ │ │ │ └── FinishExecutorImpl.java │ │ │ ├── util │ │ │ └── ConfigUtil.java │ │ │ └── worker │ │ │ ├── WorkerManager.java │ │ │ └── service │ │ │ ├── IWorkerSelect.java │ │ │ └── impl │ │ │ ├── WorkerBindImpl.java │ │ │ └── WorkerRandomImpl.java │ └── resources │ │ ├── logback.xml │ │ ├── manager-applicationContext.xml │ │ └── manager.properties │ └── test │ ├── java │ └── com │ │ └── jdt │ │ └── fedlearn │ │ └── manager │ │ ├── ManagerHttpAppTest.java │ │ ├── ManagerLocalAppTest.java │ │ ├── service │ │ ├── CacheManagerTest.java │ │ ├── JobManagerTest.java │ │ ├── TaskManagerTest.java │ │ └── WorkerManagerTest.java │ │ └── task │ │ └── local │ │ └── impl │ │ └── FinishExecutorImplTest.java │ └── resources │ ├── conf │ └── manager.properties │ └── manager-applicationContext.xml ├── pom.xml ├── tools ├── pom.xml └── src │ ├── main │ ├── Expr.g4 │ └── java │ │ └── com │ │ └── jdt │ │ └── fedlearn │ │ └── tools │ │ ├── CacheUtil.java │ │ ├── EvalVisitor.java │ │ ├── ExprAnalysis.java │ │ ├── ExprErrorListener.java │ │ ├── FileUtil.java │ │ ├── GZIPCompressUtil.java │ │ ├── IpAddressUtil.java │ │ ├── LogUtil.java │ │ ├── LogbackConfigLoader.java │ │ ├── ManagerCommandUtil.java │ │ ├── NameUtil.java │ │ ├── PacketUtil.java │ │ ├── TimeUtil.java │ │ ├── ToString.java │ │ ├── TokenUtil.java │ │ ├── WorkerCommandUtil.java │ │ ├── antlrGenerate │ │ ├── Expr.interp │ │ ├── Expr.tokens │ │ ├── ExprBaseListener.java │ │ ├── ExprBaseVisitor.java │ │ ├── ExprLexer.interp │ │ ├── ExprLexer.java │ │ ├── ExprLexer.tokens │ │ ├── ExprListener.java │ │ ├── ExprParser.java │ │ └── ExprVisitor.java │ │ ├── internel │ │ ├── ResponseConstruct.java │ │ ├── ResponseHandler.java │ │ └── ResponseInternal.java │ │ ├── netty │ │ └── server │ │ │ ├── SocketServer.java │ │ │ ├── SocketServerHandler.java │ │ │ └── SocketServerInitializer.java │ │ ├── network │ │ ├── INetWorkService.java │ │ └── impl │ │ │ ├── HttpClientImpl.java │ │ │ └── NettySocketImpl.java │ │ ├── serializer │ │ ├── JavaSerializer.java │ │ ├── JsonUtil.java │ │ ├── KryoUtil.java │ │ ├── SerializationUtils.java │ │ └── Serializer.java │ │ └── utils │ │ └── GetMethodUtil.java │ └── test │ ├── java │ └── com │ │ └── jdt │ │ └── fedlearn │ │ └── tools │ │ ├── AntlrTest.java │ │ ├── CacheUtilTest.java │ │ ├── FileUtilTest.java │ │ ├── HttpUtilTest.java │ │ ├── JsonUtilTest.java │ │ ├── KryoUtilTest.java │ │ ├── LogUtilTest.java │ │ ├── ManagerCommandUtilTest.java │ │ ├── MockRequest.java │ │ ├── NameUtilTest.java │ │ ├── SerializationUtilsTest.java │ │ ├── TimeUtilsTest.java │ │ ├── TokenUtilTest.java │ │ └── WorkerCommandUtilTest.java │ └── resources │ └── file │ └── mo17k_test.csv └── worker ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── jdt │ │ └── fedlearn │ │ └── worker │ │ ├── WorkerHttpApp.java │ │ ├── cache │ │ ├── ManagerCache.java │ │ └── WorkerResultCache.java │ │ ├── constant │ │ └── Constant.java │ │ ├── entity │ │ ├── system │ │ │ └── Metadata.java │ │ └── train │ │ │ └── QueryProgress.java │ │ ├── exception │ │ └── ForbiddenException.java │ │ ├── multi │ │ └── TrainProcess.java │ │ ├── runner │ │ ├── Runner.java │ │ └── impl │ │ │ └── fedLearning │ │ │ ├── InitRunnerImpl.java │ │ │ ├── MapRunnerImpl.java │ │ │ └── ReduceRunnerImpl.java │ │ ├── service │ │ ├── AlgorithmService.java │ │ ├── RuntimeStatusService.java │ │ ├── SystemService.java │ │ ├── TrainService.java │ │ ├── WorkerRunner.java │ │ └── WorkerRunnerImpl.java │ │ ├── spring │ │ ├── Constant.java │ │ ├── SpringBean.java │ │ └── SpringUtil.java │ │ └── util │ │ ├── DAGUtil.java │ │ ├── ExceptionUtil.java │ │ └── Tools.java └── resources │ ├── logback.xml │ ├── worker-applicationContext.xml │ └── worker.properties └── test ├── java └── com │ └── jdt │ └── fedlearn │ └── worker │ ├── WorkerHttpAppTest.java │ ├── cache │ ├── InferenceDataCacheTest.java │ ├── ManagerCacheTest.java │ ├── ModelCacheTest.java │ └── TrainDataCacheTest.java │ ├── dao │ └── ModelDaoTest.java │ ├── runner │ └── impl │ │ └── fedLearning │ │ ├── InitRunnerImplTest.java │ │ ├── MapRunnerImplTest.java │ │ └── ReduceRunnerImplTest.java │ ├── service │ ├── InferenceServiceTest.java │ ├── PrepareServiceTest.java │ ├── RuntimeStatusServiceTest.java │ ├── SystemServiceTest.java │ ├── TrainServiceTest.java │ └── WorkerRunnerImplTest.java │ └── util │ ├── DAGUtilTest.java │ ├── ExceptionUtilTest.java │ ├── HttpClientUtilTest.java │ ├── PacketUtilTest.java │ └── ToolsTest.java └── resources ├── conf └── worker.properties ├── demo ├── mo17k.csv ├── mo17k.csv.success ├── mo17k_result.csv ├── mo17k_test.csv └── predict │ └── predict.txt ├── draft.json ├── draft1.json ├── draft_data.json ├── logback-test.xml ├── model ├── 124-DistributedRandomForest-210427162559.model └── 2-MD5-210719144319.txt ├── regressionA ├── inference1.csv ├── inference2.csv ├── inference3.csv ├── readme.txt ├── train1.csv ├── train2.csv └── train3.csv └── result.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | 14 | #idea IDE files 15 | .idea/ 16 | target/ 17 | # only ignore project dir in base 18 | /project/ 19 | *.iml 20 | .DS_Store 21 | .DS_Store? 22 | 23 | 24 | # Package Files # 25 | *.jar 26 | *.war 27 | *.nar 28 | *.ear 29 | *.zip 30 | *.tar.gz 31 | *.rar 32 | 33 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 34 | hs_err_pid* 35 | 36 | # generated model file in project root 37 | /*.model 38 | 39 | .vscode/ 40 | -------------------------------------------------------------------------------- /assembly/src/main/assembly/conf/manager.properties: -------------------------------------------------------------------------------- 1 | # 应用名,启动脚本会用到,与logback.xml 内的app保持一致 2 | app.name=fedlearn-manager 3 | # 启动端口 4 | app.port=8095 5 | # 日志文件路径 6 | log.settings=/export/Config/logback.xml 7 | # worker端地址,多个用分号分隔 8 | workers.address=127.0.0.1:9094;127.0.0.1:9095 9 | # 默认的worker 10 | default.worker=http://127.0.0.1:9094 -------------------------------------------------------------------------------- /assembly/src/main/assembly/conf/worker.properties: -------------------------------------------------------------------------------- 1 | manager.address=http://127.0.0.1:8095 2 | #是否主动注册(当服务器已经启动后,可以通过和这个主动注册) 3 | auto.register=false 4 | 5 | # 目前配置文件 6 | # 应用名,启动脚本会用到,与logback.xml 内的app保持一致 7 | app.name=fedlearn-worker 8 | # 启动端口 9 | app.port=9094 10 | # 日志文件路径 11 | log.settings=/export/Config/logback.xml 12 | # master端地址,多个用逗号分隔 13 | master.address=127.0.0.1 14 | 15 | # train config, 支持多个数据源 16 | #hdfs数据源配置 17 | hdfs.uri=hdfs://ThinkStation-P320:9000 18 | hdfs.user=root 19 | 20 | # train config, 支持多个数据源 21 | train1.source=hdfs 22 | train1.base=/ 23 | #train1.source=csv 24 | #train1.base=/Users/geyan29/202104/bank/ 25 | train1.dataset=class0_train.csv 26 | 27 | 28 | # inference config 29 | inference.data.source=csv 30 | inference.base=/Users/bank/ 31 | inference.dataset1=class0_test.csv 32 | 33 | #是否允许预测训练集中的uid 34 | inference.allowTrainUid=True 35 | 36 | # id对齐结果输出保存配置 37 | idMatch.dir=/export/Data/federated-learning-client/idMatch/ 38 | 39 | # 模型保存路径 40 | model.dir=/Users/model/ 41 | 42 | #预测结果文件 43 | predict.dir=/Users/predict/ 44 | -------------------------------------------------------------------------------- /assembly/src/main/assembly/readme/enviroment.txt: -------------------------------------------------------------------------------- 1 | 部署环境要求: -------------------------------------------------------------------------------- /assembly/src/main/assembly/readme/readme.txt: -------------------------------------------------------------------------------- 1 | 默认配置文件路径:conf/client.properties 2 | 如需使用其他配置文件请在运行 脚本时指定 -c configFileLocation 指定 -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/entity/inference/InferencePrepareRes.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.entity.inference; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | import java.util.List; 6 | 7 | public class InferencePrepareRes implements Message { 8 | private List filterList ; 9 | 10 | public InferencePrepareRes(List filterList) { 11 | this.filterList = filterList; 12 | } 13 | 14 | public List getFilterList() { 15 | return filterList; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/entity/local/AuthToken.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.entity.local; 2 | 3 | 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | 6 | @JsonIgnoreProperties(ignoreUnknown = true) 7 | public class AuthToken { 8 | private String token; 9 | 10 | public AuthToken() { 11 | } 12 | 13 | public AuthToken(String token) { 14 | this.token = token; 15 | } 16 | 17 | public String getToken() { 18 | return token; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/entity/local/ConfigQueryReq.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.entity.local; 2 | 3 | public class ConfigQueryReq { 4 | private String token; 5 | 6 | public ConfigQueryReq(String token) { 7 | this.token = token; 8 | } 9 | 10 | public String getToken() { 11 | return token; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/entity/local/ConfigUpdateReq.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.entity.local; 2 | 3 | import java.util.List; 4 | 5 | public class ConfigUpdateReq extends AuthToken { 6 | 7 | private List config; 8 | 9 | public ConfigUpdateReq() { 10 | } 11 | 12 | public ConfigUpdateReq(List config) { 13 | this.config = config; 14 | } 15 | 16 | public List getConfig() { 17 | return config; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/entity/local/InferenceStart.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.entity.local; 2 | 3 | /** 4 | * 本地推理请求, 5 | */ 6 | public class InferenceStart { 7 | private String modelId; 8 | private String[] uid; 9 | private int ratio; 10 | 11 | public InferenceStart() { 12 | } 13 | 14 | public InferenceStart(String[] uid, int ratio) { 15 | this.uid = uid; 16 | this.ratio = ratio; 17 | } 18 | 19 | public String[] getUid() { 20 | return uid; 21 | } 22 | 23 | public int getRatio() { 24 | return ratio; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/entity/local/SingleConfig.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.entity.local; 2 | 3 | public class SingleConfig { 4 | private String key; 5 | private String desc; 6 | 7 | private Object value; 8 | 9 | public SingleConfig() { 10 | } 11 | 12 | public SingleConfig(String key, String desc, Object value) { 13 | this.key = key; 14 | this.desc = desc; 15 | this.value = value; 16 | } 17 | 18 | public String getKey() { 19 | return key; 20 | } 21 | 22 | public String getDesc() { 23 | return desc; 24 | } 25 | 26 | public Object getValue() { 27 | return value; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/exception/ServerNotFoundException.java: -------------------------------------------------------------------------------- 1 | 2 | package com.jdt.fedlearn.client.exception; 3 | 4 | public class ServerNotFoundException extends RuntimeException { 5 | private static final long serialVersionUID = 3816979698911773512L; 6 | 7 | public ServerNotFoundException() { 8 | super(); 9 | } 10 | 11 | public ServerNotFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 12 | super(message, cause, enableSuppression, writableStackTrace); 13 | } 14 | 15 | public ServerNotFoundException(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | 19 | public ServerNotFoundException(String message) { 20 | super(message); 21 | } 22 | 23 | public ServerNotFoundException(Throwable cause) { 24 | super(cause); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/netty/SocketClientInitializer.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.netty; 2 | 3 | import io.netty.channel.ChannelInitializer; 4 | import io.netty.channel.ChannelPipeline; 5 | import io.netty.channel.socket.SocketChannel; 6 | import io.netty.handler.codec.serialization.ClassResolvers; 7 | import io.netty.handler.codec.serialization.ObjectDecoder; 8 | import io.netty.handler.codec.serialization.ObjectEncoder; 9 | 10 | public class SocketClientInitializer extends ChannelInitializer { 11 | private SocketClient socketClient; 12 | public SocketClientInitializer(SocketClient socketClient) { 13 | this.socketClient = socketClient; 14 | } 15 | 16 | @Override 17 | protected void initChannel(SocketChannel ch){ 18 | ChannelPipeline pipeline = ch.pipeline(); 19 | pipeline.addLast(new ObjectDecoder(Integer.MAX_VALUE,ClassResolvers.cacheDisabled(null))); 20 | pipeline.addLast(new ObjectEncoder()); 21 | pipeline.addLast(new SocketClientHandler(socketClient)); 22 | } 23 | } -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/type/ApiEnum.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.type; 2 | 3 | public class ApiEnum { 4 | } 5 | -------------------------------------------------------------------------------- /client/src/main/java/com/jdt/fedlearn/client/util/AuthUtil.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.util; 2 | 3 | 4 | import com.jdt.fedlearn.client.entity.local.AuthToken; 5 | import com.jdt.fedlearn.tools.serializer.JsonUtil; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | public class AuthUtil { 10 | private static final Logger logger = LoggerFactory.getLogger(AuthUtil.class); 11 | 12 | public static boolean check(String content) { 13 | AuthToken authToken = JsonUtil.json2Object(content, AuthToken.class); 14 | if (authToken == null) { 15 | return false; 16 | } 17 | String token = authToken.getToken(); 18 | String actualToken = ConfigUtil.getClientConfig().getAuthToken(); 19 | logger.info("token:" + token); 20 | logger.info("==authToken==:" + actualToken); 21 | return token != null && token.equals(actualToken); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /client/src/main/resources/name-dict.properties: -------------------------------------------------------------------------------- 1 | sourceType=数据源类型 2 | driver=驱动 3 | username=用户名 4 | password=密码 5 | url=链接 6 | table=表名 7 | dataset=数据集唯一名称 -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/cache/InferenceDataCacheTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.cache; 2 | 3 | 4 | import org.testng.annotations.Test;; 5 | 6 | import java.util.Arrays; 7 | 8 | public class InferenceDataCacheTest { 9 | 10 | @Test 11 | public void Test1() { 12 | String[] uidList = new String[]{"we","er","retw"}; 13 | System.out.println(Arrays.toString(uidList).length()); 14 | } 15 | 16 | // public String[][] predict(String uid) throws IOException { 17 | // String inferenceId = uid; 18 | // 19 | // String[][] sample = InferenceDataCache. (inferenceId, new String[]{"0", "1", "4", "3", "2", "test", "test1", "43d10e5db296ec539471cf4b34ecdab6", "5f5fca0ee771920529af94cdac721e8d", "cae0438a6ccf8e0e1cbd89e9536567d4", "edbc75733a46ea392a892d3880efe2c8", "2e7d4bacccc7cd8f16da28378b421fc6"}); 20 | // return sample; 21 | // } 22 | } 23 | -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/cache/ModelCacheTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.cache; 2 | 3 | import com.jdt.fedlearn.core.model.Model; 4 | import com.jdt.fedlearn.core.type.data.Tuple2; 5 | 6 | import java.util.*; 7 | import java.util.stream.Collectors; 8 | 9 | public class ModelCacheTest { 10 | public static void main(String[] args) { 11 | int capacity = 10; 12 | Set tokenSet = new HashSet<>(); 13 | tokenSet.add("1"); 14 | // tokenSet.add("2"); 15 | // tokenSet.add("3"); 16 | // tokenSet.add("4"); 17 | // tokenSet.add("5"); 18 | 19 | List needToLoad = tokenSet.stream().limit(capacity).collect(Collectors.toList()); 20 | System.out.println(needToLoad.size()); 21 | 22 | Queue> modelQueue = new LinkedList<>(); 23 | System.out.println(modelQueue.size()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/cache/TrainDataCacheTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.cache; 2 | 3 | 4 | import org.testng.annotations.Test;; 5 | 6 | import java.util.Arrays; 7 | 8 | public class TrainDataCacheTest { 9 | @Test 10 | public void test1() { 11 | String[] uidList = new String[]{"we","er","retw"}; 12 | System.out.println(Arrays.toString(uidList).length()); 13 | } 14 | 15 | // public String[][] predict(String uid) throws IOException { 16 | // String inferenceId = uid; 17 | // 18 | // String[][] sample = InferenceDataCache. (inferenceId, new String[]{"0", "1", "4", "3", "2", "test", "test1", "43d10e5db296ec539471cf4b34ecdab6", "5f5fca0ee771920529af94cdac721e8d", "cae0438a6ccf8e0e1cbd89e9536567d4", "edbc75733a46ea392a892d3880efe2c8", "2e7d4bacccc7cd8f16da28378b421fc6"}); 19 | // return sample; 20 | // } 21 | } 22 | -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/dao/InferenceDataDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.dao; 2 | 3 | import java.io.IOException; 4 | import java.util.Arrays; 5 | 6 | 7 | public class InferenceDataDaoTest { 8 | public static void main(String[] args) throws IOException { 9 | String[] x = new String[]{"1.0", "1.5", "2.0", "15.9", "", "20.1"}; 10 | System.out.println(Arrays.toString(x)); 11 | String[][] y = new String[][]{x}; 12 | // String[][] z = extractSamples(y); 13 | 14 | System.out.println(Arrays.deepToString(y)); 15 | // System.out.println(Arrays.deepToString(z)); 16 | 17 | // String[][] trainData = loadTrain("common/diabetes.txt", new long[]{10}); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/dao/TrainDataDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.dao; 2 | 3 | import java.util.Arrays; 4 | 5 | public class TrainDataDaoTest { 6 | public static void main(String[] args) { 7 | // CsvReader reader = new CsvReader(); 8 | // String[][] trainData = reader.loadTrain("src/test/resources/testFileA.csv"); 9 | // System.out.println(Arrays.toString(trainData[1])); 10 | // System.out.println(trainData.length); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/entity/HttpRespTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.entity; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | 6 | public class HttpRespTest { 7 | @Test 8 | public void Test(){ 9 | String reponse = "{\"code\": 0,\"status\": \"success\",\"message\": \"success\",\"data\": {\"header\": [],\"result\": [{}, {}]}}"; 10 | // String reponse = "{\"code\": 0,\"status\": \"success\",\"message\": \"success\"}"; 11 | // String reponse ="{\"code\": 0,\"status\": \"success\",\"message\": \"success\",\"data\": {\"header\": [\"md042m\", \"md000g\"],\"result\": [{\"uid\": \"test\",\"feature\": [\"-1\", \"20\"]}, { \"uid\": \"test1\", \"feature\": [\"-1\", \"20\"]}]}}"; 12 | new HttpResp(reponse); 13 | } 14 | } -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/service/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.service; 2 | 3 | public class AppTest { 4 | } 5 | -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/service/TrainServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.service; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import java.util.*; 6 | import java.util.stream.Collectors; 7 | 8 | public class TrainServiceTest { 9 | 10 | @Test 11 | public void push() { 12 | int uid = 12; 13 | double score = 1231.123117923791723923; 14 | Map map = new HashMap(); 15 | map.put("uid", uid); 16 | map.put("score", score); 17 | ArrayList picArray = new ArrayList(); 18 | picArray.add(map); 19 | } 20 | 21 | @Test 22 | public void t(){ 23 | Set tokenSet = new HashSet<>(); 24 | List needToLoad = tokenSet.stream().limit(5).collect(Collectors.toList()); 25 | 26 | for (String modelToken:needToLoad) { 27 | System.out.println(modelToken); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/type/RunningTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.type; 2 | 3 | 4 | import com.jdt.fedlearn.common.enums.RunningType; 5 | import org.testng.Assert; 6 | import org.testng.annotations.Test;; 7 | 8 | 9 | public class RunningTypeTest { 10 | 11 | private final RunningType[] runningTypes = {RunningType.RUNNING, RunningType.SUSPEND, 12 | RunningType.RESUME, RunningType.WAITING, RunningType.COMPLETE, RunningType.STOP}; 13 | 14 | @Test 15 | public void testGetRunningType() { 16 | String[] target = {"running", "suspend", "resume", "waiting", "complete", "stop"}; 17 | for (int i = 0; i < target.length; i++) { 18 | Assert.assertEquals(runningTypes[i].getRunningType(), target[i]); 19 | } 20 | } 21 | 22 | 23 | } -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/util/CastUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class CastUtilTest { 7 | public static void main(String[] args) { 8 | Map map = new HashMap<>(); 9 | map.put("key", 1); 10 | map.get("key"); 11 | System.out.println(Integer.parseInt(map.get("key").toString())); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/src/test/java/com/jdt/fedlearn/client/util/ConfigUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.client.util; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | public class ConfigUtilTest { 6 | @Test 7 | public void testUseTrain2Inference(){ 8 | String configPath = "./src/test/resources/client.properties"; 9 | try { 10 | ConfigUtil.init(configPath) ; 11 | boolean useTrain2Inference = ConfigUtil.getClientConfig().isAllowTrainUid(); 12 | System.out.println("useTrain2Inference: "+ useTrain2Inference); 13 | }catch(Exception e){ 14 | e.printStackTrace(); 15 | } 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /client/src/test/resources/data/cl1_train.csv: -------------------------------------------------------------------------------- 1 | uid,Population,MedInc 2 | 8088,1444,2.8438 3 | 19459,327,6.8654 4 | 17750,1937,4.1146 5 | 13821,1458,5.4201 6 | 16683,1068,3.5242 7 | 10760,735,15.0001 8 | 19790,918,2.2115 9 | 13415,1305,2.9107 10 | 1692,1531,6.5006 11 | 9656,1168,2.2794 12 | 19576,239,1.8958 13 | 18683,1764,4.3321 14 | 16680,2710,4.6776 15 | 10018,955,5.2359 16 | 12090,2317,2.9542 17 | 7284,1622,2.125 18 | 14483,1817,8.496 19 | 15498,685,7.745 20 | 10171,937,3.8068 21 | 11060,1334,4.7208 22 | 8875,810,13.8556 23 | 17274,1701,2.8042 24 | 9810,1480,6.777 25 | 6334,660,5.2852 26 | 5338,1435,3.9489 27 | 11606,1379,8.4952 28 | 2680,1104,1.9088 29 | 939,1524,3.7364 30 | 8484,1258,3.0139 31 | 5599,1789,3.1613 32 | -------------------------------------------------------------------------------- /client/src/test/resources/model/1-SecureBoost-123456.model: -------------------------------------------------------------------------------- 1 | ##splitSymbol##first_round_predict=0.0 2 | eta=0.0 3 | crossEntropy 4 | passiveQueryTable=[] 5 | multiClassUniqueLabelList 6 | 7 | tree[end] -------------------------------------------------------------------------------- /client/src/test/resources/model/111-FederatedGB-210119152702.model: -------------------------------------------------------------------------------- 1 | first_round_predict=0.0 2 | eta=0.3 3 | crossEntropy 4 | passiveQueryTable={"1":{"recordId":1,"featureIndex":2,"splitValue":3.4917}} 5 | multiClassUniqueLabelList 6 | 7 | tree[end] -------------------------------------------------------------------------------- /client/src/test/resources/testFileA.csv: -------------------------------------------------------------------------------- 1 | 1,2,3,4 2 | q,w,e,r 3 | 5,,, 4 | ,,,, -------------------------------------------------------------------------------- /common/src/main/java/com/jdt/fedlearn/common/entity/core/Message.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.common.entity.core; 15 | 16 | 17 | import java.io.Serializable; 18 | 19 | public interface Message extends Serializable { 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/com/jdt/fedlearn/common/entity/core/type/ReduceType.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.common.entity.core.type; 15 | 16 | public enum ReduceType { 17 | needMerge("needMerge"), 18 | noMerge("noMerge"); 19 | 20 | ReduceType(String bitLengthType) { 21 | this.bitLengthType = bitLengthType; 22 | } 23 | 24 | private final String bitLengthType; 25 | 26 | public String getBitLengthType() { 27 | return bitLengthType; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/com/jdt/fedlearn/common/entity/jdchain/JdchainCreateFeatures.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.common.entity.jdchain; 2 | 3 | import java.util.List; 4 | 5 | public class JdchainCreateFeatures { 6 | private List featureList; 7 | private String uidName; 8 | 9 | public JdchainCreateFeatures() { 10 | } 11 | 12 | public JdchainCreateFeatures(List featureList, String uidName) { 13 | this.featureList = featureList; 14 | this.uidName = uidName; 15 | } 16 | 17 | public List getFeatureList() { 18 | return featureList; 19 | } 20 | 21 | public void setFeatureList(List featureList) { 22 | this.featureList = featureList; 23 | } 24 | 25 | public String getUidName() { 26 | return uidName; 27 | } 28 | 29 | public void setUidName(String uidName) { 30 | this.uidName = uidName; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/com/jdt/fedlearn/common/enums/UrlType.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.common.enums; 2 | 3 | /** 4 | * 从协调端发起的请求枚举, 5 | */ 6 | public enum UrlType { 7 | MATCH("/api/train/match", "TODO /co/match"), 8 | START_TRAIN("/co/train/start", "发起训练"), 9 | READY("/api/query", "准备完成"), 10 | RUNNING("/api/inference", "运行中"), 11 | MODEL_DELETE("/api/system/model/delete", "发起训练"), 12 | FETCH("/api/system/metadata/fetch", "准备完成"), 13 | RUNNING2("/api/inference", "运行中"), 14 | FAIL("FAIL", "失败"), 15 | TRAIN_SPLIT_DATA("/api/train/splitData","分布式训练拆分训练数据"); 16 | 17 | private final String path; 18 | private final String desc; 19 | 20 | UrlType(String path, String desc) { 21 | this.path = path; 22 | this.desc = desc; 23 | } 24 | 25 | public String getPath() { 26 | return path; 27 | } 28 | 29 | public String getDesc() { 30 | return desc; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/test/java/com/jdt/fedlearn/common/enums/LocalUrlTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.common.enums; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | public class LocalUrlTypeTest { 7 | @Test 8 | public void testValueOf(){ 9 | System.out.println(LocalUrlType.CONFIG_QUERY.toString()); 10 | String path = "/local/config/query"; 11 | LocalUrlType type = LocalUrlType.urlOf(path); 12 | Assert.assertEquals(LocalUrlType.CONFIG_QUERY, type); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/test/java/com/jdt/fedlearn/common/enums/RunStatusEnumTest.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.common.enums; 14 | 15 | 16 | import org.testng.Assert; 17 | import org.testng.annotations.Test; 18 | 19 | public class RunStatusEnumTest { 20 | @Test 21 | public void testGetDesc() { 22 | 23 | Assert.assertEquals(RunStatusEnum.SUCCESS.getDesc(), "成功"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/test/java/com/jdt/fedlearn/common/enums/TaskTypeEnumTest.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.common.enums; 14 | 15 | 16 | import org.testng.Assert; 17 | import org.testng.annotations.Test; 18 | 19 | public class TaskTypeEnumTest { 20 | 21 | @Test 22 | public void testGetDesc() { 23 | Assert.assertEquals(TaskTypeEnum.REDUCE.getDesc(),"reduce类任务"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/test/java/com/jdt/fedlearn/common/enums/WorkerCommandEnumTest.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.common.enums; 14 | 15 | 16 | import org.testng.Assert; 17 | import org.testng.annotations.Test; 18 | 19 | public class WorkerCommandEnumTest { 20 | 21 | @Test 22 | public void testGetDesc() { 23 | Assert.assertEquals(WorkerCommandEnum.RUN_TASK.getDesc(), "运行任务"); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /common/src/test/resources/conf/manager.properties: -------------------------------------------------------------------------------- 1 | app.name=fedlearning-disframe-manager 2 | # 启动端口 3 | app.port=8095 4 | # 日志文件路径 5 | log.settings=src/test/resources/conf/logback.xml 6 | # workers端地址,多个用分号分隔 7 | workers.address=127.0.0.1:9094;127.0.0.1:9095 8 | # 默认的worker 9 | default.worker=http://127.0.0.1:9094 -------------------------------------------------------------------------------- /common/src/test/resources/file/mo17k_test.csv: -------------------------------------------------------------------------------- 1 | uid,x0,x1 2 | 291,0.21444106475157843,0.04996388474568747 3 | 292,0.7944067018474512,0.8861544687235355 4 | 293,0.658829251569282,0.4851542473709365 5 | 294,0.9339425034214133,0.6404827725090099 6 | 295,0.8312541673269118,0.6088112562622189 7 | 296,0.3353810478843261,0.30130126153951753 8 | 297,0.4706547473499929,0.26646183440057836 9 | 298,0.6035958154305429,0.7297353851688908 10 | 299,0.8445586350352466,0.8297011325240027 11 | 300,0.1378862833164921,0.6769327235205828 -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/allocation/MultiAutoTrain.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.allocation; 2 | 3 | public class MultiAutoTrain { 4 | } 5 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/dao/jdchain/ChainInferenceMapper.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.dao.jdchain; 2 | 3 | import com.jd.blockchain.ledger.TransactionResponse; 4 | import com.jdt.fedlearn.common.constant.JdChainConstant; 5 | import com.jdt.fedlearn.tools.serializer.JsonUtil; 6 | import com.jdt.fedlearn.coordinator.entity.table.InferenceEntity; 7 | import com.jdt.fedlearn.coordinator.util.JdChainUtils; 8 | 9 | /** 10 | * @className: JdchainInferenceMapper 11 | * @description: 记录推理信息 12 | * @author: geyan29 13 | * @createTime: 2021/2/2 5:01 下午 14 | */ 15 | public class ChainInferenceMapper { 16 | 17 | public static boolean insertInferenceLog(InferenceEntity inferenceEntity){ 18 | String value = JsonUtil.object2json(inferenceEntity); 19 | TransactionResponse response = JdChainUtils.saveKV(JdChainConstant.INFERENCE_TABLE_ADDRESS,inferenceEntity.getInferenceId(),value); 20 | if(response != null){ 21 | return response.isSuccess(); 22 | }else{ 23 | return false; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/dao/jdchain/ChainMatchMapper.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.dao.jdchain; 2 | 3 | import com.jd.blockchain.ledger.TransactionResponse; 4 | import com.jdt.fedlearn.common.constant.JdChainConstant; 5 | import com.jdt.fedlearn.tools.serializer.JsonUtil; 6 | import com.jdt.fedlearn.coordinator.entity.table.InferenceEntity; 7 | import com.jdt.fedlearn.coordinator.util.JdChainUtils; 8 | 9 | /** 10 | * 记录id对齐信息 11 | * @author geyan29 12 | * @version 0.8.2 2021/2/2 5:01 下午 13 | * TODO 14 | */ 15 | public class ChainMatchMapper { 16 | 17 | public static boolean insertInferenceLog(InferenceEntity inferenceEntity){ 18 | String value = JsonUtil.object2json(inferenceEntity); 19 | TransactionResponse response = JdChainUtils.saveKV(JdChainConstant.INFERENCE_TABLE_ADDRESS,inferenceEntity.getInferenceId(),value); 20 | if(response != null){ 21 | return response.isSuccess(); 22 | }else{ 23 | return false; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/dao/jdchain/ChainTaskMapper.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.dao.jdchain; 2 | 3 | import com.jdt.fedlearn.common.constant.JdChainConstant; 4 | import com.jdt.fedlearn.common.entity.jdchain.JdchainTask; 5 | import com.jdt.fedlearn.tools.serializer.JsonUtil; 6 | import com.jdt.fedlearn.coordinator.util.JdChainUtils; 7 | 8 | 9 | /** 10 | * @author geyan29 11 | * @author wangpeiqi 12 | * @version 0.8.2 2021/1/25 4:03 下午 13 | * 在区块链版本中,因表关联等不方便,所有task信息,包括标准表中 Task/Feature/Partner 14 | */ 15 | public class ChainTaskMapper { 16 | /** 17 | * @param id taskId 18 | * @description: 通过id查询task 19 | * @return: com.jdd.ml.federated.front.jdchain.mapper.entity.JdchainTask 20 | */ 21 | @Deprecated 22 | public static JdchainTask queryById(String id) { 23 | String typedKVEntries = JdChainUtils.queryLatestValueByKey(JdChainConstant.TASK_TABLE_ADDRESS, id); 24 | return JsonUtil.json2Object(typedKVEntries, JdchainTask.class); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/entity/inference/InferenceInfoCache.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.inference; 2 | 3 | import java.util.Date; 4 | 5 | public class InferenceInfoCache { 6 | private Date startTime; 7 | private int percent; 8 | private String desc; 9 | 10 | public InferenceInfoCache() { 11 | } 12 | 13 | public InferenceInfoCache(Date startTime, int percent, String desc) { 14 | this.startTime = startTime; 15 | this.percent = percent; 16 | this.desc = desc; 17 | } 18 | 19 | public Date getStartTime() { 20 | return startTime; 21 | } 22 | 23 | public void setStartTime(Date startTime) { 24 | this.startTime = startTime; 25 | } 26 | 27 | public int getPercent() { 28 | return percent; 29 | } 30 | 31 | public void setPercent(int percent) { 32 | this.percent = percent; 33 | } 34 | 35 | public String getDesc() { 36 | return desc; 37 | } 38 | 39 | public void setDesc(String desc) { 40 | this.desc = desc; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/entity/inference/InferenceRes.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.inference; 2 | 3 | import java.util.List; 4 | 5 | public class InferenceRes { 6 | private String indexName; 7 | private String[] scoreNameList; 8 | private List inferenceResList; 9 | 10 | 11 | public InferenceRes(String indexName, String[] scoreNameList, List inferenceResList) { 12 | this.indexName = indexName; 13 | this.scoreNameList = scoreNameList; 14 | this.inferenceResList = inferenceResList; 15 | } 16 | 17 | public String getIndexName() { 18 | return indexName; 19 | } 20 | 21 | public String[] getScoreNameList() { 22 | return scoreNameList; 23 | } 24 | 25 | public List getInferenceResList() { 26 | return inferenceResList; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/entity/metric/MetricPair.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.coordinator.entity.metric; 15 | 16 | /** 17 | * 指标解析,用于前端界面展示包括指标轮数和具体指标值 18 | */ 19 | public interface MetricPair { 20 | 21 | String roundString(); 22 | 23 | String metricString(); 24 | } 25 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/entity/prepare/MatchDetailRes.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.prepare; 2 | 3 | public class MatchDetailRes { 4 | private String matchType; 5 | private String taskId; 6 | 7 | public MatchDetailRes(String matchType, String taskId) { 8 | this.matchType = matchType; 9 | this.taskId = taskId; 10 | } 11 | 12 | public MatchDetailRes() { 13 | } 14 | 15 | public String getMatchType() { 16 | return matchType; 17 | } 18 | 19 | public String getTaskId() { 20 | return taskId; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/entity/prepare/MatchListRes.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.prepare; 2 | 3 | public class MatchListRes { 4 | private String matchId; 5 | private String taskId; 6 | private String runningStatus; 7 | 8 | public MatchListRes() { 9 | } 10 | 11 | public MatchListRes(String matchId, String taskId,String runningStatus) { 12 | this.matchId = matchId; 13 | this.taskId = taskId; 14 | this.runningStatus=runningStatus; 15 | } 16 | 17 | public String getMatchId() { 18 | return matchId; 19 | } 20 | 21 | public String getTaskId() { 22 | return taskId; 23 | } 24 | 25 | public String getRunningStatus() { 26 | return runningStatus; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/entity/train/CommonTrainQuery.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.train; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.jdt.fedlearn.common.exception.DeserializeException; 5 | 6 | import java.io.IOException; 7 | 8 | /** 9 | * 状态信号 10 | */ 11 | public class CommonTrainQuery { 12 | private String modelToken; 13 | 14 | public CommonTrainQuery() { 15 | } 16 | 17 | public CommonTrainQuery( String modelToken) { 18 | this.modelToken = modelToken; 19 | } 20 | 21 | public String getModelToken() { 22 | return modelToken; 23 | } 24 | 25 | public void parseJson(String jsonStr) { 26 | ObjectMapper mapper = new ObjectMapper(); 27 | CommonTrainQuery p3r; 28 | try { 29 | p3r = mapper.readValue(jsonStr, CommonTrainQuery.class); 30 | this.modelToken = p3r.modelToken; 31 | } catch (IOException e) { 32 | throw new DeserializeException(e.getMessage()); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/entity/uniqueId/UniqueId.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.uniqueId; 2 | 3 | import java.text.SimpleDateFormat; 4 | 5 | 6 | /** 7 | * 8 | */ 9 | public interface UniqueId{ 10 | String COMMON_DATE = "yyMMddHHmmss"; 11 | ThreadLocal df = ThreadLocal.withInitial(() -> new SimpleDateFormat(COMMON_DATE)); 12 | String separator = "-"; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/exception/jdchain/RandomServerException.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.exception.jdchain; 2 | 3 | public class RandomServerException extends RuntimeException{ 4 | 5 | 6 | private static final long serialVersionUID = -4921547405344670799L; 7 | 8 | public RandomServerException() { 9 | super(); 10 | } 11 | 12 | public RandomServerException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 13 | super(message, cause, enableSuppression, writableStackTrace); 14 | } 15 | 16 | public RandomServerException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public RandomServerException(String message) { 21 | super(message); 22 | } 23 | 24 | public RandomServerException(Throwable cause) { 25 | super(cause); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/exception/jdchain/StartTrainException.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.exception.jdchain; 2 | 3 | public class StartTrainException extends RuntimeException{ 4 | 5 | 6 | private static final long serialVersionUID = -6751554656273696393L; 7 | 8 | public StartTrainException() { 9 | super(); 10 | } 11 | 12 | public StartTrainException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 13 | super(message, cause, enableSuppression, writableStackTrace); 14 | } 15 | 16 | public StartTrainException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public StartTrainException(String message) { 21 | super(message); 22 | } 23 | 24 | public StartTrainException(Throwable cause) { 25 | super(cause); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/service/IAbstractDispatchService.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.coordinator.service; 15 | 16 | /** 17 | * @Name: IAbstractDispatchService 18 | */ 19 | public interface IAbstractDispatchService { 20 | 21 | /** 22 | * 处理业务逻辑抽象方法 23 | * 业务代码中需要返回接口实际结果 24 | */ 25 | Object dealService(); 26 | } 27 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/service/IDispatchService.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.coordinator.service; 15 | 16 | import java.util.Map; 17 | 18 | /** 19 | * 联邦学习顶层接口类 20 | * 21 | * @since 0.6.6 22 | */ 23 | public interface IDispatchService { 24 | 25 | /*** 26 | * 处理逻辑的服务层 27 | * @param content 内容 28 | * @return map 29 | */ 30 | // 31 | Map service(String content) throws Exception; 32 | } 33 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/service/InferenceService.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.coordinator.service; 15 | 16 | /** 17 | * @name: IInferenceService 18 | */ 19 | public interface InferenceService extends IDispatchService { 20 | } 21 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/service/TrainService.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.coordinator.service; 15 | 16 | /** 17 | * @Name: ITrainService 18 | */ 19 | public interface TrainService extends IDispatchService { 20 | } 21 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/service/validate/ValidateCommonServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.coordinator.service.validate; 15 | 16 | /** 17 | * @Name: InferenceCommonService 18 | */ 19 | public class ValidateCommonServiceImpl { 20 | 21 | public static final ValidateService VALIDATE_SERVICE = new ValidateService(); 22 | 23 | /** 24 | * 私有化构造方法 25 | */ 26 | private ValidateCommonServiceImpl() { 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /coordinator/src/main/java/com/jdt/fedlearn/coordinator/type/TuneType.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.type; 2 | 3 | public enum TuneType { 4 | BOHB("BOHB"), 5 | SMAC("SMAC"); 6 | 7 | private final String tuneType; 8 | 9 | TuneType(String tuneType) { 10 | this.tuneType = tuneType; 11 | } 12 | 13 | public String getTuneType() { 14 | return tuneType; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /coordinator/src/main/resources/fl.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fedlearnAI/fedlearn/d830fe4f384f9e78bbd43d5af948e4116332ca9a/coordinator/src/main/resources/fl.db -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/TrainContextTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity; 2 | 3 | import com.jdt.fedlearn.common.entity.SingleParameter; 4 | import com.jdt.fedlearn.coordinator.entity.train.TrainContext; 5 | import com.jdt.fedlearn.coordinator.service.prepare.AlgorithmParameterImpl; 6 | import org.testng.Assert; 7 | import org.testng.annotations.Test; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class TrainContextTest { 13 | @Test 14 | public void extractSplitRatio(){ 15 | List parameterList = new ArrayList<>(); 16 | SingleParameter singleParameter = new SingleParameter(AlgorithmParameterImpl.CROSS_VALIDATION, 1); 17 | parameterList.add(singleParameter); 18 | 19 | TrainContext context = new TrainContext(); 20 | float splitRatio = context.extractSplitRatio(parameterList); 21 | System.out.println(splitRatio); 22 | Assert.assertEquals(1.0F, splitRatio ,1e-8); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/common/ResponseConstructTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.common; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class ResponseConstructTest { 8 | 9 | 10 | 11 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/inference/TestInferenceRequest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.inference; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | public class TestInferenceRequest { 6 | @Test 7 | public void parse(){ 8 | String str= "{\"modelToken\":\"1-FederatedGB-210802162214\",\"uid\":[\"1\",\"2\",\"3\"],\"clientList\":[{\"url\":\"http://10.222.54.141:8094\",\"dataset\":\"reg0_train.csv\",\"features\":null},{\"url\":\"http://10.222.54.142:8094\",\"dataset\":\"reg1_train.csv\",\"features\":null},{\"url\":\"http://10.222.54.143:8094\",\"dataset\":\"reg2_train.csv\",\"features\":null}],\"secureMode\":false}"; 9 | InferenceRequest inferenceRequest = new InferenceRequest(str); 10 | System.out.println(inferenceRequest.getModelToken()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/metric/TestMetric.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.metric; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | import static org.testng.Assert.*; 10 | 11 | public class TestMetric { 12 | 13 | @Test 14 | public void testGetName() { 15 | String name = "RMSE"; 16 | List metricPairs = new ArrayList<>(); 17 | metricPairs.add(new SingleMetric(1,0.5)); 18 | Metric metric = new Metric(name,metricPairs); 19 | String res = metric.getName(); 20 | Assert.assertEquals(res,name); 21 | } 22 | 23 | @Test 24 | public void testGetMetric() { 25 | String name = "RMSE"; 26 | List metricPairs = new ArrayList<>(); 27 | metricPairs.add(new SingleMetric(1,0.5)); 28 | Metric metric = new Metric(name,metricPairs); 29 | List res = metric.getMetric(); 30 | Assert.assertEquals(res,metricPairs); 31 | } 32 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/prepare/AlgorithmQueryTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.prepare; 2 | 3 | import com.jdt.fedlearn.tools.serializer.JsonUtil; 4 | import org.testng.Assert; 5 | import org.testng.annotations.Test; 6 | 7 | public class AlgorithmQueryTest { 8 | 9 | @Test 10 | public void testALL() { 11 | AlgorithmQuery algorithmQuery = new AlgorithmQuery(); 12 | AlgorithmQuery algorithmQuery1 = new AlgorithmQuery("FederatedGB", 1); 13 | String s = JsonUtil.object2json(algorithmQuery1); 14 | AlgorithmQuery algorithmQuery2 = new AlgorithmQuery(s); 15 | Assert.assertEquals(algorithmQuery2.getAlgorithmType(), "FederatedGB"); 16 | Assert.assertEquals(algorithmQuery2.getTaskId(), (Integer) 1); 17 | } 18 | 19 | 20 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/system/DeleteModelReqTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.system; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | import static org.testng.Assert.*; 7 | 8 | public class DeleteModelReqTest { 9 | @Test 10 | public void testAll() { 11 | DeleteModelReq deleteModelReq = new DeleteModelReq(); 12 | deleteModelReq.setModelToken("1-FederatedGB-100"); 13 | String s = deleteModelReq.toJson(); 14 | DeleteModelReq deleteModelReq1 = new DeleteModelReq(s); 15 | DeleteModelReq deleteModelReq2 = new DeleteModelReq(); 16 | deleteModelReq2.setModelToken("1-FederatedGB-100"); 17 | Assert.assertEquals(deleteModelReq1.getModelToken(), deleteModelReq2.getModelToken()); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/system/FeatureReqTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.system; 2 | 3 | import com.jdt.fedlearn.tools.serializer.JsonUtil; 4 | import org.testng.Assert; 5 | import org.testng.annotations.Test; 6 | 7 | public class FeatureReqTest { 8 | @Test 9 | public void testAll() { 10 | FeatureReq featureReq = new FeatureReq(); 11 | featureReq.setUrl("url"); 12 | String s = JsonUtil.object2json(featureReq); 13 | FeatureReq featureReq1 = new FeatureReq(s); 14 | Assert.assertEquals(featureReq.getUrl(), featureReq1.getUrl()); 15 | 16 | 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/system/FeaturesDTOTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.system; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | public class FeaturesDTOTest { 7 | @Test 8 | public void testAll() { 9 | FeaturesDTO featuresDto = new FeaturesDTO(); 10 | featuresDto.setDtype("String"); 11 | featuresDto.setName("name"); 12 | Assert.assertEquals(featuresDto.getDtype(), "String"); 13 | Assert.assertEquals(featuresDto.getName(), "name"); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/system/FeaturesDatasetDTOTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.system; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class FeaturesDatasetDTOTest { 9 | @Test 10 | public void testAll() { 11 | FeaturesDatasetDTO featuresDatasetDto = new FeaturesDatasetDTO(); 12 | featuresDatasetDto.setDataset("a.csv"); 13 | featuresDatasetDto.setFeatures(new ArrayList<>()); 14 | Assert.assertEquals(featuresDatasetDto.getDataset(), "a.csv"); 15 | Assert.assertEquals(featuresDatasetDto.getFeatures().size(), 0); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/table/TestTrainInfo.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.table; 2 | 3 | public class TestTrainInfo { 4 | 5 | 6 | 7 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/task/CreateQueryTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.task; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class CreateQueryTest { 8 | @Test 9 | public void testAll() { 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/train/TrainListResTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.train; 2 | 3 | import com.jdt.fedlearn.common.enums.RunningType; 4 | import com.jdt.fedlearn.tools.serializer.JsonUtil; 5 | import org.testng.Assert; 6 | import org.testng.annotations.Test; 7 | 8 | public class TrainListResTest { 9 | @Test 10 | public void test() { 11 | TrainListRes trainListRes = new TrainListRes(); 12 | TrainListRes trainListRes1 = new TrainListRes("", RunningType.COMPLETE, ""); 13 | String s = JsonUtil.object2json(trainListRes1); 14 | TrainListRes trainListRes2 = new TrainListRes(s); 15 | Assert.assertEquals(trainListRes1.getModelToken(), trainListRes2.getModelToken()); 16 | Assert.assertEquals(trainListRes1.getRunningStatus(), trainListRes2.getRunningStatus()); 17 | Assert.assertEquals(trainListRes1.getTaskId(), trainListRes2.getTaskId()); 18 | 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/train/TrainProgressResQueryTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.train; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.jdt.fedlearn.tools.serializer.JsonUtil; 5 | import com.jdt.fedlearn.common.exception.DeserializeException; 6 | import org.testng.Assert; 7 | import org.testng.annotations.Test; 8 | 9 | public class TrainProgressResQueryTest { 10 | 11 | @Test 12 | public void testTrainProgressQuery() { 13 | TrainParameterQuery trainParameterQuery = new TrainParameterQuery("1"); 14 | String s = JsonUtil.object2json(trainParameterQuery); 15 | try { 16 | TrainParameterQuery trainParameterQuery1 = TrainParameterQuery.parseJson(s); 17 | } catch (DeserializeException | JsonProcessingException e) { 18 | Assert.assertEquals(e.getMessage(), "train query"); 19 | } 20 | Assert.assertEquals(trainParameterQuery.getModelToken(), "1"); 21 | 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/entity/train/TrainProgressResTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.entity.train; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import java.util.Arrays; 6 | 7 | public class TrainProgressResTest { 8 | @Test 9 | public void testNewStatus(){ 10 | TrainProgressRes endStatus = new TrainProgressRes(100, 11 | Arrays.asList("开始", "参数初始化成功", "正在训练模型", "训练结束", "weightDesc", "taskIdDesc")); 12 | // 设置modelToken 13 | endStatus.setCompleteStatus("predictDesc"); 14 | } 15 | 16 | @Test 17 | public void testNew(){ 18 | TrainProgressRes endStatus = new TrainProgressRes(10, 19 | Arrays.asList("开始", "参数初始化成功", "正在训练模型", "训练结束", "weightDesc", "taskIdDesc")); 20 | // 设置modelToken 21 | endStatus.setStatus(30, "predictDesc"); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/service/CommonServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.service; 2 | 3 | import com.jdt.fedlearn.coordinator.exception.NotAcceptableException; 4 | import org.testng.Assert; 5 | import org.testng.annotations.Test; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | 11 | public class CommonServiceTest { 12 | 13 | @Test 14 | public void testFail() { 15 | Map res = CommonService.fail("000"); 16 | Assert.assertEquals(res.get("code"), "000"); 17 | Assert.assertEquals(res.get("status"), "fail"); 18 | 19 | } 20 | 21 | @Test 22 | public void testExceptionProcess() { 23 | Map ResMap = CommonService.exceptionProcess(new NotAcceptableException(), new HashMap<>()); 24 | Assert.assertEquals(ResMap.get("code"), -1); 25 | Map ResMap2 = CommonService.exceptionProcess(new Exception(), new HashMap<>()); 26 | Assert.assertEquals(ResMap2.get("code"), -4); 27 | } 28 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/service/inference/InferenceCommonServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.service.inference; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class InferenceCommonServiceTest { 8 | 9 | @Test 10 | public void testBatchInference() { 11 | } 12 | 13 | @Test 14 | public void testBuildPercentStart() { 15 | } 16 | 17 | @Test 18 | public void testBuildPercentProgress() { 19 | } 20 | 21 | @Test 22 | public void testCommonInference() { 23 | } 24 | 25 | @Test 26 | public void testPredictRemote() { 27 | } 28 | 29 | @Test 30 | public void testInferenceCore() { 31 | } 32 | 33 | @Test 34 | public void testPredictQuery() { 35 | } 36 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/service/prepare/CommonParameterImplTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.service.prepare; 2 | 3 | import com.jdt.fedlearn.core.parameter.common.ParameterField; 4 | import com.jdt.fedlearn.core.type.ParameterType; 5 | import org.testng.Assert; 6 | import org.testng.annotations.Test; 7 | 8 | import java.util.List; 9 | 10 | import static org.testng.Assert.*; 11 | 12 | public class CommonParameterImplTest { 13 | 14 | @Test 15 | public void testGetCommonParams() { 16 | CommonParameterImpl commonParameterImpl = new CommonParameterImpl(); 17 | List parameterFields = commonParameterImpl.getCommonParams(); 18 | Assert.assertEquals(parameterFields.size(), 1); 19 | Assert.assertEquals(parameterFields.get(0).getType(), ParameterType.STRING); 20 | Assert.assertEquals(parameterFields.get(0).getField(), "matchAlgorithm"); 21 | System.out.println(parameterFields.get(0)); 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/service/train/TrainStartServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.service.train; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class TrainStartServiceImplTest { 8 | 9 | @Test 10 | public void testStart() { 11 | 12 | } 13 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/service/validate/ValidateBatchServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.service.validate; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class ValidateBatchServiceImplTest { 8 | 9 | @Test 10 | public void testService() { 11 | } 12 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/type/RunningTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.type; 2 | 3 | import com.jdt.fedlearn.common.enums.RunningType; 4 | import org.testng.annotations.Test; 5 | import org.ujmp.core.util.R; 6 | 7 | import static org.testng.Assert.*; 8 | 9 | public class RunningTypeTest { 10 | 11 | private final RunningType[] runningTypes = {RunningType.RUNNING, RunningType.SUSPEND, 12 | RunningType.WAITING, RunningType.COMPLETE, RunningType.STOP}; 13 | @Test 14 | public void testGetRunningType() { 15 | String[] target = {"running","suspend","waiting","complete","stop"}; 16 | for (int i = 0;i < target.length;i++){ 17 | assertEquals(runningTypes[i].getRunningType(),target[i]); 18 | } 19 | } 20 | 21 | @Test 22 | public void testRunningType(){ 23 | 24 | RunningType runningType = RunningType.COMPLETE; 25 | String res = runningType.toString(); 26 | System.out.println("runningtype" + res); 27 | 28 | } 29 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/util/DbUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.util; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | public class DbUtilTest { 6 | 7 | // @Test(expectedExceptions = ExceptionInInitializerError.class) 8 | // public void testGetConnection() throws SQLException { 9 | // DbUtil.getConnection(); 10 | // } 11 | 12 | @Test 13 | public void testClose() { 14 | } 15 | 16 | @Test 17 | public void testTestClose() { 18 | } 19 | 20 | @Test 21 | public void testGetDbType() { 22 | } 23 | } -------------------------------------------------------------------------------- /coordinator/src/test/java/com/jdt/fedlearn/coordinator/util/LogbackConfigTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.coordinator.util; 2 | 3 | 4 | import ch.qos.logback.core.joran.spi.JoranException; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.testng.annotations.Test; 8 | 9 | import java.io.IOException; 10 | import java.util.Date; 11 | 12 | public class LogbackConfigTest { 13 | 14 | @Test 15 | public void test1() throws IOException, JoranException { 16 | LogbackConfigLoader.load("src/test/resources/logback-test.xml"); 17 | Logger logger = LoggerFactory.getLogger(LogbackConfigLoader.class); 18 | logger.debug("现在的时间是 {}", new Date().toString()); 19 | logger.info(" This time is {}", new Date().toString()); 20 | logger.warn(" This time is {}", new Date().toString()); 21 | logger.error(" This time is {}", new Date().toString()); 22 | // @SuppressWarnings("unused") 23 | // int n = 1 / 0; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /coordinator/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0} - %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /coordinator/src/test/resources/testTXT.txt: -------------------------------------------------------------------------------- 1 | abc 2 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/encryption/README.md: -------------------------------------------------------------------------------- 1 | ## 同态加密模块 2 | ----- 3 | 包含纯 Java版本Paillier, 底层为GMP的Javallier, -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/encryption/common/Ciphertext.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.common; 2 | 3 | public interface Ciphertext { 4 | /** 5 | * 将对象类型的密文序列化 6 | * @return 字符串类型的密文 7 | */ 8 | String serialize(); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/encryption/common/PrivateKey.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.encryption.common; 15 | 16 | public interface PrivateKey { 17 | /** 18 | * 将对象类型的秘钥序列化 19 | * @return 字符串类型的秘钥 20 | */ 21 | String serialize(); 22 | 23 | /** 24 | * 25 | * @return 根据私钥生成公钥 26 | */ 27 | PublicKey generatePublicKey(); 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/encryption/common/PublicKey.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.common; 2 | 3 | public interface PublicKey { 4 | /** 5 | * 将对象类型的秘钥序列化 6 | * @return 字符串类型的秘钥 7 | */ 8 | String serialize(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/encryption/differentialPrivacy/DifferentialPrivacyFactory.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.differentialPrivacy; 2 | 3 | import com.jdt.fedlearn.core.exception.NotImplementedException; 4 | import com.jdt.fedlearn.core.type.DifferentialPrivacyType; 5 | 6 | public class DifferentialPrivacyFactory { 7 | 8 | public static IDifferentialPrivacy createDifferentialPrivacy(DifferentialPrivacyType type){ 9 | IDifferentialPrivacy dp = null; 10 | switch (type) { 11 | case OUTPUT_PERTURB: 12 | dp = new OutputPerturbDPImpl(); 13 | break; 14 | case OBJECTIVE_PERTURB: 15 | dp = new ObjectivePerturbDPImpl(); 16 | break; 17 | default: 18 | throw new NotImplementedException(type + ": not implemented differential privacy type"); 19 | } 20 | return dp; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/encryption/differentialPrivacy/IDifferentialPrivacy.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.differentialPrivacy; 2 | 3 | 4 | 5 | /** 6 | * @author songjixian 7 | * 差分隐私噪声生成等。 8 | */ 9 | public interface IDifferentialPrivacy { 10 | 11 | /** 12 | * 初始化差分隐私参数 13 | * @param shape 噪声向量的size 14 | * @param maxEpochs 训练的最大轮数 15 | * @param datasetSize 数据集的大小 16 | * @param epsilon 噪声生成参数epsilon 17 | * @param delta 差分隐私delta参数 18 | * @param lambda 目标扰动参数 19 | * @param eta 学习率 20 | */ 21 | void init(int shape, int maxEpochs, int datasetSize, double epsilon, double delta, double lambda, double eta, long seed); 22 | 23 | void generateNoises(); 24 | 25 | /** 26 | * 获取差分隐私的噪声向量 27 | * @return noises 28 | */ 29 | double[] getNoises(); 30 | 31 | void addNoises(double[] origin, double[] weight); 32 | 33 | void addNoises(double[][] origin, double[][] weight, int index); 34 | 35 | default double getC(){ 36 | return 0.0; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/encryption/distributedPaillier/comm/MockSendRecv.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.distributedPaillier.comm; 2 | 3 | public class MockSendRecv { 4 | static public void mockSend(Object in, String address) { 5 | } 6 | 7 | static public Object mockRecv(Object in, String address) { 8 | return in; 9 | } 10 | 11 | static public void mockSync() { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/base/Double2dArray.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.base; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class Double2dArray implements Message { 9 | private final double[][] data; 10 | 11 | public Double2dArray() { 12 | this.data = new double[0][0]; 13 | } 14 | 15 | public Double2dArray(double[][] data) { 16 | this.data = data; 17 | } 18 | 19 | public Double2dArray(List data) { 20 | this.data = data.toArray(new double[0][]); 21 | } 22 | 23 | public double[][] getData() { 24 | return data; 25 | } 26 | 27 | public List getListData(){ 28 | List list = new ArrayList<>(); 29 | for(int i =0; i data) { 19 | this.data = data.toArray(new int[0][]); 20 | } 21 | 22 | public int[][] getData() { 23 | return data; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/base/IntArray.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.base; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | 6 | public class IntArray implements Message { 7 | private final int[] data; 8 | 9 | public IntArray(int[] data) { 10 | this.data = data; 11 | } 12 | 13 | public int[] getData() { 14 | return data; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/base/SingleElement.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.core.entity.base; 14 | 15 | import com.jdt.fedlearn.common.entity.core.Message; 16 | 17 | public class SingleElement implements Message { 18 | private final String element; 19 | 20 | public SingleElement(String a) { 21 | element = a; 22 | } 23 | 24 | public String getElement() { 25 | return element; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/base/StringArray.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.base; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | public class StringArray implements Message { 6 | private final String[] data; 7 | 8 | public StringArray(String[] data) { 9 | this.data = data; 10 | } 11 | 12 | public String[] getData() { 13 | return data; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/base/UniversalArray.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.base; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | public class UniversalArray implements Message { 6 | private final T[] data; 7 | 8 | public UniversalArray(T[] data) { 9 | this.data = data; 10 | } 11 | 12 | public T[] getData() { 13 | return data; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/delphiInference/DelphiMsg.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.delphiInference; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * 用于调用delphi python接口传输json的类 9 | * @author lijingxi 10 | */ 11 | public class DelphiMsg implements Message { 12 | private Map msg; 13 | private String strMsg; 14 | 15 | public DelphiMsg(Map msg) { 16 | this.msg = msg; 17 | } 18 | 19 | public DelphiMsg() { 20 | } 21 | 22 | public DelphiMsg(String strMsg) { 23 | this.strMsg = strMsg; 24 | } 25 | 26 | public Map getMsg() { 27 | return msg; 28 | } 29 | 30 | public void setMsg(Map msg) { 31 | this.msg = msg; 32 | } 33 | 34 | public String getStrMsg() { 35 | return strMsg; 36 | } 37 | 38 | public void setStrMsg(String strMsg) { 39 | this.strMsg = strMsg; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/distributedKeyGeneMsg/EmptyKeyGeneMsg.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.distributedKeyGeneMsg; 2 | 3 | public class EmptyKeyGeneMsg extends KeyGeneMsg{ 4 | 5 | public EmptyKeyGeneMsg(int reqTypeCode) { 6 | super(reqTypeCode); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/distributedKeyGeneMsg/KeyGeneMsg.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.distributedKeyGeneMsg; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | public class KeyGeneMsg implements Message { 6 | 7 | public int reqTypeCode; 8 | 9 | public KeyGeneMsg(int reqTypeCode) { 10 | this.reqTypeCode = reqTypeCode; 11 | } 12 | 13 | 14 | public int getReqTypeCode() { 15 | return reqTypeCode; 16 | } 17 | } -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/distributedKeyGeneMsg/LongTypeMsg.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.distributedKeyGeneMsg; 2 | 3 | import java.util.Set; 4 | 5 | import static com.jdt.fedlearn.core.type.KeyGeneReqType.VALIDATE_N; 6 | 7 | public class LongTypeMsg extends KeyGeneMsg { 8 | 9 | private final Set idxSet; 10 | public LongTypeMsg(int reqTypeCode, Set idxSet) { 11 | super(reqTypeCode); 12 | this.idxSet = idxSet; 13 | 14 | assert(reqTypeCode == VALIDATE_N.getPhaseValue()); 15 | } 16 | 17 | public Set getIdxSet() { 18 | return idxSet; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/distributedKeyGeneMsg/PiQiAndLongTypeMsg.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.distributedKeyGeneMsg; 2 | 3 | import com.jdt.fedlearn.core.encryption.distributedPaillier.DistributedPaillierNative.signedByteArray; 4 | 5 | import java.util.List; 6 | import java.util.Set; 7 | 8 | public class PiQiAndLongTypeMsg extends LongTypeMsg{ 9 | private final List pi; 10 | private final List qi; 11 | public PiQiAndLongTypeMsg(int reqTypeCode, List pi, List qi, Set idxSet) { 12 | super(reqTypeCode, idxSet); 13 | this.pi = pi; 14 | this.qi = qi; 15 | } 16 | public List getPi() { 17 | return pi; 18 | } 19 | 20 | public List getQi() { 21 | return qi; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/distributedKeyGeneMsg/PiQiSharesFromParty.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.distributedKeyGeneMsg; 2 | 3 | import com.jdt.fedlearn.core.encryption.distributedPaillier.DistributedPaillierNative.signedByteArray; 4 | 5 | import java.util.List; 6 | 7 | public class PiQiSharesFromParty extends KeyGeneMsg { 8 | 9 | public PiQiSharesFromParty(int reqTypeCode, 10 | List piIn , 11 | List qiIn) { 12 | super(reqTypeCode); 13 | piShare = piIn; 14 | qiShare = qiIn; 15 | } 16 | private final List piShare; 17 | private final List qiShare; 18 | 19 | public List getPiShare() { 20 | return piShare; 21 | } 22 | 23 | public List getQiShare() { 24 | return qiShare; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/distributedKeyGeneMsg/SbArrayListMsg.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.distributedKeyGeneMsg; 2 | 3 | import com.jdt.fedlearn.core.encryption.distributedPaillier.DistributedPaillierNative.signedByteArray; 4 | 5 | import java.util.List; 6 | 7 | public class SbArrayListMsg extends KeyGeneMsg { 8 | public SbArrayListMsg(int reqTypeCode, 9 | List> in) { 10 | super(reqTypeCode); 11 | body = in; 12 | } 13 | private final List> body; 14 | 15 | public List> getBody() { 16 | return body; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/distributedKeyGeneMsg/SbArrayMsg.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.distributedKeyGeneMsg; 2 | 3 | import com.jdt.fedlearn.core.encryption.distributedPaillier.DistributedPaillierNative.signedByteArray; 4 | 5 | import java.util.List; 6 | 7 | public class SbArrayMsg extends KeyGeneMsg { 8 | public SbArrayMsg(int reqTypeCode, 9 | List in) { 10 | super(reqTypeCode); 11 | body = in; 12 | } 13 | private final List body; 14 | 15 | public List getBody() { 16 | return body; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/distributedKeyGeneMsg/SelectedIdxMsg.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.distributedKeyGeneMsg; 2 | 3 | import com.jdt.fedlearn.core.encryption.distributedPaillier.DistributedPaillierNative; 4 | 5 | import static com.jdt.fedlearn.core.type.KeyGeneReqType.GENE_LAMBDA_BETA_SHARES; 6 | 7 | public class SelectedIdxMsg extends KeyGeneMsg { 8 | private final int idx; 9 | private final DistributedPaillierNative.signedByteArray selectedN; 10 | public SelectedIdxMsg(int reqTypeCode, int idx, DistributedPaillierNative.signedByteArray selectedN) { 11 | super(reqTypeCode); 12 | this.idx = idx; 13 | this.selectedN = selectedN; 14 | assert(reqTypeCode == GENE_LAMBDA_BETA_SHARES.getPhaseValue()); 15 | } 16 | 17 | public int getIdx() { 18 | return idx; 19 | } 20 | 21 | public DistributedPaillierNative.signedByteArray getSelectedN() { 22 | return selectedN; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/distributedKeyGeneMsg/Shares4AllOtherParties.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.distributedKeyGeneMsg; 2 | 3 | import com.jdt.fedlearn.core.encryption.distributedPaillier.DistributedPaillierNative.signedByteArray; 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public class Shares4AllOtherParties extends KeyGeneMsg { 9 | 10 | Map>> shares; 11 | 12 | public Shares4AllOtherParties(int reqTypeCode, Map>> in 13 | ) { 14 | super(reqTypeCode); 15 | shares = in; 16 | } 17 | 18 | public Map>> getShare() { 19 | return shares; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/mixGBoost/BoostInferScoreReq.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.entity.mixGBoost; 15 | 16 | import com.jdt.fedlearn.common.entity.core.Message; 17 | 18 | 19 | /** 20 | * @author zhangwenxi 21 | */ 22 | public class BoostInferScoreReq implements Message { 23 | public BoostInferScoreReq() { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/mixedLinearRegression/CypherMessage2DList.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.mixedLinearRegression; 2 | 3 | import com.jdt.fedlearn.core.encryption.distributedPaillier.DistributedPaillierNative; 4 | import com.jdt.fedlearn.common.entity.core.Message; 5 | 6 | import java.util.List; 7 | 8 | public class CypherMessage2DList implements Message { 9 | 10 | private List body; 11 | 12 | public CypherMessage2DList(List in) { 13 | this.body = in; 14 | } 15 | 16 | public List getBody() { 17 | return body; 18 | } 19 | 20 | public void setBody(List body) { 21 | this.body = body; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/mixedLinearRegression/CypherMessageList.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.mixedLinearRegression; 2 | 3 | import com.jdt.fedlearn.core.encryption.distributedPaillier.DistributedPaillierNative; 4 | import com.jdt.fedlearn.common.entity.core.Message; 5 | 6 | import java.util.List; 7 | 8 | public class CypherMessageList implements Message { 9 | 10 | private List body; 11 | 12 | public CypherMessageList(List in) { 13 | this.body = in; 14 | } 15 | 16 | public List getBody() { 17 | return body; 18 | } 19 | 20 | public void setBody(List body) { 21 | this.body = body; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/mixedLinearRegression/PartialDecMessage.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.mixedLinearRegression; 2 | 3 | import com.jdt.fedlearn.core.encryption.distributedPaillier.DistributedPaillierNative; 4 | import com.jdt.fedlearn.common.entity.core.Message; 5 | 6 | import java.util.Map; 7 | 8 | public class PartialDecMessage implements Message { 9 | 10 | Map body; 11 | 12 | public PartialDecMessage(Map in) { 13 | body = in; 14 | } 15 | 16 | public Map getBody() { 17 | return body; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/mixedLinearRegression/TwoCypherMessage.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.mixedLinearRegression; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | public class TwoCypherMessage implements Message { 6 | 7 | CypherMessage first; 8 | CypherMessage second; 9 | 10 | public TwoCypherMessage(CypherMessage first, CypherMessage second) { 11 | this.first = first; 12 | this.second = second; 13 | } 14 | 15 | public CypherMessage getFirst() { 16 | return first; 17 | } 18 | 19 | public void setFirst(CypherMessage first) { 20 | this.first = first; 21 | } 22 | 23 | public CypherMessage getSecond() { 24 | return second; 25 | } 26 | 27 | public void setSecond(CypherMessage second) { 28 | this.second = second; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/psi/DhMatchRes2.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.psi; 2 | 3 | import com.jdt.fedlearn.common.entity.core.ClientInfo; 4 | import com.jdt.fedlearn.common.entity.core.Message; 5 | 6 | import java.util.Map; 7 | 8 | public class DhMatchRes2 implements Message { 9 | Map intersection; 10 | Map clientDoubleCipher; 11 | 12 | public DhMatchRes2(Map intersection, Map clientDoubleCipher) { 13 | this.intersection = intersection; 14 | this.clientDoubleCipher = clientDoubleCipher; 15 | } 16 | 17 | public Map getIntersection() { 18 | return intersection; 19 | } 20 | 21 | public Map getClientDoubleCipher() { 22 | return clientDoubleCipher; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/psi/FreedmanEncryption.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.psi; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | public class FreedmanEncryption implements Message { 6 | private String[] encryptedCoefficients; 7 | private String publicKey; 8 | 9 | public FreedmanEncryption(String[] encryptedCoefficients, String publicKey) { 10 | this.encryptedCoefficients = encryptedCoefficients; 11 | this.publicKey = publicKey; 12 | } 13 | 14 | public String[] getEncryptedCoefficients() { 15 | return encryptedCoefficients; 16 | } 17 | 18 | public String getPublicKey() { 19 | return publicKey; 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/psi/FreedmanPassiveIdx.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.psi; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | public class FreedmanPassiveIdx implements Message { 6 | private int[] passiveIndex; 7 | 8 | public FreedmanPassiveIdx(int[] passiveIndex) { 9 | this.passiveIndex = passiveIndex; 10 | } 11 | 12 | public int[] getPassiveIndex() { 13 | return passiveIndex; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/psi/FreedmanPassiveIdxMap.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.psi; 2 | 3 | import com.jdt.fedlearn.common.entity.core.ClientInfo; 4 | import com.jdt.fedlearn.common.entity.core.Message; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * 用于Freedman 由active向master传送各个非active方对齐好的id对应index 10 | */ 11 | public class FreedmanPassiveIdxMap implements Message { 12 | private Map indexResMap; 13 | 14 | public FreedmanPassiveIdxMap(Map indexResMap) { 15 | this.indexResMap = indexResMap; 16 | } 17 | 18 | public Map getIndexResMap() { 19 | return indexResMap; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/psi/FreedmanPassiveResult.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.psi; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | public class FreedmanPassiveResult implements Message { 6 | private String[] passiveResult; 7 | 8 | public FreedmanPassiveResult(String[] passiveResult) { 9 | this.passiveResult = passiveResult; 10 | } 11 | 12 | public String[] getPassiveResult() { 13 | return passiveResult; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/psi/FreedmanPassiveUidMap.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.psi; 2 | 3 | import com.jdt.fedlearn.common.entity.core.ClientInfo; 4 | import com.jdt.fedlearn.common.entity.core.Message; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * Freedman ID对齐算法在master端的phase3时的请求实体 10 | * 非主动方加密好的多项式计算结果 11 | * @author lijingxi 12 | */ 13 | public class FreedmanPassiveUidMap implements Message { 14 | private Map passiveUidMap; 15 | 16 | public FreedmanPassiveUidMap(Map passiveUidMap) { 17 | this.passiveUidMap = passiveUidMap; 18 | } 19 | 20 | public Map getPassiveUidMap() { 21 | return passiveUidMap; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/entity/serialize/BinarySerializer.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.serialize; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | import com.jdt.fedlearn.tools.serializer.Serializer; 5 | 6 | public class BinarySerializer implements Serializer { 7 | @Override 8 | public String serialize(Message message) { 9 | return null; 10 | } 11 | 12 | @Override 13 | public Message deserialize(String str) { 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/exception/WrongValueException.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.exception; 2 | 3 | public class WrongValueException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 3816979698933373512L; 6 | 7 | public WrongValueException() { 8 | super(); 9 | } 10 | 11 | public WrongValueException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 12 | super(message, cause, enableSuppression, writableStackTrace); 13 | } 14 | 15 | public WrongValueException(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | 19 | public WrongValueException(String message) { 20 | super(message); 21 | } 22 | 23 | public WrongValueException(Throwable cause) { 24 | super(cause); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/loader/common/CommonTestData.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.loader.common; 15 | 16 | public class CommonTestData extends AbstractTestData { 17 | 18 | //TODO refactor 19 | public CommonTestData(String[][] rawData) { 20 | super.scan(rawData, null); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/loader/common/InferenceData.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.loader.common; 15 | 16 | public interface InferenceData extends Data { 17 | 18 | int[] getFakeIdIndex(); 19 | 20 | void filterOtherUid(String[] partUid); 21 | 22 | int getFeatureDim(); 23 | 24 | int getDatasetSize(); 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/loader/common/TestData.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.loader.common; 15 | 16 | public interface TestData extends Data { 17 | double[] getLabel(); 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/loader/common/TrainData.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.loader.common; 15 | 16 | public interface TrainData extends Data { 17 | 18 | // //TODO 改成返回 matrix 19 | double[][] getSample(); 20 | 21 | String[] getUid(); 22 | 23 | String[] getFeatureName(); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/math/Matrix.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.math; 15 | 16 | public interface Matrix{ 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/math/NormalizerOutPackage.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.math; 2 | 3 | public class NormalizerOutPackage { 4 | /* 5 | ## All member functions. 6 | */ 7 | // constructor 8 | public NormalizerOutPackage() { 9 | // normalizedTable = null; 10 | params1 = null; 11 | params2 = null; 12 | } 13 | 14 | /* 15 | ## All member variables. 16 | */ 17 | // public String[][] normalizedTable; 18 | public double[] params1; 19 | public double[] params2; 20 | } -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/math/Scalar.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.math; 15 | 16 | public interface Scalar { 17 | Scalar add(Scalar another); 18 | 19 | Scalar mul(Scalar scalar); 20 | 21 | int getEle(); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/math/Vector.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.math; 15 | 16 | public interface Vector { 17 | Vector add(Vector vector); 18 | int getLength(); 19 | 20 | int size(); 21 | 22 | int[] getEle(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/math/base/FlScalar.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.math.base; 2 | 3 | import com.jdt.fedlearn.core.math.Scalar; 4 | 5 | import java.util.Objects; 6 | 7 | public class FlScalar implements Scalar { 8 | private final int a; 9 | 10 | public FlScalar(int a) { 11 | this.a = a; 12 | } 13 | 14 | public Scalar mul(Scalar scalar){ 15 | return new FlScalar(scalar.getEle() * this.getEle()) ; 16 | } 17 | 18 | public Scalar add(Scalar scalar){ 19 | return new FlScalar(scalar.getEle() + this.a); 20 | } 21 | 22 | public int getEle(){ 23 | return a; 24 | } 25 | 26 | @Override 27 | public boolean equals(Object o) { 28 | if (this == o) { 29 | return true; 30 | } 31 | if (o == null || getClass() != o.getClass()){ 32 | return false; 33 | } 34 | FlScalar flScalar = (FlScalar) o; 35 | return a == flScalar.a; 36 | } 37 | 38 | @Override 39 | public int hashCode() { 40 | return Objects.hash(a); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/math/ejml/EjMatrix.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.math.ejml; 2 | 3 | import com.jdt.fedlearn.core.math.Matrix; 4 | import org.ejml.simple.SimpleMatrix; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * 底层采用ejml实现的 matrix 10 | */ 11 | public class EjMatrix implements Matrix { 12 | private static final Logger logger = LoggerFactory.getLogger(EjMatrix.class); 13 | private SimpleMatrix matrix; 14 | 15 | public EjMatrix(int numTrees) { 16 | this.matrix = new SimpleMatrix(1, numTrees); 17 | logger.info("EjMatrix", matrix); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/math/package-info.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | /** 15 | * 数学计算包,底层目前采用 16 | * ujmp https://ujmp.org/ 17 | * 后续可替换为其他数学工具包 18 | */ 19 | package com.jdt.fedlearn.core.math; -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/model/common/loss/ActivationFunction.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.model.common.loss; 15 | 16 | public class ActivationFunction { 17 | public static double[] loss(double[] a) { 18 | return new double[2]; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/model/serialize/ModelSerializer.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.model.serialize; 2 | 3 | import java.io.Serializable; 4 | 5 | public interface ModelSerializer extends Serializable { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/optimizer/bfgs/WeightedLinRegLossNonprivClient.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.optimizer.bfgs; 2 | 3 | public class WeightedLinRegLossNonprivClient extends WeightedLinRegBFGSSolver { 4 | 5 | public WeightedLinRegLossNonprivClient(double[][] x, double[] w, double[] y, double stepLength, 6 | double lambda) { 7 | super(x, w, y, stepLength, lambda); 8 | } 9 | 10 | public WeightedLinRegLossNonprivClient(double[][] x, double[] w) { 11 | super(x, w); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/preprocess/FeatureEngineering.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.preprocess; 2 | 3 | /** 4 | * Feature Engineering: 5 | * 用途: 6 | * 对主动方/被动方的数据进行变换,以达到更好的建模效果 7 | */ 8 | public interface FeatureEngineering { 9 | 10 | /** 11 | * 训练时的feature engineering:给定feature name,对该 feature 进行变换 12 | * @return 变换后的feature: double[] 13 | */ 14 | double[] transformTrain(String featureName, double[] featureValues); 15 | double[] transformTrain(String featureName, String[] featureValues); 16 | 17 | /** 18 | * 推理时的feature engineering:给定feature name,对该 feature 进行变换 19 | * @return 变换后的feature: double[] 20 | */ 21 | double[] transformInference(String featureName, double[] featureValues); 22 | double[] transformInference(String featureName, String[] featureValues); 23 | 24 | /** 25 | * 序列化模型 26 | * @return 模型string 27 | */ 28 | String serialize(); 29 | 30 | /** 31 | * 反序列化模型 32 | * @param s 模型string 33 | * @return 模型 34 | */ 35 | FeatureEngineering deserialize(String s); 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/preprocess/Scaler.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.preprocess; 15 | 16 | public interface Scaler { 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/preprocess/package-info.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.core.preprocess; 14 | 15 | //数据预处理 -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/research/ScoreCard.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.research; 15 | 16 | 17 | /** 18 | * 评分卡模型 19 | * 参考下面链接实现 20 | * https://github.com/ShichenXie/scorecardpy/tree/master/scorecardpy 21 | */ 22 | public class ScoreCard { 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/research/mpc/Mpc.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.research.mpc; 15 | 16 | public class Mpc { 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/type/BitLengthType.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.type; 15 | 16 | public enum BitLengthType { 17 | bit512(512), 18 | bit1024(1024), 19 | bit2048(2048); 20 | 21 | BitLengthType(int bitLengthType) { 22 | this.bitLengthType = bitLengthType; 23 | } 24 | 25 | private final int bitLengthType; 26 | 27 | public int getBitLengthType() { 28 | return bitLengthType; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/type/DifferentialPrivacyType.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import java.util.Arrays; 4 | 5 | public enum DifferentialPrivacyType { 6 | 7 | OUTPUT_PERTURB("OutputPerturb"), 8 | OBJECTIVE_PERTURB("ObjectivePerturb"); 9 | 10 | private final String type; 11 | 12 | DifferentialPrivacyType(String type){ 13 | this.type = type; 14 | } 15 | 16 | public String getDifferentialPrivacyType(){ 17 | return this.type; 18 | } 19 | 20 | public static DifferentialPrivacyType[] getDifferentialPrivacyTypes(){ 21 | return DifferentialPrivacyType.values(); 22 | } 23 | 24 | public static String[] getDifferentialPrivacies(){ 25 | return Arrays.stream(DifferentialPrivacyType.values()).map(DifferentialPrivacyType::getDifferentialPrivacyType).toArray(String[]::new); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/type/EncryptionType.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.type; 15 | 16 | 17 | public enum EncryptionType { 18 | Paillier("Paillier"), 19 | Javallier("Javallier"), 20 | Palisade("Palisade"), 21 | ; 22 | 23 | private final String type; 24 | 25 | EncryptionType(String type) { 26 | this.type = type; 27 | } 28 | 29 | public String getEncryptionType() { 30 | return type; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/type/FeatureType.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.type; 15 | 16 | public enum FeatureType { 17 | String("String"), 18 | Float("Float"), 19 | Bool("Bool"), 20 | Int("Int"); 21 | 22 | private final String featureType; 23 | 24 | FeatureType(String featureType) { 25 | this.featureType = featureType; 26 | } 27 | 28 | public String getFeatureType() { 29 | return featureType; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/type/FirstPredictType.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.type; 15 | 16 | public enum FirstPredictType { 17 | AVG("avg"), 18 | ZERO("zero"), 19 | RANDOM("random"); 20 | 21 | private final String firsPredictType; 22 | 23 | FirstPredictType(String firsPredictType) { 24 | this.firsPredictType = firsPredictType; 25 | } 26 | 27 | public String getFirsPredictType() { 28 | return firsPredictType; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/type/OptimizerType.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.type; 15 | 16 | public enum OptimizerType { 17 | NEWTON("NEWTON"), 18 | BFGS("bfgs"), 19 | BatchGD("batchGD"), 20 | StochasticGD("StochasticGD"); 21 | 22 | private final String optimizer; 23 | 24 | OptimizerType(String optimizer) { 25 | this.optimizer = optimizer; 26 | } 27 | 28 | public String getOptimizer() { 29 | return optimizer; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/type/ParameterType.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.core.type; 15 | 16 | public enum ParameterType { 17 | 18 | STRING("string"), 19 | NUMS("nums"), 20 | MULTI("multi"); 21 | 22 | private final String parameterType; 23 | 24 | ParameterType(String parameterType) { 25 | this.parameterType = parameterType; 26 | } 27 | 28 | public String getParameterType() { 29 | return parameterType; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/jdt/fedlearn/core/type/data/IntTuple3.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type.data; 2 | 3 | 4 | public class IntTuple3 { 5 | private final int a; 6 | private final int b; 7 | private final int c; 8 | 9 | public IntTuple3(int a, int b, int c) { 10 | this.a = a; 11 | this.b = b; 12 | this.c = c; 13 | } 14 | 15 | public int _1() { 16 | return a; 17 | } 18 | 19 | public int _2() { 20 | return b; 21 | } 22 | 23 | public int _3() { 24 | return c; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "IntTuple3{" + 30 | "a=" + a + 31 | ", b=" + b + 32 | ", c=" + c + 33 | '}'; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/resources/libDistpaillier.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fedlearnAI/fedlearn/d830fe4f384f9e78bbd43d5af948e4116332ca9a/core/src/main/resources/libDistpaillier.dylib -------------------------------------------------------------------------------- /core/src/main/resources/libDistpaillier.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fedlearnAI/fedlearn/d830fe4f384f9e78bbd43d5af948e4116332ca9a/core/src/main/resources/libDistpaillier.so -------------------------------------------------------------------------------- /core/src/main/resources/libDistpaillier.so.0.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fedlearnAI/fedlearn/d830fe4f384f9e78bbd43d5af948e4116332ca9a/core/src/main/resources/libDistpaillier.so.0.1 -------------------------------------------------------------------------------- /core/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | %d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0} - %m%n 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/dispatch/TestDispatcherFactory.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.dispatch; 2 | 3 | import com.jdt.fedlearn.core.dispatch.common.DispatcherFactory; 4 | import com.jdt.fedlearn.core.dispatch.common.Control; 5 | import com.jdt.fedlearn.core.parameter.FgbParameter; 6 | import com.jdt.fedlearn.common.entity.core.type.AlgorithmType; 7 | import com.jdt.fedlearn.core.type.MetricType; 8 | import com.jdt.fedlearn.core.type.ObjectiveType; 9 | import org.testng.Assert; 10 | import org.testng.annotations.Test; 11 | 12 | public class TestDispatcherFactory { 13 | @Test 14 | public void dispatchConstruct() { 15 | AlgorithmType type = AlgorithmType.FederatedGB; 16 | Control control = DispatcherFactory.getDispatcher(type, new FgbParameter.Builder(5, new MetricType[]{MetricType.RMSE}, ObjectiveType.regSquare).build()); 17 | Assert.assertTrue(control instanceof FederatedGB); 18 | } 19 | 20 | @Test 21 | public void dispatchConstructString() { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/encryption/TestDifferentialPrivacy.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | public class TestDifferentialPrivacy { 6 | 7 | 8 | @Test 9 | public void exponentialMechanismIndex(){ 10 | 11 | } 12 | 13 | @Test 14 | public void randomizedResponseSoft(){ 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/encryption/differentialPrivacy/TestDifferentialPrivacyFactory.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.differentialPrivacy; 2 | 3 | 4 | import com.jdt.fedlearn.core.type.DifferentialPrivacyType; 5 | import org.testng.Assert; 6 | import org.testng.annotations.Test; 7 | 8 | public class TestDifferentialPrivacyFactory { 9 | 10 | @Test 11 | public void testCreateDP(){ 12 | DifferentialPrivacyType[] types = {DifferentialPrivacyType.OUTPUT_PERTURB, DifferentialPrivacyType.OBJECTIVE_PERTURB}; 13 | IDifferentialPrivacy dp = DifferentialPrivacyFactory.createDifferentialPrivacy(types[0]); 14 | Assert.assertEquals(dp.getClass(), OutputPerturbDPImpl.class); 15 | dp = DifferentialPrivacyFactory.createDifferentialPrivacy(types[1]); 16 | Assert.assertEquals(dp.getClass(), ObjectivePerturbDPImpl.class); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/encryption/differentialPrivacy/TestGammaDP.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.differentialPrivacy; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | public class TestGammaDP { 7 | 8 | @Test 9 | public void testGamma(){ 10 | int shape = 2; 11 | double sigma = 0.2; 12 | double[] noises = GammaDP.getGammaNoise(shape, sigma, 666); 13 | Assert.assertEquals(noises.length, shape); 14 | for(double noise: noises){ 15 | System.out.println(noise); 16 | } 17 | shape = 0; 18 | noises = GammaDP.getGammaNoise(shape, sigma, 666); 19 | Assert.assertEquals(noises.length, 0); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/encryption/differentialPrivacy/TestGaussianDP.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.differentialPrivacy; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | public class TestGaussianDP { 7 | 8 | @Test 9 | public void testGaussian(){ 10 | int shape = 5; 11 | double sigma = 0.1; 12 | double[] noises = GaussianDP.getGaussianMechanismNoise(shape, sigma, 666); 13 | Assert.assertEquals(noises.length, shape); 14 | for (double noise : noises) { 15 | System.out.println(noise); 16 | } 17 | shape = 0; 18 | noises = GaussianDP.getGaussianMechanismNoise(shape, sigma, 666); 19 | Assert.assertEquals(noises.length, 0); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/encryption/differentialPrivacy/TestLaplace.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.differentialPrivacy; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | public class TestLaplace { 7 | 8 | @Test 9 | public void laplaceMechanismNoise(){ 10 | double x = Laplace.laplaceMechanismNoise(1, 0.1); 11 | System.out.println(x); 12 | x = Laplace.laplaceMechanismNoise(0, 0); 13 | Assert.assertEquals(x, 0); 14 | } 15 | 16 | @Test 17 | public void laplaceMechanismNoiseV1(){ 18 | double x = Laplace.laplaceMechanismNoiseV1(1.0 / 100.0, 0.1); 19 | System.out.println(x); 20 | x = Laplace.laplaceMechanismNoiseV1(1.0/100.0, 0); 21 | System.out.println(x); 22 | x = Laplace.laplaceMechanismNoiseV1(0, 0); 23 | Assert.assertEquals(x, 0); 24 | } 25 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/encryption/differentialPrivacy/TestRandomDP.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.encryption.differentialPrivacy; 2 | 3 | import org.testng.annotations.Test; 4 | import org.testng.Assert; 5 | 6 | public class TestRandomDP { 7 | 8 | @Test 9 | public void testRandomizedResponseForNumeric(){ 10 | double[][] data = new double[][]{{0.0, 1.0, 2.0}, {2.0, 1.0, 2.0}}; 11 | double[][] res = RandomDP.randomizedResponseForNumeric(data, 0.1); 12 | double expEpsilon = Math.exp(0.1); 13 | double candidateValue = (expEpsilon + 1) / (expEpsilon - 1) * 3; 14 | for (double[] re : res) { 15 | for (double v : re) { 16 | if(v != 0){ 17 | Assert.assertEquals(Math.abs(v), candidateValue, 0.000001); 18 | } 19 | } 20 | } 21 | res = RandomDP.randomizedResponseForNumeric(data, 0); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/entity/TestClientInfo.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity; 2 | 3 | import com.jdt.fedlearn.common.entity.core.ClientInfo; 4 | import org.testng.Assert; 5 | import org.testng.annotations.Test; 6 | 7 | public class TestClientInfo { 8 | @Test 9 | public void testSerialize(){ 10 | ClientInfo clientInfo = new ClientInfo("127.0.0.1", 92, "http"); 11 | //System.out.println(clientInfo.serialize()); 12 | Assert.assertEquals(clientInfo.url(),"http://127.0.0.1:92"); 13 | } 14 | 15 | 16 | @Test 17 | public void testDeserialize(){ 18 | ClientInfo clientInfo = new ClientInfo("127.0.0.1", 92, "http"); 19 | String ser = clientInfo.url(); 20 | ClientInfo clientInfo2 = ClientInfo.parseUrl(ser); 21 | Assert.assertEquals(clientInfo2,clientInfo); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/entity/boost/TestGainOutput.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.boost; 2 | 3 | import com.jdt.fedlearn.common.entity.core.ClientInfo; 4 | import org.testng.Assert; 5 | import org.testng.annotations.Test; 6 | 7 | public class TestGainOutput { 8 | @Test 9 | public void construct(){ 10 | GainOutput gainOutput = new GainOutput(new ClientInfo(), "feature", 5, 12.44); 11 | 12 | Assert.assertEquals(gainOutput.getClient(), new ClientInfo()); 13 | Assert.assertEquals(gainOutput.getFeature(), "feature"); 14 | Assert.assertEquals(gainOutput.getSplitIndex(), 5); 15 | Assert.assertEquals(gainOutput.getGain(), 12.44); 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/entity/boost/TestQueryEntry.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.boost; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | public class TestQueryEntry { 7 | @Test 8 | public void construct(){ 9 | QueryEntry entry = new QueryEntry(1, 5, 12.44); 10 | 11 | Assert.assertEquals(entry.getRecordId(), 1); 12 | Assert.assertEquals(entry.getFeatureIndex(), 5); 13 | Assert.assertEquals(entry.getSplitValue(), 12.44); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/entity/feature/TestTargetValueEncoder.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.feature; 2 | 3 | public class TestTargetValueEncoder { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/entity/horizontalFedAvg/TestHorizontalZooDataUtils.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.horizontalFedAvg; 2 | 3 | public class TestHorizontalZooDataUtils { 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/entity/mixGB/BoostInferQueryReqBodyTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.mixGB; 2 | 3 | import com.jdt.fedlearn.core.entity.mixGBoost.BoostInferQueryReqBody; 4 | import org.testng.Assert; 5 | import org.testng.annotations.Test; 6 | 7 | /** 8 | * @author zhangwenxi 9 | */ 10 | public class BoostInferQueryReqBodyTest { 11 | @Test 12 | public void testGetRecordId() { 13 | BoostInferQueryReqBody reqBody = new BoostInferQueryReqBody(null, 1); 14 | Assert.assertEquals(reqBody.getRecordId(), 1); 15 | } 16 | 17 | @Test 18 | public void testSetRecordId() { 19 | BoostInferQueryReqBody reqBody = new BoostInferQueryReqBody(null, 1); 20 | reqBody.setRecordId(2); 21 | Assert.assertEquals(reqBody.getRecordId(), 2); 22 | } 23 | 24 | @Test 25 | public void testGetInstanceId() { 26 | String[] instanceId = new String[]{"test"}; 27 | BoostInferQueryReqBody reqBody = new BoostInferQueryReqBody(instanceId, 0); 28 | Assert.assertEquals(reqBody.getInstanceId(), instanceId); 29 | } 30 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/entity/mixGB/BoostInferQueryResTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.mixGB; 2 | 3 | import com.jdt.fedlearn.core.entity.mixGBoost.BoostInferQueryRes; 4 | import com.jdt.fedlearn.core.entity.mixGBoost.BoostInferQueryResBody; 5 | import org.testng.Assert; 6 | import org.testng.annotations.Test; 7 | 8 | /** 9 | * @author zhangwenxi 10 | */ 11 | public class BoostInferQueryResTest { 12 | 13 | @Test 14 | public void testGetBodies() { 15 | BoostInferQueryResBody[] boostInferQueryResBodies = new BoostInferQueryResBody[1]; 16 | BoostInferQueryRes res = new BoostInferQueryRes(boostInferQueryResBodies, new int[0]); 17 | Assert.assertEquals(res.getBodies(), boostInferQueryResBodies); 18 | } 19 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/entity/randomForest/RandomForestLossTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.entity.randomForest; 2 | 3 | import org.ejml.simple.SimpleMatrix; 4 | import org.testng.annotations.Test; 5 | 6 | import static org.testng.Assert.*; 7 | 8 | public class RandomForestLossTest { 9 | 10 | @Test 11 | public void testBagging() { 12 | RandomForestLoss loss = new RandomForestLoss("Regression:MSE"); 13 | double[][] y = {{1.0},{0.0}}; 14 | SimpleMatrix label = new SimpleMatrix(y); 15 | double res = loss.bagging(label); 16 | assertEquals(res, 0.5); 17 | try { 18 | new RandomForestLoss(""); 19 | } catch (Exception e) { 20 | assertEquals(e.getMessage(), "Unsupported loss type!"); 21 | } 22 | } 23 | 24 | @Test 25 | public void testGetLossTypeId() { 26 | RandomForestLoss loss = new RandomForestLoss("Regression:MSE"); 27 | double res = loss.getLossTypeId(); 28 | assertEquals(1.0, res); 29 | } 30 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/loader/TestPreprocess.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.loader; 2 | 3 | import com.jdt.fedlearn.core.fake.StructureGenerate; 4 | import com.jdt.fedlearn.core.util.DataParseUtil; 5 | import com.jdt.fedlearn.core.loader.common.CommonTrainData; 6 | import org.testng.annotations.Test; 7 | 8 | import java.util.Arrays; 9 | 10 | public class TestPreprocess { 11 | public String baseDir = "./src/test/resources/classificationA/"; 12 | public String fileName = "train0_missing.csv"; 13 | 14 | @Test 15 | public void missingValueFilling() { 16 | String[][] data = DataParseUtil.loadTrainFromFile(baseDir + fileName); 17 | CommonTrainData commonTrainData = StructureGenerate.getTrainData(); 18 | String[][] transData = commonTrainData.columnTransNew(data); 19 | System.out.println("transData: " + Arrays.deepToString(transData)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/math/base/TestFlMatrix.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.math.base; 2 | 3 | import com.jdt.fedlearn.core.math.MathExt; 4 | import com.jdt.fedlearn.core.math.base.FlMatrix; 5 | import org.testng.Assert; 6 | import org.testng.annotations.Test; 7 | 8 | import java.util.Arrays; 9 | 10 | public class TestFlMatrix { 11 | @Test//zeros函数的返回值为新的空的SimpleMatrix?getDim固定返回2? 12 | public void testMatrix() { 13 | FlMatrix x = new FlMatrix(); 14 | System.out.println(x); 15 | FlMatrix res = x.zeros(2,4); 16 | System.out.println(x.col); 17 | System.out.println(x.row); 18 | System.out.println(x.getDim()); 19 | Assert.assertEquals(x.col,4); 20 | Assert.assertEquals(x.row,2); 21 | Assert.assertEquals(x.getDim(),2); 22 | } 23 | 24 | @Test 25 | public void testDiffSet(){ 26 | int[] a = new int[]{1,2,3,4}; 27 | int[] b = new int[]{1,2}; 28 | int[] c = MathExt.diffSet(a, b); 29 | System.out.println(Arrays.toString(c)); 30 | Assert.assertEquals(c.length,2); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/math/base/TestFlScalar.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.math.base; 2 | 3 | import com.jdt.fedlearn.core.math.Scalar; 4 | import com.jdt.fedlearn.core.math.base.FlScalar; 5 | import org.testng.Assert; 6 | import org.testng.annotations.Test; 7 | 8 | public class TestFlScalar { 9 | @Test 10 | public void add(){ 11 | Scalar a = new FlScalar(2); 12 | Scalar b = new FlScalar(3); 13 | Scalar c = a.add(b); 14 | Assert.assertEquals(c, new FlScalar(5)); 15 | } 16 | 17 | @Test 18 | public void multiply(){ 19 | Scalar a = new FlScalar(2); 20 | Scalar b = new FlScalar(3); 21 | Scalar c = a.mul(b); 22 | Assert.assertEquals(c, new FlScalar(6)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/math/base/TestFlVector.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.math.base; 2 | 3 | import com.jdt.fedlearn.core.math.Vector; 4 | import org.testng.Assert; 5 | import org.testng.annotations.Test; 6 | 7 | public class TestFlVector { 8 | @Test 9 | public void add(){ 10 | Vector a = new FlVector(1,2,3); 11 | Vector b = new FlVector(4,5,6); 12 | Vector c = a.add(b); 13 | Assert.assertEquals(c.size(),3); 14 | Assert.assertEquals(c, new FlVector(5,7,9)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/math/ejml/TestEjMatrix.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.math.ejml; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | public class TestEjMatrix { 6 | @Test 7 | public void cons(){ 8 | EjMatrix matrix = new EjMatrix(5); 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/model/common/tree/TestSampling.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.model.common.tree; 2 | 3 | import com.jdt.fedlearn.core.model.common.tree.sampling.ColSampler; 4 | import com.jdt.fedlearn.core.model.common.tree.sampling.RowSampler; 5 | 6 | public class TestSampling { 7 | public static void main(String[] args) { 8 | //test case 9 | RowSampler rs = new RowSampler(1000000, 0.8); 10 | System.out.println(rs.row_mask.subList(0,20)); 11 | rs.shuffle(); 12 | System.out.println(rs.row_mask.subList(0,20)); 13 | int sum = 0; 14 | for(double v:rs.row_mask){ 15 | sum += v; 16 | } 17 | System.out.println(sum); 18 | 19 | ColSampler cs = new ColSampler(1000, 0.6); 20 | System.out.println(cs.getColSelected().subList(0,20)); 21 | cs.shuffle(); 22 | System.out.println(cs.getColSelected().subList(0,20)); 23 | System.out.println(cs.getColSelected().size()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/multi/TestMultithread.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.multi; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import java.util.concurrent.ForkJoinPool; 6 | 7 | public class TestMultithread { 8 | @Test 9 | public void testProcessor(){ 10 | System.out.println(Runtime.getRuntime().availableProcessors()); 11 | System.out.println(ForkJoinPool.getCommonPoolParallelism()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/multi/TestStream.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.multi; 2 | 3 | import java.util.Arrays; 4 | 5 | public class TestStream { 6 | 7 | // @Test 8 | // public void testParr(){ 9 | // int[] x = new int[]{1,2,3,4,5}; 10 | // int[] y= Arrays.stream(x).parallel().map(i -> i*i).toArray(); 11 | // System.out.println(Arrays.toString(y)); 12 | // } 13 | 14 | public static void main(String[] args) { 15 | int size = 10000000; 16 | String[] tmpG = new String[size]; 17 | for (int i =0;i Double.parseDouble(x) + Double.parseDouble(x)).toArray(Double[]::new); 21 | System.out.println(Arrays.toString(decryptedG).substring(1,1000)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/optimizer/StochasticGDTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.optimizer; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | import static org.testng.Assert.*; 7 | 8 | public class StochasticGDTest { 9 | 10 | @Test 11 | public void testGetGlobalUpdate() { 12 | StochasticGD stochasticGD = new StochasticGD(0.1); 13 | double[] gredients = {0.1,0.2,0.3}; 14 | double[] res = stochasticGD.getGlobalUpdate(gredients); 15 | double[] target = {-0.01,-0.02,-0.03}; 16 | Assert.assertEquals(res, target , 1E-8); 17 | } 18 | 19 | @Test 20 | public void testTestGetGlobalUpdate() { 21 | } 22 | 23 | @Test 24 | public void testRandomChoose() { 25 | } 26 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/preprocess/TestMissingValueFilling.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.preprocess; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import java.util.Arrays; 6 | 7 | public class TestMissingValueFilling { 8 | double[][] table = {{1,Double.NaN,2},{5,6,7},{3,6,10}}; 9 | MissingValueFilling missingValueFilling = new MissingValueFilling(table); 10 | 11 | @Test 12 | public void testAvgFilling() { 13 | missingValueFilling.avgFilling(); 14 | for (double[] res1 :table) { 15 | for (double res2 :res1) 16 | System.out.println(res2); 17 | } 18 | System.out.println(Arrays.deepToString(table)); 19 | } 20 | //这个填充平均值,应该是去除缺省行,然后算平均值,分母不应加上缺省值的行。 21 | //结果为{{"1","3.0","2"},{"5","6","7"},{"3","6","10"}},填充值应该为6! 22 | 23 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/preprocess/TestScaling.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.preprocess; 2 | 3 | import com.jdt.fedlearn.core.util.Tool; 4 | import org.testng.Assert; 5 | import org.testng.annotations.Test; 6 | 7 | public class TestScaling { 8 | double[][] table = {{1.1,2,3}, {2,2,0.3}, {5,2,2}}; 9 | Scaling scaling = new Scaling(table); 10 | @Test 11 | public void testMinMaxScaling() { 12 | scaling.minMaxScaling(0,1); 13 | // for (double[] res1 :table) { 14 | // for (double res2 :res1) 15 | // System.out.println(res2); 16 | // } 17 | double[][] target = {{0,0.0,1.0}, {0.23076923076923077,0.0,0.0}, {1.0,0.0,0.6296296296296296}}; 18 | for (int i =0;i idList = new ArrayList<>(); 14 | for (int i=0;i<100;i++){ 15 | idList.add(Long.valueOf(i)); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/psi/rsa/TestRsaMatch.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.psi.rsa; 2 | 3 | 4 | import org.testng.annotations.Test; 5 | 6 | public class TestRsaMatch { 7 | @Test 8 | public void match(){ 9 | 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/psi/rsa/TestRsaMatchClient.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.psi.rsa; 2 | 3 | 4 | /** 5 | */ 6 | public class TestRsaMatchClient { 7 | 8 | 9 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/research/mpc/TestMpc.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.research.mpc; 2 | 3 | public class TestMpc { 4 | 5 | 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/AlgorithmTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import com.jdt.fedlearn.common.entity.core.type.AlgorithmType; 4 | import org.testng.annotations.Test; 5 | 6 | import java.util.Arrays; 7 | 8 | import static org.testng.Assert.*; 9 | 10 | public class AlgorithmTypeTest { 11 | private final AlgorithmType[] algorithmTypes = {AlgorithmType.VerticalLinearRegression, AlgorithmType.LinearRegression, 12 | AlgorithmType.FederatedGB, AlgorithmType.MixGBoost}; 13 | 14 | @Test 15 | public void getAlgorithm() { 16 | String[] target = {"VerticalLinearRegression", "LinearRegression", "FederatedGB", "MixGBoost"}; 17 | for (int i = 0; i < target.length; i++) { 18 | assertEquals(algorithmTypes[i].getAlgorithm(), target[i]); 19 | } 20 | } 21 | 22 | @Test 23 | public void fullAlgorithm() { 24 | System.out.println(Arrays.toString(AlgorithmType.getAlgorithms())); 25 | } 26 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/DifferentialPrivacyTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | import java.util.Arrays; 7 | 8 | public class DifferentialPrivacyTypeTest { 9 | 10 | private final DifferentialPrivacyType[] differentialPrivacyTypes = {DifferentialPrivacyType.OBJECTIVE_PERTURB, 11 | DifferentialPrivacyType.OUTPUT_PERTURB}; 12 | 13 | @Test 14 | public void getDifferential(){ 15 | String[] types = {"ObjectivePerturb", "OutputPerturb"}; 16 | for(int i = 0; i < types.length; i++){ 17 | Assert.assertEquals(differentialPrivacyTypes[i].getDifferentialPrivacyType(), types[i]); 18 | } 19 | } 20 | 21 | @Test 22 | public void fullAlgorithm() { 23 | System.out.println(Arrays.toString(DifferentialPrivacyType.getDifferentialPrivacies())); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/FGBDispatchPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.assertEquals; 6 | 7 | 8 | public class FGBDispatchPhaseTypeTest { 9 | 10 | private final FGBDispatchPhaseType[] algorithmTypes = {FGBDispatchPhaseType.FromInit, FGBDispatchPhaseType.ControlPhase1, 11 | FGBDispatchPhaseType.ControlPhase2, FGBDispatchPhaseType.ControlPhase3, FGBDispatchPhaseType.ControlPhase4, FGBDispatchPhaseType.ControlPhase5}; 12 | 13 | @Test 14 | public void FGBModelPhaseTypeTest() { 15 | String[] target = {"FromInit","ControlPhase1","ControlPhase2","ControlPhase3","ControlPhase4","ControlPhase5"}; 16 | for (int i =0;i < target.length;i++){ 17 | assertEquals(algorithmTypes[i].toString(), target[i]); 18 | } 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/HorDispatchPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | import org.testng.annotations.Test; 3 | 4 | import static org.testng.Assert.assertEquals; 5 | 6 | public class HorDispatchPhaseTypeTest { 7 | // @Test 8 | // public void HorDispatchPhaseTypeTest() { 9 | // HorDispatchPhaseType type = HorDispatchPhaseType.createNullRequest; 10 | // int message = 1; 11 | // Assert.assertEquals(type.getPhaseValue(),message); 12 | // 13 | // } 14 | private final HorDispatchPhaseType[] algorithmTypes = {HorDispatchPhaseType.createNullRequest, HorDispatchPhaseType.transferModels, 15 | HorDispatchPhaseType.predict, HorDispatchPhaseType.getPredictResults}; 16 | 17 | @Test 18 | public void HorDispatchPhaseTypeTest() { 19 | int[] target = {1,2,-2,-3}; 20 | for (int i =0;i < target.length;i++){ 21 | assertEquals(algorithmTypes[i].getPhaseValue(), target[i]); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/HorModelPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | import org.testng.annotations.Test; 3 | 4 | import static org.testng.Assert.assertEquals; 5 | 6 | public class HorModelPhaseTypeTest { 7 | // @Test 8 | // public void HorModelPhaseTypeTest() { 9 | // HorModelPhaseType type = HorModelPhaseType.loadTrainUpdate; 10 | // int message = 2; 11 | // Assert.assertEquals(type.getPhaseValue() ,message); 12 | // 13 | // } 14 | private final HorModelPhaseType[] algorithmTypes = {HorModelPhaseType.Null_1, HorModelPhaseType.loadTrainUpdate, 15 | HorModelPhaseType.loadTrainUpdate_1}; 16 | 17 | @Test 18 | public void HorModelPhaseTypeTest() { 19 | int[] target = {1,2,3}; 20 | for (int i =0;i < target.length;i++){ 21 | assertEquals(algorithmTypes[i].getPhaseValue(), target[i]); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/InferMessageTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class InferMessageTypeTest { 8 | private final InferMessageType[] inferMessageType = {InferMessageType.Init,InferMessageType.Query,InferMessageType.Left, 9 | InferMessageType.Right,InferMessageType.Leaf,InferMessageType.FetchVertical,InferMessageType.Result, 10 | InferMessageType.Predict}; 11 | @Test 12 | public void testGetMsgType() { 13 | String[] target = {"Init","Query","Left","Right","Leaf","FetchVertical","Result","Predict"}; 14 | for (int i = 0;i < target.length;i++){ 15 | assertEquals(inferMessageType[i].getMsgType(),target[i]); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/KernelModelPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class KernelModelPhaseTypeTest { 8 | private int[] phases = {1, 2, 3, 4, 5, 6, 7, -1,-2,-3}; 9 | private KernelModelPhaseType[] kernelModelPhaseTypes = new KernelModelPhaseType[phases.length]; 10 | 11 | @Test 12 | public void test(){ 13 | for (int i = 0; i < phases.length ; i++) { 14 | kernelModelPhaseTypes[i] = KernelModelPhaseType.valueOf(phases[i]); 15 | } 16 | for (int i = 0;i < phases.length;i++){ 17 | assertEquals(kernelModelPhaseTypes[i].getPhaseValue(), phases[i]); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/MappingTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class MappingTypeTest { 8 | private final MappingType[] matchTypes = {MappingType.MD5, MappingType.RSA, MappingType.EMPTY}; 9 | 10 | @Test 11 | public void testGetType() { 12 | String[] target = {"MD5", "RSA", "EMPTY"}; 13 | for (int i = 0; i < target.length; i++) { 14 | assertEquals(matchTypes[i].getType(), target[i]); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/MemoryUnitsTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class MemoryUnitsTypeTest { 8 | private final MemoryUnitsType[] memoryUnitsTypes = {MemoryUnitsType.B, MemoryUnitsType.KB, MemoryUnitsType.MB, MemoryUnitsType.GB, MemoryUnitsType.TB}; 9 | 10 | @Test 11 | public void testGetMemoryUnits() { 12 | String[] target = {"B","KB","MB","GB","TB"}; 13 | for (int i = 0;i < target.length;i++){ 14 | assertEquals(memoryUnitsTypes[i].getMemoryUnits(),target[i]); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/MetricTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class MetricTypeTest { 8 | private final MetricType[] metricType = {MetricType.MSE,MetricType.RMSE,MetricType.MSE,MetricType.MAE,MetricType.MAPE,MetricType.MAAPE, 9 | MetricType.ACC,MetricType.ERROR,MetricType.AUC,MetricType.F1,MetricType.R2,MetricType.PRECISION,MetricType.RECALL, 10 | MetricType.ROC,MetricType.KS}; 11 | @Test 12 | public void testGetMetric() { 13 | String[] target = {"mse","rmse","mse","mae","mape","maape","acc","error","auc","f1","r2","precision","recall","roc","ks"}; 14 | for (int i = 0;i < target.length;i++){ 15 | assertEquals(metricType[i].getMetric(),target[i]); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/NormalizationTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class NormalizationTypeTest { 8 | private final NormalizationType[] normalizationTypes = {NormalizationType.MINMAX, NormalizationType.STANDARD, NormalizationType.NONE}; 9 | 10 | @Test 11 | public void testGetNormalizationType() { 12 | String[] target = {"MINMAX","STANDARD","NONE"}; 13 | for (int i = 0;i < target.length;i++){ 14 | assertEquals(normalizationTypes[i].getNormalizationType(),target[i]); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/OptimizerTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class OptimizerTypeTest { 8 | private final OptimizerType[] optimizerTypes = {OptimizerType.NEWTON,OptimizerType.BFGS, OptimizerType.BatchGD,OptimizerType.StochasticGD}; 9 | @Test 10 | public void testGetOptimizer() { 11 | String[] target = {"NEWTON","bfgs","batchGD","StochasticGD"}; 12 | for (int i = 0;i < target.length;i++){ 13 | assertEquals(optimizerTypes[i].getOptimizer(),target[i]); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/RFDispatchPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class RFDispatchPhaseTypeTest { 8 | private int[] phases = {1, 2, 3, 4, 5, 6, 7, 8, 9, 99}; 9 | private RFDispatchPhaseType[] rfDispatchPhaseTypes = new RFDispatchPhaseType[phases.length]; 10 | 11 | 12 | @Test 13 | public void test() { 14 | for (int i = 0; i < phases.length; i++) { 15 | rfDispatchPhaseTypes[i] = RFDispatchPhaseType.valueOf(phases[i]); 16 | } 17 | for (int i = 0;i < phases.length;i++){ 18 | assertEquals(rfDispatchPhaseTypes[i].getPhaseValue(), phases[i]); 19 | } 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/RFModelPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | import static org.testng.Assert.*; 6 | 7 | public class RFModelPhaseTypeTest { 8 | 9 | private int[] phases = {1, 2, 3, 4, 5, 6, 7, 8, 9, 99}; 10 | private RFModelPhaseType[] rfModelPhaseTypes = new RFModelPhaseType[phases.length]; 11 | 12 | 13 | @Test 14 | public void test() { 15 | for (int i = 0; i < phases.length; i++) { 16 | rfModelPhaseTypes[i] = RFModelPhaseType.valueOf(phases[i]); 17 | } 18 | for (int i = 0;i < phases.length;i++){ 19 | assertEquals(rfModelPhaseTypes[i].getPhaseValue(), phases[i]); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/Tuple2Test.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import com.jdt.fedlearn.core.type.data.Tuple2; 4 | import org.testng.annotations.Test; 5 | 6 | import static org.testng.Assert.*; 7 | //如果包含null或者"",是不一样的。 8 | public class Tuple2Test { 9 | private final String a = null; 10 | private final double b = -10; 11 | private final Tuple2 tuple2 = new Tuple2(null,b); 12 | @Test 13 | public void test_1() { 14 | assertEquals(tuple2._1(), null); 15 | } 16 | 17 | @Test 18 | public void test_2() { 19 | assertEquals(tuple2._2(),b); 20 | } 21 | 22 | @Test 23 | public void test_3() { 24 | assertNull(tuple2._3()); 25 | } 26 | 27 | @Test 28 | public void testTestToString() { 29 | String target = "Tuple2{a=null, b=-10.0}"; 30 | assertEquals(tuple2.toString(),target); 31 | } 32 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/Tuple3Test.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | 3 | import com.jdt.fedlearn.core.type.data.Tuple3; 4 | import org.testng.annotations.Test; 5 | 6 | import java.util.Optional; 7 | 8 | import static org.testng.Assert.*; 9 | 10 | public class Tuple3Test { 11 | private final double b = -10; 12 | private final int c = 12313131; 13 | private final Tuple3 tuple3 = new Tuple3(null,b,c); 14 | 15 | @Test 16 | public void test_1() { 17 | assertEquals(tuple3._1(), Optional.empty()); 18 | } 19 | 20 | @Test 21 | public void test_2() { 22 | assertEquals(tuple3._2(),Optional.of(b)); 23 | } 24 | 25 | @Test 26 | public void test_3() { 27 | assertEquals(tuple3._3(),Optional.of(c)); 28 | } 29 | 30 | @Test 31 | public void testTestToString() { 32 | String target = "Tuple3{a=null, b=-10.0, c=12313131}"; 33 | assertEquals(tuple3.toString(),target); 34 | } 35 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/VerLRDispatchPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | import org.testng.annotations.Test; 3 | 4 | import static org.testng.Assert.assertEquals; 5 | 6 | public class VerLRDispatchPhaseTypeTest { 7 | // @Test 8 | // public void VerLRDispatchPhaseTypeTest() { 9 | // VerLRDispatchPhaseType type = VerLRDispatchPhaseType.controlPhase1; 10 | // int message = 1; 11 | // Assert.assertEquals(type.getPhaseValue(),message); 12 | // } 13 | private final VerLRDispatchPhaseType[] algorithmTypes = {VerLRDispatchPhaseType.UPDATE_METRIC, VerLRDispatchPhaseType.SEND_LOSS, 14 | VerLRDispatchPhaseType.SEND_GRADIENTS, VerLRDispatchPhaseType.UPDATE_GRADIENTS, VerLRDispatchPhaseType.PREDICT_RESULT,VerLRDispatchPhaseType.EMPTY_REQUEST}; 15 | 16 | @Test 17 | public void FGBModelPhaseTypeTest () { 18 | int[] target = {1,2,3,4,-2,-3}; 19 | for (int i =0;i < target.length;i++){ 20 | assertEquals(algorithmTypes[i].getPhaseValue(), target[i]); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/VerLRModelPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | import org.testng.annotations.Test; 3 | 4 | import static org.testng.Assert.assertEquals; 5 | 6 | public class VerLRModelPhaseTypeTest { 7 | // @Test 8 | // public void VerLRModelPhaseTypeTest() { 9 | // VerLRModelPhaseType type = VerLRModelPhaseType.trainPhase1; 10 | // int message = 1; 11 | // Assert.assertEquals(type.getPhaseValue(),message); 12 | // } 13 | private final VerLRModelPhaseType[] algorithmTypes = {VerLRModelPhaseType.PASSIVE_LOCAL_PREDICT, VerLRModelPhaseType.COMPUTE_DIFFERENT, 14 | VerLRModelPhaseType.COMPUTE_GRADIENTS, VerLRModelPhaseType.UPDATE_WEIGHTS}; 15 | 16 | @Test 17 | public void FGBModelPhaseTypeTest () { 18 | int[] target = {1,2,3,4}; 19 | for (int i =0;i < target.length;i++){ 20 | assertEquals(algorithmTypes[i].getPhaseValue(), target[i]); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/VerLinDispatchPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | import org.testng.annotations.Test; 3 | 4 | import static org.testng.Assert.assertEquals; 5 | 6 | public class VerLinDispatchPhaseTypeTest { 7 | // @Test 8 | // public void VerLinRegDispatchPhaseTypeTest() { 9 | // VerLinRegDispatchPhaseType type = VerLinRegDispatchPhaseType.controlPhase1; 10 | // int message = 1; 11 | // Assert.assertEquals(type.getPhaseValue(),message); 12 | // } 13 | private final VerLinDispatchPhaseType[] algorithmTypes = {VerLinDispatchPhaseType.UPDATE_METRIC, VerLinDispatchPhaseType.SEND_LOSS, 14 | VerLinDispatchPhaseType.SEND_GRADIENTS, VerLinDispatchPhaseType.UPDATE_GRADIENTS, VerLinDispatchPhaseType.PREDICT_RESULT, VerLinDispatchPhaseType.EMPTY_REQUEST}; 15 | 16 | @Test 17 | public void FGBModelPhaseTypeTest () { 18 | int[] target = {1,2,3,4,-1,-2}; 19 | for (int i =0;i < target.length;i++){ 20 | assertEquals(algorithmTypes[i].getPhaseValue(), target[i]); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/type/VerLinModelPhaseTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.type; 2 | import org.testng.annotations.Test; 3 | 4 | import static org.testng.Assert.assertEquals; 5 | 6 | public class VerLinModelPhaseTypeTest { 7 | // @Test 8 | // public void VerLinModelPhaseTypeTest() { 9 | // VerLinModelPhaseType type = VerLinModelPhaseType.trainPhase1; 10 | // int message = 1; 11 | // Assert.assertEquals(type.getPhaseValue(),message); 12 | // } 13 | private final VerLinModelPhaseType[] algorithmTypes = {VerLinModelPhaseType.PASSIVE_LOCAL_PREDICT, VerLinModelPhaseType.COMPUTE_DIFFERENT, 14 | VerLinModelPhaseType.COMPUTE_GRADIENTS, VerLinModelPhaseType.UPDATE_WEIGHTS}; 15 | 16 | @Test 17 | public void VerLinModelPhaseTypeTest () { 18 | int[] target = {1,2,3,4}; 19 | for (int i =0;i < target.length;i++){ 20 | assertEquals(algorithmTypes[i].getPhaseValue(), target[i]); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/util/LagrangeInterpolationTest.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.util; 2 | 3 | import org.testng.Assert; 4 | import org.testng.annotations.Test; 5 | 6 | import java.math.BigInteger; 7 | import java.util.Arrays; 8 | 9 | import static org.testng.Assert.*; 10 | 11 | public class LagrangeInterpolationTest { 12 | 13 | @Test 14 | public void testGenerateCoefficients() { 15 | LagrangeInterpolation li = new LagrangeInterpolation(new double[]{-2.0, -3.0, -1.0}); 16 | double[] result = li.generateBigCoefficients(); 17 | double[] target = new double[]{1.0, -6.0, 11.0, -6.0}; 18 | for (int i = 0; i < target.length; i++) { 19 | Assert.assertEquals(result[i], target[i]); 20 | } 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /core/src/test/java/com/jdt/fedlearn/core/util/TestTypeTrans.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.core.util; 2 | 3 | public class TestTypeTrans { 4 | public static void main(String[] args) { 5 | float x = 0.050218654f; 6 | double y = x; 7 | System.out.println(y); 8 | double z = 1.001; 9 | String hex = Double.toHexString(z); 10 | double zs = Double.parseDouble(hex); 11 | System.out.println(zs); 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA/inference0.csv: -------------------------------------------------------------------------------- 1 | uid,Pregnancies,Glucose 2 | 591B,11,111 3 | 592B,2,112 4 | 593A,3,132 5 | 594B,2,82 6 | 595C,6,123 7 | 596B,0,188 8 | 597C,0,67 9 | 598A,1,89 10 | 599B,1,173 11 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA/inference1.csv: -------------------------------------------------------------------------------- 1 | uid,SkinThickness,Insulin 2 | 591B,40,0 3 | 592B,50,140 4 | 593A,0,0 5 | 594B,22,115 6 | 595C,45,230 7 | 596B,14,185 8 | 597C,0,0 9 | 598A,19,25 10 | 599B,0,0 11 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA/inference2.csv: -------------------------------------------------------------------------------- 1 | uid,Insulin,BMI,DiabetesPedigreeFunction,Age,SkinThickness,Insulin 2 | 591B,0,46.8,0.925,45,40,0 3 | 592B,140,39.4,0.175,24,50,140 4 | 593A,0,34.4,0.402,44,0,0 5 | 594B,115,28.5,1.699,25,22,115 6 | 595C,230,33.6,0.733,34,45,230 7 | 596B,185,32,0.682,22,14,185 8 | 597C,0,45.3,0.194,46,0,0 9 | 598A,25,27.8,0.559,21,19,25 10 | 599B,0,36.8,0.088,38,0,0 11 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA/readme.txt: -------------------------------------------------------------------------------- 1 | 二分类测试数据集 2 | 3 | 推理数据集中的实际 label为 4 | 1,0,1,0,0,1,0,0,1 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA/train0_missing.csv: -------------------------------------------------------------------------------- 1 | uid,Pregnancies,Glucose,p,Outcome 2 | 1,null,wifi,1080*100,1 3 | 2,1,4g,720*890,0 4 | 3,8,null,2040*125,1 5 | 4,unknown,5g,421*102,0 6 | 5,0,2g,421*102,1 7 | 6,unknown,5g,1080*100,0 8 | 7,3,4g,2040*125,1 9 | 8,unknown,wifi,1080*100,0 10 | 9,2,wifi,1080*100,1 11 | 10,null,wifi,2040*125,1 12 | 11,4,4g,421*102,0 13 | 12,,2g,720*890,1 14 | 13,10,2g,1080*100,0 15 | 14,1,wifi,421*102,1 16 | 15,5,5g,2040*125,1 17 | 16,unknown,5g,1080*100,1 18 | 17,0,4g,421*102,1 19 | 18,7,2g,2040*125,1 20 | 19,1,wifi,421*102,0 21 | 20,1,,2040*125,1 22 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_IDMatch/readme.txt: -------------------------------------------------------------------------------- 1 | 二分类测试数据集 2 | 3 | 推理数据集中的实际 label为 4 | 1,0,1,0,0,1,0,0,1 5 | 6 | 实际对齐ID个数应为9 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_IDMatch/train0.csv: -------------------------------------------------------------------------------- 1 | uid,Pregnancies,Glucose,Outcome 2 | 1A,6,148,1 3 | 2A,1,85,0 4 | 3A,8,183,1 5 | 4A,1,89,0 6 | 5C,0,137,1 7 | 6C,5,116,0 8 | 7C,3,78,1 9 | 8B,10,115,0 10 | 9B,2,197,1 11 | 10B,8,125,1 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_IDMatch/train1.csv: -------------------------------------------------------------------------------- 1 | uid,SkinThickness,Insulin 2 | 1C,35,0 3 | 2A,29,0 4 | 3A,0,0 5 | 4A,23,94 6 | 5C,35,168 7 | 6C,0,0 8 | 7C,32,88 9 | 8B,0,0 10 | 9B,45,543 11 | 10B,0,0 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_IDMatch/train2.csv: -------------------------------------------------------------------------------- 1 | uid,Insulin,BMI,DiabetesPedigreeFunction,Age 2 | 1C,0,33.6,0.627,50 3 | 2A,0,26.6,0.351,31 4 | 3A,0,23.3,0.672,32 5 | 4A,94,28.1,0.167,21 6 | 5C,168,43.1,2.288,33 7 | 6C,0,25.6,0.201,30 8 | 7C,88,31,0.248,26 9 | 8B,0,35.3,0.134,29 10 | 9B,543,30.5,0.158,53 11 | 10B,0,0,0.232,54 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Small/inference0.csv: -------------------------------------------------------------------------------- 1 | uid,Pregnancies,Glucose 2 | 1B,11,111 3 | 2A,2,112 4 | 3A,3,132 5 | 4A,2,82 6 | 5C,6,123 7 | 6C,0,188 8 | 7C,0,67 9 | 8B,1,89 10 | 9B,1,173 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Small/inference1.csv: -------------------------------------------------------------------------------- 1 | uid,SkinThickness,Insulin 2 | 1B,40,0 3 | 2A,50,140 4 | 3A,0,0 5 | 4A,22,115 6 | 5C,45,230 7 | 6C,14,185 8 | 7C,0,0 9 | 8B,19,25 10 | 9B,0,0 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Small/inference2.csv: -------------------------------------------------------------------------------- 1 | uid,Insulin,BMI,DiabetesPedigreeFunction,Age 2 | 1B,0,46.8,0.925,45 3 | 2A,140,39.4,0.175,24 4 | 3A,0,34.4,0.402,44 5 | 4A,115,28.5,1.699,25 6 | 5C,230,33.6,0.733,34 7 | 6C,185,32,0.682,22 8 | 7C,0,45.3,0.194,46 9 | 8B,25,27.8,0.559,21 10 | 9B,0,36.8,0.088,38 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Small/readme.txt: -------------------------------------------------------------------------------- 1 | 二分类测试数据集 2 | 3 | 推理数据集中的实际 label为 4 | 1,0,1,0,0,1,0,0,1 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Small/train0.csv: -------------------------------------------------------------------------------- 1 | uid,Pregnancies,Glucose,Outcome 2 | 1B,6,148,1 3 | 2A,1,85,0 4 | 3A,8,183,1 5 | 4A,1,89,0 6 | 5C,0,137,1 7 | 6C,5,116,0 8 | 7C,3,78,1 9 | 8B,10,115,0 10 | 9B,2,197,1 11 | 10B,8,125,1 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Small/train0_missing.csv: -------------------------------------------------------------------------------- 1 | uid,Pregnancies,Glucose,p,Outcome 2 | 1,null,wifi,1080*100,1 3 | 2,1,4g,720*890,0 4 | 3,8,null,2040*125,1 5 | 4,unknown,5g,421*102,0 6 | 5,0,2g,421*102,1 7 | 6,unknown,5g,1080*100,0 8 | 7,3,4g,2040*125,1 9 | 8,unknown,wifi,1080*100,0 10 | 9,2,wifi,1080*100,1 11 | 10,null,wifi,2040*125,1 12 | 11,4,4g,421*102,0 13 | 12,,2g,720*890,1 14 | 13,10,2g,1080*100,0 15 | 14,1,wifi,421*102,1 16 | 15,5,5g,2040*125,1 17 | 16,unknown,5g,1080*100,1 18 | 17,0,4g,421*102,1 19 | 18,7,2g,2040*125,1 20 | 19,1,wifi,421*102,0 21 | 20,1,,2040*125,1 22 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Small/train1.csv: -------------------------------------------------------------------------------- 1 | uid,SkinThickness,Insulin 2 | 1B,35,0 3 | 2A,29,0 4 | 3A,0,0 5 | 4A,23,94 6 | 5C,35,168 7 | 6C,0,0 8 | 7C,32,88 9 | 8B,0,0 10 | 9B,45,543 11 | 10B,0,0 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Small/train2.csv: -------------------------------------------------------------------------------- 1 | uid,Insulin,BMI,DiabetesPedigreeFunction,Age 2 | 1B,0,33.6,0.627,50 3 | 2A,0,26.6,0.351,31 4 | 3A,0,23.3,0.672,32 5 | 4A,94,28.1,0.167,21 6 | 5C,168,43.1,2.288,33 7 | 6C,0,25.6,0.201,30 8 | 7C,88,31,0.248,26 9 | 8B,0,35.3,0.134,29 10 | 9B,543,30.5,0.158,53 11 | 10B,0,0,0.232,54 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Twopartner/inference0.csv: -------------------------------------------------------------------------------- 1 | uid,Pregnancies,Glucose 2 | 591B,11,111 3 | 592B,2,112 4 | 593A,3,132 5 | 594B,2,82 6 | 595C,6,123 7 | 596B,0,188 8 | 597C,0,67 9 | 598A,1,89 10 | 599B,1,173 11 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Twopartner/inference0_onlyLabel.csv: -------------------------------------------------------------------------------- 1 | uid 2 | 591B 3 | 592B 4 | 593A 5 | 594B 6 | 595C 7 | 596B 8 | 597C 9 | 598A 10 | 599B 11 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Twopartner/inference1.csv: -------------------------------------------------------------------------------- 1 | uid,SkinThickness,Insulin,Insulin,BMI,DiabetesPedigreeFunction,Age 2 | 591B,40,0,0,46.8,0.925,45 3 | 592B,50,140,140,39.4,0.175,24 4 | 593A,0,0,0,34.4,0.402,44 5 | 594B,22,115,115,28.5,1.699,25 6 | 595C,45,230,230,33.6,0.733,34 7 | 596B,14,185,185,32,0.682,22 8 | 597C,0,0,0,45.3,0.194,46 9 | 598A,19,25,25,27.8,0.559,21 10 | 599B,0,0,0,36.8,0.088,38 11 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Twopartner/inference1_onlyLabel.csv: -------------------------------------------------------------------------------- 1 | uid,SkinThickness,Insulin,Insulin,BMI,DiabetesPedigreeFunction,Age 2 | 591B,40,0,0,46.8,0.925,45 3 | 592B,50,140,140,39.4,0.175,24 4 | 593A,0,0,0,34.4,0.402,44 5 | 594B,22,115,115,28.5,1.699,25 6 | 595C,45,230,230,33.6,0.733,34 7 | 596B,14,185,185,32,0.682,22 8 | 597C,0,0,0,45.3,0.194,46 9 | 598A,19,25,25,27.8,0.559,21 10 | 599B,0,0,0,36.8,0.088,38 11 | -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_Twopartner/readme.txt: -------------------------------------------------------------------------------- 1 | 二分类测试数据集 2 | 3 | 推理数据集中的实际 label为 4 | 1,0,1,0,0,1,0,0,1 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_numberID/readme.txt: -------------------------------------------------------------------------------- 1 | 二分类测试数据集 2 | 3 | 推理数据集中的实际 label为 4 | 1,0,1,0,0,1,0,0,1 5 | 6 | 实际对齐ID个数应为9 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_numberID/train0.csv: -------------------------------------------------------------------------------- 1 | uid,Pregnancies,Glucose,Outcome 2 | 1,6,148,1 3 | 2,1,85,0 4 | 3,8,183,1 5 | 4,1,89,0 6 | 5,0,137,1 7 | 6,5,116,0 8 | 7,3,78,1 9 | 8,10,115,0 10 | 9,2,197,1 11 | 10,8,125,1 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_numberID/train1.csv: -------------------------------------------------------------------------------- 1 | uid,SkinThickness,Insulin 2 | 0.0,35,0 3 | 1.0,29,0 4 | 2.0,0,0 5 | 3.0,23,94 6 | 4.0,35,168 7 | 5.0,0,0 8 | 6.0,32,88 9 | 7.0,0,0 10 | 8.0,45,543 11 | 9.0,0,0 -------------------------------------------------------------------------------- /core/src/test/resources/classificationA_numberID/train2.csv: -------------------------------------------------------------------------------- 1 | uid,Insulin,BMI,DiabetesPedigreeFunction,Age 2 | 2,0,33.6,0.627,50 3 | 3,0,26.6,0.351,31 4 | 4,0,23.3,0.672,32 5 | 5,94,28.1,0.167,21 6 | 6,168,43.1,2.288,33 7 | 7,0,25.6,0.201,30 8 | 8,88,31,0.248,26 9 | 9,0,35.3,0.134,29 10 | 10,543,30.5,0.158,53 11 | 11,0,0,0.232,54 -------------------------------------------------------------------------------- /core/src/test/resources/match/readme.txt: -------------------------------------------------------------------------------- 1 | id 对齐测试数据,每个参与方样本数量不等,且顺序不一致 -------------------------------------------------------------------------------- /core/src/test/resources/multiClassificationA/readme.txt: -------------------------------------------------------------------------------- 1 | 纵向多分类数据集 - 叶子分类 A 2 | 3 | 需要设置: 4 | (1)objective= multi:softmax 或 multi-softprob 5 | (2)设置 numClass (类别数量) 6 | 数据集中类别 label 有 36 个, numClass 可以设为大于等于 36 的值, 多出的数量作为 missing label 处理 7 | 8 | 数据源: 9 | https://archive.ics.uci.edu/ml/datasets/Leaf 10 | 11 | 数据集信息: 12 | (1)样本数量 13 | 训练集 272 条 14 | 测试集 68条 15 | 16 | (2)Attribute Information: 17 | 1. uid (样本 id 已对齐) 18 | 2. Specimen Number 19 | 3. Eccentricity 20 | 4. Aspect Ratio 21 | 5. Elongation 22 | 6. Solidity 23 | 7. Stochastic Convexity 24 | 8. Isoperimetric Factor 25 | 9. Maximal Indentation Depth 26 | 10. Lobedness 27 | 11. Average Intensity 28 | 12. Average Contrast 29 | 13. Smoothness 30 | 14. Third moment 31 | 15. Uniformity 32 | 16. Entropy 33 | 34 | 35 | -------------------------------------------------------------------------------- /core/src/test/resources/multiClassificationB/inference0.csv: -------------------------------------------------------------------------------- 1 | uid,Specimen_Number,Eccentricity,Aspect_Ratio,Elongation,Solidity 2 | 13,1,0.93361,2.7582,0.64257,0.98346 3 | 14,2,0.91186,2.4994,0.60323,0.983 -------------------------------------------------------------------------------- /core/src/test/resources/multiClassificationB/inference1.csv: -------------------------------------------------------------------------------- 1 | uid,Stochastic_Convexity,Isoperimetric_Factor,Maximal_Indentation_Depth,Lobedness,Average_Intensity 2 | 13,1.0,0.59851,0.0055336000000000005,0.0055731,0.029712 3 | 14,1.0,0.6491600000000001,0.0061494,0.006882300000000001,0.018887 -------------------------------------------------------------------------------- /core/src/test/resources/multiClassificationB/inference2.csv: -------------------------------------------------------------------------------- 1 | uid,Average_Contrast,Smoothness,Third_moment,Uniformity,Entropy 2 | 13,0.089889,0.008015300000000001,0.0020648000000000003,0.00023883,0.91499 3 | 14,0.072486,0.0052267,0.0014887000000000001,8.327100000000001e-05,0.67811 -------------------------------------------------------------------------------- /core/src/test/resources/multiClassificationB/readme.txt: -------------------------------------------------------------------------------- 1 | 纵向多分类数据集 - 叶子分类 B 2 | 3 | 需要设置: 4 | (1)objective= multi:softmax 或 multi-softprob 5 | (2)设置 numClass (类别数量) 6 | 数据集中类别 label 有 3 个, numClass 可以设为大于等于 3 的值, 多出的数量作为 missing label 处理 7 | 8 | 数据源: 9 | https://archive.ics.uci.edu/ml/datasets/Leaf 10 | 11 | 数据集信息: 12 | (1)样本数量 13 | 训练集 11 条 14 | 测试集 2 条 15 | (2)Attribute Information: 16 | 1. uid (样本 id 已对齐) 17 | 2. Specimen Number 18 | 3. Eccentricity 19 | 4. Aspect Ratio 20 | 5. Elongation 21 | 6. Solidity 22 | 7. Stochastic Convexity 23 | 8. Isoperimetric Factor 24 | 9. Maximal Indentation Depth 25 | 10. Lobedness 26 | 11. Average Intensity 27 | 12. Average Contrast 28 | 13. Smoothness 29 | 14. Third moment 30 | 15. Uniformity 31 | 16. Entropy 32 | 33 | 34 | -------------------------------------------------------------------------------- /core/src/test/resources/multiClassificationB/train0.csv: -------------------------------------------------------------------------------- 1 | uid,Specimen_Number,Eccentricity,Aspect_Ratio,Elongation,Solidity,label 2 | 5,5,0.82301,1.7707,0.44461999999999996,0.97698,1 3 | 112,4,0.38500999999999996,1.0656,0.63042,0.51223,11 4 | 124,16,0.44882,1.0118,0.6301,0.57134,11 5 | 3,3,0.76722,1.5725,0.38998,0.97755,1 6 | 6,6,0.72997,1.4892,0.34284000000000003,0.98755,1 7 | 115,7,0.39092,1.087,0.68174,0.50961,11 8 | 12,12,0.79606,1.6934,0.43387,0.9818100000000001,1 9 | 114,6,0.24465,1.047,0.60511,0.56524,11 10 | 110,2,0.54893,1.1111,0.63983,0.56623,11 11 | 116,8,0.4042,1.0965,0.65899,0.52833,11 12 | 317,9,0.9953,10.63,0.9059799999999999,0.88866,34 -------------------------------------------------------------------------------- /core/src/test/resources/multiClassificationB/train1.csv: -------------------------------------------------------------------------------- 1 | uid,Stochastic_Convexity,Isoperimetric_Factor,Maximal_Indentation_Depth,Lobedness,Average_Intensity 2 | 5,1.0,0.75493,0.007428,0.010042,0.0079379 3 | 112,0.59123,0.13705,0.12292,2.7498,0.033373 4 | 124,0.81053,0.16187,0.11115,2.2486,0.027308999999999996 5 | 3,1.0,0.80812,0.007457300000000001,0.010121,0.011897 6 | 6,1.0,0.8448200000000001,0.0049451,0.0044506,0.010487 7 | 115,0.6614,0.15361,0.14082,3.6093,0.028638 8 | 12,1.0,0.76985,0.0077992,0.011071,0.013677000000000002 9 | 114,0.79474,0.21788000000000002,0.12522,2.8539999999999996,0.037594999999999996 10 | 110,0.6,0.15743,0.13080999999999998,3.1143,0.021231 11 | 116,0.68421,0.1771,0.13017,3.0837,0.029057 12 | 317,0.9578899999999999,0.15967,0.025636000000000003,0.11961,0.014782 -------------------------------------------------------------------------------- /core/src/test/resources/multiClassificationB/train2.csv: -------------------------------------------------------------------------------- 1 | uid,Average_Contrast,Smoothness,Third_moment,Uniformity,Entropy 2 | 5,0.045339,0.0020514,0.00055986,2.3504e-05,0.34214 3 | 112,0.09890700000000001,0.0096879,0.0027872,0.00021426,1.0015 4 | 124,0.088889,0.0078393,0.0022734,0.00017545,0.86 5 | 3,0.057445,0.0032890999999999997,0.00092068,3.7885999999999996e-05,0.44348000000000004 6 | 6,0.058528,0.0034138000000000007,0.0011248,2.4798000000000002e-05,0.34068000000000004 7 | 115,0.089135,0.0078824,0.0021177,0.00021044,0.9008200000000001 8 | 12,0.05783200000000001,0.0033334000000000003,0.00081648,0.00013855,0.49751000000000006 9 | 114,0.127,0.015874,0.006587000000000001,0.00010798,0.8331 10 | 110,0.079722,0.0063155,0.0019123,7.3919e-05,0.71949 11 | 116,0.096836,0.0092902,0.0028927,0.00012649999999999998,0.82383 12 | 317,0.065416,0.0042611,0.0012831,6.4365e-05,0.52178 -------------------------------------------------------------------------------- /core/src/test/resources/regressionA/inference0.csv: -------------------------------------------------------------------------------- 1 | uid,x0,x1 2 | 291B,0.21444106475157845,0.04996388474568747 3 | 292A,0.7944067018474512,0.8861544687235355 4 | 293B,0.658829251569282,0.4851542473709365 5 | 294C,0.9339425034214132,0.6404827725090099 6 | 295B,0.8312541673269118,0.6088112562622189 7 | 296A,0.3353810478843261,0.30130126153951753 8 | 297A,0.4706547473499929,0.2664618344005784 9 | 298C,0.6035958154305429,0.7297353851688908 10 | 299B,0.8445586350352466,0.8297011325240027 11 | 300B,0.1378862833164921,0.6769327235205828 12 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionA/inference1.csv: -------------------------------------------------------------------------------- 1 | uid,x2,x3 2 | 291B,0.2720783537908599,0.5573800583315913 3 | 292A,0.833115264179749,0.1149465943766148 4 | 293B,0.4568064601393725,0.18533638361991267 5 | 294C,0.7471779863120398,0.033432633995296834 6 | 295B,0.4972854295710559,0.9875139208377152 7 | 296A,0.8564245071473828,0.1662884066490331 8 | 297A,0.3522434999634079,0.4126409970708691 9 | 298C,0.8077265663850443,0.609338269776228 10 | 299B,0.3040345786046943,0.2620383838975675 11 | 300B,0.2677650415447881,0.312600964581816 12 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionA/inference1_removefeature.csv: -------------------------------------------------------------------------------- 1 | uid 2 | 291 3 | 292 4 | 293 5 | 294 6 | 295 7 | 296 8 | 297 9 | 298 10 | 299 11 | 300 -------------------------------------------------------------------------------- /core/src/test/resources/regressionA/inference2.csv: -------------------------------------------------------------------------------- 1 | uid,x4,x5 2 | 291B,0.8480124243648866,0.9555639228515236 3 | 292A,0.058690366311673466,0.2411882434462061 4 | 293B,0.8111122234012546,0.11763673952117625 5 | 294C,0.4125838265336024,0.38073286019090624 6 | 295B,0.02088380696444414,0.8421215779351089 7 | 296A,0.0428238751552088,0.3704231065532555 8 | 297A,0.8414757856850273,0.31961702096825784 9 | 298C,0.09776643248186577,0.8616286143157607 10 | 299B,0.18480189742287045,0.8212617230419422 11 | 300B,0.6922842941832948,0.2481534972391123 12 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionA/readme.txt: -------------------------------------------------------------------------------- 1 | 联邦学习线性回归算法,垂直样本 2 | actual weight is w=[4, 7, 9, 7, 4, 7],b=72.0 3 | 4 | inference 数据集的实际结果是: 5 | 291,89.60986015354005 6 | 292,91.70476651790817 7 | 293,87.44380042155758 8 | 294,91.47558896705452 9 | 295,96.93425648144094 10 | 296,87.04291071249907 11 | 297,87.48221336001339 12 | 298,97.57524667959672 13 | 299,92.24632611397192 14 | 300,86.4052878135539 15 | 16 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionA_TwoPartner/inference0.csv: -------------------------------------------------------------------------------- 1 | uid,x0,x1 2 | 291B,0.21444106475157845,0.04996388474568747 3 | 292A,0.7944067018474512,0.8861544687235355 4 | 293B,0.658829251569282,0.4851542473709365 5 | 294C,0.9339425034214132,0.6404827725090099 6 | 295B,0.8312541673269118,0.6088112562622189 7 | 296A,0.3353810478843261,0.30130126153951753 8 | 297A,0.4706547473499929,0.2664618344005784 9 | 298C,0.6035958154305429,0.7297353851688908 10 | 299B,0.8445586350352466,0.8297011325240027 11 | 300B,0.1378862833164921,0.6769327235205828 12 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionA_TwoPartner/inference1.csv: -------------------------------------------------------------------------------- 1 | uid,x2,x3,x4,x5 2 | 291B,0.272078354,0.557380058,0.848012424,0.955563923 3 | 292A,0.833115264,0.114946594,0.058690366,0.241188243 4 | 293B,0.45680646,0.185336384,0.811112223,0.11763674 5 | 294C,0.747177986,0.033432634,0.412583827,0.38073286 6 | 295B,0.49728543,0.987513921,0.020883807,0.842121578 7 | 296A,0.856424507,0.166288407,0.042823875,0.370423107 8 | 297A,0.3522435,0.412640997,0.841475786,0.319617021 9 | 298C,0.807726566,0.60933827,0.097766432,0.861628614 10 | 299B,0.304034579,0.262038384,0.184801897,0.821261723 11 | 300B,0.267765042,0.312600965,0.692284294,0.248153497 12 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionA_TwoPartner/readme.txt: -------------------------------------------------------------------------------- 1 | 联邦学习线性回归算法,垂直样本 2 | actual weight is w=[4, 7, 9, 7, 4, 7],b=72.0 3 | 4 | inference 数据集的实际结果是: 5 | 291,89.60986015354005 6 | 292,91.70476651790817 7 | 293,87.44380042155758 8 | 294,91.47558896705452 9 | 295,96.93425648144094 10 | 296,87.04291071249907 11 | 297,87.48221336001339 12 | 298,97.57524667959672 13 | 299,92.24632611397192 14 | 300,86.4052878135539 15 | 16 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionC/readme.txt: -------------------------------------------------------------------------------- 1 | 联邦学习线性回归算法,垂直样本, 各方都有 y 2 | ======= 3 | 4 | actual weight is w=[4, 7, 9, 7, 4, 7],b=72.0 5 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionD/readme.txt: -------------------------------------------------------------------------------- 1 | 联邦学习线性回归算法,混合样本, 各方都有 y 2 | actual weight is w=[4, 7, 9, 7, 4, 7],b=72.0 3 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionF/readme.txt: -------------------------------------------------------------------------------- 1 | 联邦学习线性回归算法,垂直样本,样本 label 分散在三个平台,各 100 个有 label 样本和 200 个无 label 样本 2 | actual weight is w=[4, 7, 9, 7, 4, 7],b=72.0 3 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionF/test1.csv: -------------------------------------------------------------------------------- 1 | uid,2,3,y 2 | 101,0.759531278,0.773317569,95.66392852 3 | 102,0.912981667,0.561815138,99.08085266 4 | 103,0.890949968,0.977760798,98.35914349 5 | 104,0.082351847,0.75597727,90.50706626 6 | 105,0.892920257,0.805083351,93.29930706 7 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionF/test2.csv: -------------------------------------------------------------------------------- 1 | uid,4,5,y 2 | 201,0.29352053,0.255182284,93.94436132 3 | 202,0.583419011,0.164758112,97.64311603 4 | 203,0.289811241,0.037083606,87.37712064 5 | 204,0.701077889,0.71528362,98.22105334 6 | 205,0.137443383,0.836611321,84.59338801 7 | -------------------------------------------------------------------------------- /core/src/test/resources/regressionG/inference1.csv: -------------------------------------------------------------------------------- 1 | uid 2 | 291 3 | 292 4 | 293 5 | 294 6 | 295 7 | 296 8 | 297 9 | 298 10 | 299 11 | 300 -------------------------------------------------------------------------------- /core/src/test/resources/regressionG/inference2.csv: -------------------------------------------------------------------------------- 1 | uid,x2,x3 2 | 291,0.2720783537908599,0.5573800583315913 3 | 292,0.833115264179749,0.11494659437661481 4 | 293,0.45680646013937254,0.18533638361991267 5 | 294,0.7471779863120398,0.033432633995296834 6 | 295,0.4972854295710559,0.9875139208377152 7 | 296,0.8564245071473828,0.1662884066490331 8 | 297,0.35224349996340787,0.4126409970708691 9 | 298,0.8077265663850443,0.609338269776228 10 | 299,0.3040345786046943,0.2620383838975675 11 | 300,0.2677650415447881,0.31260096458181597 -------------------------------------------------------------------------------- /core/src/test/resources/regressionG/inference3.csv: -------------------------------------------------------------------------------- 1 | uid,x4,x5 2 | 291,0.8480124243648866,0.9555639228515235 3 | 292,0.05869036631167346,0.24118824344620615 4 | 293,0.8111122234012546,0.11763673952117626 5 | 294,0.41258382653360237,0.38073286019090624 6 | 295,0.02088380696444414,0.8421215779351089 7 | 296,0.0428238751552088,0.3704231065532555 8 | 297,0.8414757856850273,0.31961702096825784 9 | 298,0.09776643248186578,0.8616286143157607 10 | 299,0.18480189742287045,0.8212617230419422 11 | 300,0.6922842941832948,0.2481534972391123 -------------------------------------------------------------------------------- /core/src/test/resources/regressionG/readme.txt: -------------------------------------------------------------------------------- 1 | 联邦学习线性回归算法,垂直样本 2 | actual weight is w=[4, 7, 9, 7, 4, 7],b=72.0 3 | 4 | inference 数据集的实际结果是: 5 | 291,89.60986015354005 6 | 292,91.70476651790817 7 | 293,87.44380042155758 8 | 294,91.47558896705452 9 | 295,96.93425648144094 10 | 296,87.04291071249907 11 | 297,87.48221336001339 12 | 298,97.57524667959672 13 | 299,92.24632611397192 14 | 300,86.4052878135539 15 | 16 | -------------------------------------------------------------------------------- /manager/src/main/java/com/jdt/fedlearn/manager/spring/Constant.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.manager.spring; 14 | 15 | import org.springframework.context.ApplicationContext; 16 | 17 | public class Constant { 18 | public static ApplicationContext applicationContext; 19 | } 20 | -------------------------------------------------------------------------------- /manager/src/main/java/com/jdt/fedlearn/manager/spring/SpringBean.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.manager.spring; 14 | 15 | import org.springframework.context.annotation.Configuration; 16 | import org.springframework.context.annotation.ImportResource; 17 | 18 | /** 19 | * @Description: 获取配置文件 20 | */ 21 | @Configuration 22 | @ImportResource({"classpath:manager-applicationContext.xml"}) 23 | public class SpringBean { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /manager/src/main/java/com/jdt/fedlearn/manager/task/Executor.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.manager.task; 14 | 15 | import com.jdt.fedlearn.common.entity.CommonResultStatus; 16 | import com.jdt.fedlearn.common.entity.Task; 17 | 18 | /** 19 | * @Description: 任务执行器 20 | */ 21 | public interface Executor { 22 | 23 | /** 24 | * 服务器执行下一个任务 25 | * @param task 任务 26 | * @return 返回任务执行状态 27 | */ 28 | CommonResultStatus run(Task task); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /manager/src/main/java/com/jdt/fedlearn/manager/worker/service/IWorkerSelect.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.manager.worker.service; 14 | 15 | import com.jdt.fedlearn.common.entity.Task; 16 | import com.jdt.fedlearn.common.entity.WorkerUnit; 17 | 18 | /** 19 | * @className: WorkerSelect 20 | * @description: 定义选择执行任务的worker接口 21 | * @author: geyan29 22 | * @createTime: 2021/10/22 5:16 下午 23 | */ 24 | public interface IWorkerSelect { 25 | WorkerUnit getWorker(Task readyTask); 26 | } 27 | -------------------------------------------------------------------------------- /manager/src/main/resources/manager-applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /manager/src/main/resources/manager.properties: -------------------------------------------------------------------------------- 1 | # 应用名,启动脚本会用到,与logback.xml 内的app保持一致 2 | app.name=fedlearning-disframe-manager 3 | # 启动端口 4 | app.port=8095 5 | # 日志文件路径 6 | log.settings=/export/Config/logback.xml 7 | # worker端地址,多个用分号分隔 8 | workers.address=127.0.0.1:9094;127.0.0.1:9095 9 | # 默认的worker 10 | default.worker=http://127.0.0.1:9094 -------------------------------------------------------------------------------- /manager/src/test/resources/conf/manager.properties: -------------------------------------------------------------------------------- 1 | # 应用名,启动脚本会用到,与logback.xml 内的app保持一致 2 | app.name=fedlearning-disframe-manager 3 | # 启动端口 4 | app.port=9090 5 | # 日志文件路径 6 | log.settings=src/main/assembly/conf/logback.xml 7 | # workers端地址,多个用分号分隔 8 | workers.address=127.0.0.1:9094;127.0.0.1:9095 9 | # 默认的worker 10 | default.worker=http://127.0.0.1:9094 -------------------------------------------------------------------------------- /manager/src/test/resources/manager-applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tools/src/main/Expr.g4: -------------------------------------------------------------------------------- 1 | grammar Expr; 2 | /** 起始规则 语法分析器起点 */ 3 | prog: stat+ ; 4 | 5 | stat: expr NEWLINE # printExpr 6 | | ID '=' expr NEWLINE # assign 7 | | NEWLINE # blank 8 | ; 9 | 10 | expr: 11 | ID '(' expr (',' expr)* ')' # Method 12 | | expr op=('*'|'/') expr # MulDiv 13 | | expr op=('+'|'-') expr # AddSub 14 | | '-' DOUBLE # Negative 15 | | DOUBLE # double 16 | | ID # id 17 | | '(' expr ')' # paren 18 | ; 19 | 20 | DOUBLE : [0-9] + ('.'[0-9]+)? ; 21 | ID : ([a-zA-Z0-9] | '_' | '.' )+ ; 22 | NEWLINE : '\r'? '\n' |';'; 23 | WS : [ \t]+ -> skip ; 24 | MUL : '*' ; 25 | DIV : '/' ; 26 | Add : '+' ; 27 | SUB : '-' ; 28 | -------------------------------------------------------------------------------- /tools/src/main/java/com/jdt/fedlearn/tools/ExprErrorListener.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.tools; 2 | 3 | import org.antlr.v4.runtime.BaseErrorListener; 4 | import org.antlr.v4.runtime.RecognitionException; 5 | import org.antlr.v4.runtime.Recognizer; 6 | 7 | import java.util.NoSuchElementException; 8 | 9 | /*** 10 | * 语法树错误监听 11 | * @author Peng Zhengyang 12 | */ 13 | public class ExprErrorListener extends BaseErrorListener { 14 | public static ExprErrorListener INSTANCE = new ExprErrorListener(); 15 | @Override 16 | public void syntaxError(Recognizer recognizer, Object object, int line, int position, String msg, 17 | RecognitionException e) { 18 | throw new NoSuchElementException("line:" + line + " column:" + position + " " + msg); 19 | } 20 | } -------------------------------------------------------------------------------- /tools/src/main/java/com/jdt/fedlearn/tools/LogUtil.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.tools; 15 | 16 | public class LogUtil { 17 | public static String logLine(String data) { 18 | if (null == data) { 19 | return "null"; 20 | } 21 | int end = Math.min(data.length(), 40); 22 | return data.substring(0, end); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tools/src/main/java/com/jdt/fedlearn/tools/antlrGenerate/Expr.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | DOUBLE=5 6 | ID=6 7 | NEWLINE=7 8 | WS=8 9 | MUL=9 10 | DIV=10 11 | Add=11 12 | SUB=12 13 | '='=1 14 | '('=2 15 | ','=3 16 | ')'=4 17 | '*'=9 18 | '/'=10 19 | '+'=11 20 | '-'=12 21 | -------------------------------------------------------------------------------- /tools/src/main/java/com/jdt/fedlearn/tools/antlrGenerate/ExprLexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | DOUBLE=5 6 | ID=6 7 | NEWLINE=7 8 | WS=8 9 | MUL=9 10 | DIV=10 11 | Add=11 12 | SUB=12 13 | '='=1 14 | '('=2 15 | ','=3 16 | ')'=4 17 | '*'=9 18 | '/'=10 19 | '+'=11 20 | '-'=12 21 | -------------------------------------------------------------------------------- /tools/src/main/java/com/jdt/fedlearn/tools/netty/server/SocketServerInitializer.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.tools.netty.server; 2 | 3 | import io.netty.channel.ChannelInitializer; 4 | import io.netty.channel.ChannelPipeline; 5 | import io.netty.channel.socket.SocketChannel; 6 | import io.netty.handler.codec.serialization.ClassResolvers; 7 | import io.netty.handler.codec.serialization.ObjectDecoder; 8 | import io.netty.handler.codec.serialization.ObjectEncoder; 9 | 10 | /** 11 | * @Title: NioServerHandler 12 | * @Description: 服务器Channel通道初始化设置 13 | * @date 2018/6/415:29 14 | */ 15 | public class SocketServerInitializer extends ChannelInitializer { 16 | @Override 17 | protected void initChannel(SocketChannel socketChannel) throws Exception { 18 | ChannelPipeline pipeline = socketChannel.pipeline(); 19 | pipeline.addLast(new ObjectDecoder(Integer.MAX_VALUE,ClassResolvers.cacheDisabled(null))); 20 | pipeline.addLast(new ObjectEncoder()); 21 | //服务器的逻辑 22 | pipeline.addLast(new SocketServerHandler()); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tools/src/main/java/com/jdt/fedlearn/tools/serializer/Serializer.java: -------------------------------------------------------------------------------- 1 | package com.jdt.fedlearn.tools.serializer; 2 | 3 | import com.jdt.fedlearn.common.entity.core.Message; 4 | 5 | public interface Serializer { 6 | /** 7 | * 8 | * @param message Message 类型的实体 9 | * @return 字符串 10 | */ 11 | String serialize(Message message); 12 | 13 | /** 14 | * 15 | * @param str 字符串 16 | * @return 对象 17 | */ 18 | Message deserialize(String str); 19 | } 20 | -------------------------------------------------------------------------------- /tools/src/test/resources/file/mo17k_test.csv: -------------------------------------------------------------------------------- 1 | uid,x0,x1 2 | 291,0.21444106475157843,0.04996388474568747 3 | 292,0.7944067018474512,0.8861544687235355 4 | 293,0.658829251569282,0.4851542473709365 5 | 294,0.9339425034214133,0.6404827725090099 6 | 295,0.8312541673269118,0.6088112562622189 7 | 296,0.3353810478843261,0.30130126153951753 8 | 297,0.4706547473499929,0.26646183440057836 9 | 298,0.6035958154305429,0.7297353851688908 10 | 299,0.8445586350352466,0.8297011325240027 11 | 300,0.1378862833164921,0.6769327235205828 -------------------------------------------------------------------------------- /worker/src/main/java/com/jdt/fedlearn/worker/spring/Constant.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package com.jdt.fedlearn.worker.spring; 15 | 16 | import org.springframework.context.ApplicationContext; 17 | 18 | public class Constant { 19 | public static ApplicationContext applicationContext; 20 | } 21 | -------------------------------------------------------------------------------- /worker/src/main/java/com/jdt/fedlearn/worker/spring/SpringBean.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.worker.spring; 14 | 15 | import org.springframework.context.annotation.Configuration; 16 | import org.springframework.context.annotation.ImportResource; 17 | 18 | /** 19 | * @Author: liuzhaojun10 20 | * @Date: 2020/9/3 08:21 21 | * @Description: 22 | */ 23 | @Configuration 24 | @ImportResource({"classpath:worker-applicationContext.xml"}) 25 | public class SpringBean { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /worker/src/main/resources/worker-applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /worker/src/main/resources/worker.properties: -------------------------------------------------------------------------------- 1 | manager.address=http://127.0.0.1:8095 2 | #是否主动注册(当服务器已经启动后,可以通过和这个主动注册) 3 | auto.register=false 4 | 5 | # 目前配置文件 6 | # 应用名,启动脚本会用到,与logback.xml 内的app保持一致 7 | app.name=fedlearning-disframe-work 8 | # 启动端口 9 | app.port=9094 10 | # 日志文件路径 11 | log.settings=/export/Config/logback.xml 12 | # master端地址,多个用逗号分隔 13 | master.address=127.0.0.1 14 | 15 | # train config, 支持多个数据源 16 | #hdfs数据源配置 17 | hdfs.uri=hdfs://ThinkStation-P320:9000 18 | hdfs.user=root 19 | 20 | # train config, 支持多个数据源 21 | train1.source=hdfs 22 | train1.base=/ 23 | #train1.source=csv 24 | #train1.base=/Users/geyan29/202104/bank/ 25 | train1.dataset=class0_train.csv 26 | 27 | 28 | # inference config 29 | inference.data.source=csv 30 | inference.base=/Users/bank/ 31 | inference.dataset1=class0_test.csv 32 | 33 | #是否允许预测训练集中的uid 34 | inference.allowTrainUid=True 35 | 36 | # id对齐结果输出保存配置 37 | idMatch.dir=/export/Data/federated-learning-client/idMatch/ 38 | 39 | # 模型保存路径 40 | model.dir=/Users/model/ 41 | 42 | #预测结果文件 43 | predict.dir=/Users/predict/ 44 | -------------------------------------------------------------------------------- /worker/src/test/java/com/jdt/fedlearn/worker/util/ToolsTest.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 The FedLearn Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package com.jdt.fedlearn.worker.util; 14 | 15 | 16 | import org.testng.Assert; 17 | import org.testng.annotations.Test; 18 | 19 | public class ToolsTest { 20 | private static final String ip = "192.168.0.1"; 21 | @Test 22 | public void extractIp() { 23 | String ipStr = "aaa-"+ ip +"/asdasd"; 24 | String s = Tools.extractIp(ipStr); 25 | Assert.assertEquals(s,ip); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /worker/src/test/resources/conf/worker.properties: -------------------------------------------------------------------------------- 1 | # master端地址,多个用逗号分隔 2 | manager.address=http://127.0.0.1:8099 3 | #是否主动注册(当服务器已经启动后,可以通过和这个主动注册) 4 | auto.register=true 5 | 6 | # 目前配置文件 7 | # 应用名,启动脚本会用到,与logback.xml 内的app保持一致 8 | app.name=fedlearning-disframe-work 9 | # 启动端口 10 | app.port=9099 11 | # 日志文件路径 12 | log.settings=src/test/resources/logback-test.xml 13 | # master端地址,多个用逗号分隔 14 | master.address=127.0.0.1 15 | 16 | #hdfs数据源配置 17 | hdfs.uri=hdfs://wanghaihe-ThinkStation-P320:9000 18 | hdfs.user=root 19 | 20 | 21 | # train config, 支持多个数据源 22 | train1.source=csv 23 | train1.base=src/test/resources/demo/ 24 | train1.dataset=mo17k.csv 25 | 26 | 27 | # inference config 28 | inference1.source=csv 29 | inference1.base=src/test/resources/demo/ 30 | inference1.dataset=mo17k_test.csv 31 | 32 | #是否允许预测训练集中的uid 33 | inference.allowTrainUid=True 34 | 35 | # 模型保存路径 36 | model.dir=src/test/resources/model/ 37 | match.dir=src/test/resources/model/ 38 | #预测结果文件 39 | predict.dir=src/test/resources/demo/predict/ -------------------------------------------------------------------------------- /worker/src/test/resources/demo/mo17k.csv: -------------------------------------------------------------------------------- 1 | uid,job,previous,balance,education,campaign,poutcome,y 2 | 19393tA,1,0,141,1,1,3,0 3 | 1331vB,9,0,675,2,1,3,0 4 | 7656wQ,1,0,154,1,12,3,0 5 | 34879uN,0,0,-244,1,1,3,0 6 | 16393tv,7,0,90,0,4,3,0 7 | 1514kq,4,0,570,2,2,3,0 8 | 36435go,9,0,18254,2,2,3,0 9 | 27004TS,2,0,285,2,1,3,0 10 | 4526LH,4,0,2007,2,1,3,0 11 | 4879ZM,4,0,1343,2,1,3,0 12 | 20062pI,4,0,581,2,2,3,0 13 | 38474dp,1,1,1614,1,2,1,0 14 | 25356Ux,9,0,1432,1,3,3,0 15 | 7203Cp,7,0,-456,1,4,3,0 16 | 41891lx,11,0,8,0,2,3,0 17 | 32852Du,9,3,710,1,1,0,0 18 | 6762Yo,1,0,674,1,1,3,0 19 | 12739pQ,6,0,1523,1,2,3,0 20 | 2651gN,1,0,1357,0,2,3,0 -------------------------------------------------------------------------------- /worker/src/test/resources/demo/mo17k.csv.success: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /worker/src/test/resources/demo/mo17k_result.csv: -------------------------------------------------------------------------------- 1 | 19393tA,1.0 2 | -------------------------------------------------------------------------------- /worker/src/test/resources/demo/mo17k_test.csv: -------------------------------------------------------------------------------- 1 | uid,x0,x1 2 | 291,0.21444106475157843,0.04996388474568747 3 | 292,0.7944067018474512,0.8861544687235355 4 | 293,0.658829251569282,0.4851542473709365 5 | 294,0.9339425034214133,0.6404827725090099 6 | 295,0.8312541673269118,0.6088112562622189 7 | 296,0.3353810478843261,0.30130126153951753 8 | 297,0.4706547473499929,0.26646183440057836 9 | 298,0.6035958154305429,0.7297353851688908 10 | 299,0.8445586350352466,0.8297011325240027 11 | 300,0.1378862833164921,0.6769327235205828 -------------------------------------------------------------------------------- /worker/src/test/resources/demo/predict/predict.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fedlearnAI/fedlearn/d830fe4f384f9e78bbd43d5af948e4116332ca9a/worker/src/test/resources/demo/predict/predict.txt -------------------------------------------------------------------------------- /worker/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0} - %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /worker/src/test/resources/model/124-DistributedRandomForest-210427162559.model: -------------------------------------------------------------------------------- 1 | {numTrees=2, Tree1={"2":{"referenceJson":"{\"is_leaf\":0,\"feature_opt\":5,\"value_opt\":-1.5528796603095012E-7}","isLeaf":"0","nodeId":"2","party":"{\"ip\":\"127.0.0.1\",\"port\":8095,\"protocol\":\"http\",\"uniqueId\":-1116352052}"},"3":{"referenceJson":"{\"is_leaf\":0,\"feature_opt\":1,\"value_opt\":1.3344519605192283E-6}","isLeaf":"0","nodeId":"3","party":"{\"ip\":\"127.0.0.1\",\"port\":8095,\"protocol\":\"http\",\"uniqueId\":-1116352052}"}}, Tree0={}, localModelType=Null, localModel={alpha0.0beta0.00.00.00.00.00.0}} -------------------------------------------------------------------------------- /worker/src/test/resources/model/2-MD5-210719144319.txt: -------------------------------------------------------------------------------- 1 | 19393tA 2 | 1331vB 3 | 7656wQ 4 | 34879uN 5 | 16393tv 6 | 1514kq 7 | 36435go 8 | 27004TS 9 | 4526LH 10 | 4879ZM 11 | 20062pI 12 | 38474dp 13 | 25356Ux 14 | 7203Cp 15 | 41891lx 16 | 32852Du 17 | 6762Yo 18 | 12739pQ 19 | 2651gN -------------------------------------------------------------------------------- /worker/src/test/resources/regressionA/inference1.csv: -------------------------------------------------------------------------------- 1 | uid,x0,x1 2 | 291,0.21444106475157843,0.04996388474568747 3 | 292,0.7944067018474512,0.8861544687235355 4 | 293,0.658829251569282,0.4851542473709365 5 | 294,0.9339425034214133,0.6404827725090099 6 | 295,0.8312541673269118,0.6088112562622189 7 | 296,0.3353810478843261,0.30130126153951753 8 | 297,0.4706547473499929,0.26646183440057836 9 | 298,0.6035958154305429,0.7297353851688908 10 | 299,0.8445586350352466,0.8297011325240027 11 | 300,0.1378862833164921,0.6769327235205828 -------------------------------------------------------------------------------- /worker/src/test/resources/regressionA/inference2.csv: -------------------------------------------------------------------------------- 1 | uid,x2,x3 2 | 291,0.2720783537908599,0.5573800583315913 3 | 292,0.833115264179749,0.11494659437661481 4 | 293,0.45680646013937254,0.18533638361991267 5 | 294,0.7471779863120398,0.033432633995296834 6 | 295,0.4972854295710559,0.9875139208377152 7 | 296,0.8564245071473828,0.1662884066490331 8 | 297,0.35224349996340787,0.4126409970708691 9 | 298,0.8077265663850443,0.609338269776228 10 | 299,0.3040345786046943,0.2620383838975675 11 | 300,0.2677650415447881,0.31260096458181597 -------------------------------------------------------------------------------- /worker/src/test/resources/regressionA/inference3.csv: -------------------------------------------------------------------------------- 1 | uid,x4,x5 2 | 291,0.8480124243648866,0.9555639228515235 3 | 292,0.05869036631167346,0.24118824344620615 4 | 293,0.8111122234012546,0.11763673952117626 5 | 294,0.41258382653360237,0.38073286019090624 6 | 295,0.02088380696444414,0.8421215779351089 7 | 296,0.0428238751552088,0.3704231065532555 8 | 297,0.8414757856850273,0.31961702096825784 9 | 298,0.09776643248186578,0.8616286143157607 10 | 299,0.18480189742287045,0.8212617230419422 11 | 300,0.6922842941832948,0.2481534972391123 -------------------------------------------------------------------------------- /worker/src/test/resources/regressionA/readme.txt: -------------------------------------------------------------------------------- 1 | 联邦学习线性回归算法,垂直样本 2 | actual weight is w=[4, 7, 9, 7, 4, 7],b=72.0 3 | 4 | inference 数据集的实际结果是: 5 | 291,89.60986015354005 6 | 292,91.70476651790817 7 | 293,87.44380042155758 8 | 294,91.47558896705452 9 | 295,96.93425648144094 10 | 296,87.04291071249907 11 | 297,87.48221336001339 12 | 298,97.57524667959672 13 | 299,92.24632611397192 14 | 300,86.4052878135539 15 | 16 | --------------------------------------------------------------------------------