diff --git a/pom.xml b/pom.xml index 2c0fe684..a330680c 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ be accompanied by a bump in version number, regardless of how minor the change. 0.10.1 --> - 0.10.4 + 0.10.6 diff --git a/src/main/java/quickml/supervised/predictiveModelOptimizer/PredictiveModelOptimizer.java b/src/main/java/quickml/supervised/predictiveModelOptimizer/PredictiveModelOptimizer.java index 13f49b21..237c4675 100644 --- a/src/main/java/quickml/supervised/predictiveModelOptimizer/PredictiveModelOptimizer.java +++ b/src/main/java/quickml/supervised/predictiveModelOptimizer/PredictiveModelOptimizer.java @@ -28,7 +28,7 @@ public class PredictiveModelOptimizer { * @param crossValidator - Model tester takes a configuration and returns the loss */ - protected PredictiveModelOptimizer(Map fieldsToOptimize, SimpleCrossValidator crossValidator, int iterations) { + public PredictiveModelOptimizer(Map fieldsToOptimize, SimpleCrossValidator crossValidator, int iterations) { this.fieldsToOptimize = fieldsToOptimize; this.crossValidator = crossValidator; this.iterations = iterations; diff --git a/src/test/java/quickml/supervised/classifier/logRegression/LogisticRegressionBuilderTest.java b/src/test/java/quickml/supervised/classifier/logRegression/LogisticRegressionBuilderTest.java index ec077780..8502fdf1 100644 --- a/src/test/java/quickml/supervised/classifier/logRegression/LogisticRegressionBuilderTest.java +++ b/src/test/java/quickml/supervised/classifier/logRegression/LogisticRegressionBuilderTest.java @@ -17,6 +17,7 @@ import quickml.supervised.crossValidation.data.FoldedData; import quickml.supervised.crossValidation.data.OutOfTimeData; import quickml.supervised.crossValidation.lossfunctions.classifierLossFunctions.ClassifierLossFunction; +import quickml.supervised.crossValidation.lossfunctions.classifierLossFunctions.ClassifierRMSELossFunction; import quickml.supervised.crossValidation.lossfunctions.classifierLossFunctions.WeightedAUCCrossValLossFunction; import quickml.supervised.dataProcessing.instanceTranformer.CommonCoocurrenceProductFeatureAppender; import quickml.supervised.ensembles.randomForest.randomDecisionForest.RandomDecisionForestBuilder; @@ -78,7 +79,7 @@ public void testAdInstances() { logger.info("RF out of time loss: {}", simpleCrossValidator.getLossForModel()); } - + @Test public void testDiabetesInstances() { //need a builder @@ -103,10 +104,10 @@ public void testDiabetesInstances() { .maxEpochs(16000) .useBoldDriver(false) .learningRateReductionFactor(0.01)); - ClassifierLossFunction lossFunction = new WeightedAUCCrossValLossFunction(1.0);//);//new ClassifierRMSELossFunction();//new WeightedAUCCrossValLossFunction(1.0);//new ClassifierRMSELossFunction();//new ClassifierLogCVLossFunction(1E-5);//new WeightedAUCCrossValLossFunction(1.0); + ClassifierLossFunction lossFunction = new ClassifierRMSELossFunction();//);//new ClassifierRMSELossFunction();//new WeightedAUCCrossValLossFunction(1.0);//new ClassifierRMSELossFunction();//new ClassifierLogCVLossFunction(1E-5);//new WeightedAUCCrossValLossFunction(1.0); EnhancedCrossValidator enhancedCrossValidator = new EnhancedCrossValidator<>(logisticRegressionBuilder, - new ClassifierLossChecker(new WeightedAUCCrossValLossFunction(1.0)), + new ClassifierLossChecker(lossFunction), new FoldedDataFactory(4, 4), instances); diff --git a/src/test/java/quickml/supervised/crossValidation/InterfacesCompilationTest.java b/src/test/java/quickml/supervised/crossValidation/InterfacesCompilationTest.java new file mode 100644 index 00000000..48911a9b --- /dev/null +++ b/src/test/java/quickml/supervised/crossValidation/InterfacesCompilationTest.java @@ -0,0 +1,113 @@ +package quickml.supervised.crossValidation; + +import quickml.data.instances.ClassifierInstance; +import quickml.data.instances.Instance; +import quickml.supervised.PredictiveModel; +import quickml.supervised.classifier.logisticRegression.LogisticRegression; +import quickml.supervised.classifier.logisticRegression.SparseClassifierInstance; + +import java.util.List; + +/** + * Created by alexanderhawk on 11/11/15. + */ +public class InterfacesCompilationTest { + + public interface CopyableData> { + T copyWithJustTrainingSet(List trainingSet); + } + + public interface Transformed { + public abstract List getTransformedInstances(); + } + + + public interface TransformedData> {//extends Transformed, CopyableData { + D copyWithJustTrainingSet(List trainingSet); + public abstract List getTransformedInstances(); + +// public TransformedData() { +// super(); +// } + } + +//what is the problem? copy needs to return the dynamic type of the object, and right now it returns +// a TransformedDataWithDates. What can i do differently? Move where copy is being called...no a TransformededData object needs to be copyable + //could reduce the type constraints on D with the documentation saying what it should be. But this means i can't do meta programming later, on presumed methods. + //Note in python...can't write generic methods with the assumption that certain objects will have methods? or can we. Can't do it safely. + + + + public interface TransformedDataWithDates> extends TransformedData { +// public TransformedDataWithDates() { +// super(); +// } + + public abstract void getDateTimeExtractor(); + } + + //what type of D is inherited? + public static abstract class LogisticRegressionDTO> implements TransformedDataWithDates + { + + } + + public static class MeanNormalizedAndDatedLogisticRegressionDTO extends LogisticRegressionDTO { + @Override + public void getDateTimeExtractor() { + + } + + @Override + public MeanNormalizedAndDatedLogisticRegressionDTO copyWithJustTrainingSet(final List trainingSet) { + return null; + } + + @Override + public List getTransformedInstances() { + return null; + } + } + + + ///gen datatransformers + public interface DataTransformer> {//TransformedData> { + + void transformData(List rawInstance, D data); + } + + public static class DatedAndMeanNormalizedLogisticRegressionDataTransformer implements DataTransformer { + @Override + public void transformData(final List rawInstance, final MeanNormalizedAndDatedLogisticRegressionDTO data) { + + } + } + + //model builders + public interface EnhancedPredictiveModelBuilder

> + extends DataTransformer { + + P buildPredictiveModel(D transformedData); + } + + + + public static class LogisticRegressionBuilder> implements EnhancedPredictiveModelBuilder { + @Override + public LogisticRegression buildPredictiveModel(final D transformedData) { + return null; + } + + @Override + public void transformData(final List rawInstance, final D data) { + + } + } + public static void main(String[] args) { + LogisticRegressionBuilder logisticRegressionBuilder = new LogisticRegressionBuilder(); + } + + //ok, so what is the problem now. The methods are not able to use the generics. + //options: i can change the interface of EnhancedPredictiveModelBuilder. Or, I can make TransformedDataWithDates do something else in it's interface...i.e. i can make it implement copyable of a different generic type. + + }