Skip to content

Commit

Permalink
Merge pull request #148 from sanity/addLogistic
Browse files Browse the repository at this point in the history
bumped version number
  • Loading branch information
athawk81 committed Nov 12, 2015
2 parents c095b73 + c2682be commit 7cc3dff
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
be accompanied by a bump in version number, regardless of how minor the change.
0.10.1 -->

<version> 0.10.4</version>
<version> 0.10.6</version>

<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class PredictiveModelOptimizer {
* @param crossValidator - Model tester takes a configuration and returns the loss
*/

protected PredictiveModelOptimizer(Map<String, ? extends FieldValueRecommender> fieldsToOptimize, SimpleCrossValidator crossValidator, int iterations) {
public PredictiveModelOptimizer(Map<String, ? extends FieldValueRecommender> fieldsToOptimize, SimpleCrossValidator crossValidator, int iterations) {
this.fieldsToOptimize = fieldsToOptimize;
this.crossValidator = crossValidator;
this.iterations = iterations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,7 +79,7 @@ public void testAdInstances() {
logger.info("RF out of time loss: {}", simpleCrossValidator.getLossForModel());

}

@Test
public void testDiabetesInstances() {
//need a builder
Expand All @@ -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<LogisticRegression, ClassifierInstance, SparseClassifierInstance, MeanNormalizedAndDatedLogisticRegressionDTO> enhancedCrossValidator = new EnhancedCrossValidator<>(logisticRegressionBuilder,
new ClassifierLossChecker(new WeightedAUCCrossValLossFunction(1.0)),
new ClassifierLossChecker(lossFunction),
new FoldedDataFactory(4, 4), instances);


Expand Down
Original file line number Diff line number Diff line change
@@ -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<R extends Instance, T extends Transformed<R>> {
T copyWithJustTrainingSet(List<R> trainingSet);
}

public interface Transformed<R extends Instance> {
public abstract List<R> getTransformedInstances();
}


public interface TransformedData<R extends Instance, D extends TransformedData<R, D>> {//extends Transformed<R>, CopyableData<R, D> {
D copyWithJustTrainingSet(List<R> trainingSet);
public abstract List<R> 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<I, D>. 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<I extends Instance, D extends TransformedDataWithDates<I, D>> extends TransformedData<I, D> {
// public TransformedDataWithDates() {
// super();
// }

public abstract void getDateTimeExtractor();
}

//what type of D is inherited?
public static abstract class LogisticRegressionDTO<D extends LogisticRegressionDTO<D>> implements TransformedDataWithDates<SparseClassifierInstance, D>
{

}

public static class MeanNormalizedAndDatedLogisticRegressionDTO extends LogisticRegressionDTO<MeanNormalizedAndDatedLogisticRegressionDTO> {
@Override
public void getDateTimeExtractor() {

}

@Override
public MeanNormalizedAndDatedLogisticRegressionDTO copyWithJustTrainingSet(final List<SparseClassifierInstance> trainingSet) {
return null;
}

@Override
public List<SparseClassifierInstance> getTransformedInstances() {
return null;
}
}


///gen datatransformers
public interface DataTransformer<I extends Instance, R extends Instance, D extends TransformedData<R, D>> {//TransformedData<R, D>> {

void transformData(List<I> rawInstance, D data);
}

public static class DatedAndMeanNormalizedLogisticRegressionDataTransformer implements DataTransformer<ClassifierInstance, SparseClassifierInstance, MeanNormalizedAndDatedLogisticRegressionDTO> {
@Override
public void transformData(final List<ClassifierInstance> rawInstance, final MeanNormalizedAndDatedLogisticRegressionDTO data) {

}
}

//model builders
public interface EnhancedPredictiveModelBuilder<P extends PredictiveModel, I extends Instance, R extends Instance, D extends TransformedData<R, D>>
extends DataTransformer<I, R, D> {

P buildPredictiveModel(D transformedData);
}



public static class LogisticRegressionBuilder<D extends LogisticRegressionDTO<D>> implements EnhancedPredictiveModelBuilder<LogisticRegression, ClassifierInstance, SparseClassifierInstance, D> {
@Override
public LogisticRegression buildPredictiveModel(final D transformedData) {
return null;
}

@Override
public void transformData(final List<ClassifierInstance> rawInstance, final D data) {

}
}
public static void main(String[] args) {
LogisticRegressionBuilder<MeanNormalizedAndDatedLogisticRegressionDTO> logisticRegressionBuilder = new LogisticRegressionBuilder<MeanNormalizedAndDatedLogisticRegressionDTO>();
}

//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.

}

0 comments on commit 7cc3dff

Please sign in to comment.