profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/hayesall/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Alexander L. Hayes hayesall ProHealth / StARLinG Lab Bloomington, IN, USA https://hayesall.com Health Informatics Ph.D. Student at Indiana University. Precision Health & Statistical Relational Learning. he/him

hayesall/rnlp 7

Relational NLP: Convert text into relational facts.

hayesall/awesome-bayes-nets 6

⚗️ A curated list of Books, Research Papers, and Software for Bayesian Networks.

hayesall/MaliciousPortableExecutableDetection 6

Determining whether a portable executable file (.exe) is malicious or benign with comparative results for multiple ML algorithms: AdaBoost, DT, GNB, GradientBoosting, KNN, RF.

hayesall/ffscraper 5

Yet another set of scraping tools for FanFiction.Net

hayesall/CLFanfictionSearchEngine 4

Search engine for Code Lyoko FanFiction, including some adapted scraping tools and indexers.

boost-starai/BoostSRL-Misc 3

Datasets, Tutorial Files, Wiki Images, and History of BoostSRL Jar Files

harshakokel/JA-Walk-ER 1

Just-another WALK-ER

hayesall/Botnet-Buster 1

Final project for Professor Sriraam Natarajan's spring seminar on Statistical Relational Learning. Applying SRL to the problem of discerning botnet traffic 🤖 from normal traffic 👩‍💻

hayesall/DrugInteractionDiscovery 1

Indiana University ProHealth REU 2016. Discern which drugs interact with which other drugs. Information extraction on text documents and scraping tools for openFDA, PubMed, and various blogs.

hayesall/nuMoM2b_preprocessing 1

φ Preprocessing scripts to create reproducible partitions of the nuMoM2b data set. Part of the Indiana University Precision Health Initiative.

startedPaulBrownMagic/FramesPersistency

started time in 39 minutes

PublicEvent

fork Hopson97/stb

stb single-file public domain libraries for C/C++

https://twitter.com/nothings

fork in 14 hours

issue closedjmschrei/pomegranate

log_probability returns -inf.

Hello!

I am building an HMM from samples like follows:

def train(self):
        seed = 123
        numpy.random.seed(seed)

        sequences = [self.states, self.training_data_set]

        self.model = HiddenMarkovModel.from_samples(
            DiscreteDistribution,
            self.number_of_components,
            sequences,
            n_jobs=10)

The training data set contains values of energy measured at a certain timestamp: 0 0 0 0 0 0 64.2 0 0 46.8 70.4 0 0 0 0 0 These are the first 16 values from the file. Before building the model, these values are scaled. I am predicting the next state by building windows of different lengths, for example [0, 0, 0, 0, 0, 0, 1, 0], and adding each other possible state at the end this sequence and retrieve the log probability:

def __get_predicted_next_state(self, state_sequence):
        maximum_probability = -math.inf
        predicted_next_state = -1

        for state in self.training_states:
            current_state_sequence = numpy.append(state_sequence, state)

            probability = self.model.log_probability(current_state_sequence)

            if probability > maximum_probability:
                maximum_probability = probability
                predicted_next_state = state

        return predicted_next_state

The sequence that has the biggest log probability gives the predicted value after the given window. However, for some given sequences, the log_probability method always returns -inf. What could be the issue?

Thank you!

closed time in 15 hours

MARIUSDRAGOS96

issue commentjmschrei/pomegranate

log_probability returns -inf.

Thank you very much!

MARIUSDRAGOS96

comment created time in 15 hours

startedpyexcel/pyexcel-odsr

started time in 15 hours

created repositoryrodrigodesalvobraz/qtableviewdraganddrop

created time in 20 hours

startedstardust66/openapi-type-provider

started time in a day

startedtsinghua-fib-lab/DICE

started time in a day

startedfendevel/Guide-to-Modern-OpenGL-Functions

started time in a day

created repositoryjtauber/jtauber

created time in a day

Pull request review commentlinqs/psl

Introduce RankingEvaluator, a test, and updates to options

         "Include in evaluation observed target atoms that match against a truth atom."     ); +    public static final Option EVAL_RANK_REPRESENTATIVE = new Option(+        "rankingevaluator.representative",+        RankingEvaluator.RepresentativeMetric.MRR.toString(),+        "The representative metric (see RankingEvaluator.RepresentativeMetric)."+    );++    public static final Option EVAL_RANK_DEFAULT_PREDICATE = new Option(+        "rankingevaluator.defaultpredicate",+        null,+        "The default predicate to use when none are supplied."+    );++    public static final Option EVAL_RANK_CATEGORY_INDEXES = new Option(+        "rankingevaluator.categoryindexes",+        "1",+        "The index (zero-indexed) of the argument in the predicate that indicate a category."+        + " The other arguments will be treated as identifiers."+    );++    public static final Option EVAL_RANK_THRESHOLD = new Option(+        "rankingevaluator.threshold",+        0.5,+        "The truth value threshold for ranking atoms.",+        Option.FLAG_NON_NEGATIVE+    );++

Extra newline.

almumill

comment created time in a day

Pull request review commentlinqs/psl

Introduce RankingEvaluator, a test, and updates to options

 protected void init(float[] predictions, float[] truth) {         truthDB.close();     } +    /**+     * Initialize a test setting where atoms have specified integer arguments.+     */+    protected void init(float[] predictions, float[] truth, int[][] predictionsArgs, int[][] truthArgs) {+        cleanup();++        dataStore = new RDBMSDataStore(new H2DatabaseDriver(+                H2DatabaseDriver.Type.Memory, this.getClass().getName(), true));++        int argCount = predictionsArgs[0].length;+        ConstantType[] constantTypes = new ConstantType[argCount];++        for (int i = 0; i < argCount; i++) {+            constantTypes[i] = ConstantType.UniqueIntID;+        }++        // Create a test predicates with unique names which map

Plurality issue.

almumill

comment created time in a day

Pull request review commentlinqs/psl

Introduce RankingEvaluator, a test, and updates to options

+/*+ * This file is part of the PSL software.+ * Copyright 2011-2015 University of Maryland+ * Copyright 2013-2021 The Regents of the University of California+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.linqs.psl.evaluation.statistics;++import org.linqs.psl.application.learning.weight.TrainingMap;+import org.linqs.psl.config.Options;+import org.linqs.psl.model.atom.GroundAtom;+import org.linqs.psl.model.atom.ObservedAtom;+import org.linqs.psl.model.atom.RandomVariableAtom;+import org.linqs.psl.model.predicate.Predicate;+import org.linqs.psl.model.predicate.StandardPredicate;+import org.linqs.psl.model.term.Constant;+import org.linqs.psl.util.StringUtils;++import java.util.ArrayList;+import java.util.Collections;+import java.util.HashMap;+import java.util.List;+import java.util.Map;++/**+ * Compute ranking-based statistics.+ */+public class RankingEvaluator extends Evaluator {+    public enum RepresentativeMetric {+        MRR+    }++    public static final String DELIM = ":";++    private RepresentativeMetric representative;+    private String defaultPredicate;+    private List<Integer> categoryIndexes;++    // This is the truth value threshold that truth atoms must pass+    // for us to use their corresponding target atom in a ranking+    // metric calculation.+    private double threshold;++    // Save the map from target atoms to truth atoms+    // for truth value lookups in ranking metric calculations.+    private Map<RandomVariableAtom, ObservedAtom> labelMap;++     // Maintain a map from predicted atoms+     // to their ranks (with respect to their individual+     // entities) for use in ranking metric calculations.+    private Map<GroundAtom, Integer> rankMap;

Note in the comment that 1 is best.

almumill

comment created time in a day

Pull request review commentlinqs/psl

Introduce RankingEvaluator, a test, and updates to options

+/*+ * This file is part of the PSL software.+ * Copyright 2011-2015 University of Maryland+ * Copyright 2013-2021 The Regents of the University of California+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.linqs.psl.evaluation.statistics;++import org.linqs.psl.application.learning.weight.TrainingMap;+import org.linqs.psl.config.Options;+import org.linqs.psl.model.atom.GroundAtom;+import org.linqs.psl.model.atom.ObservedAtom;+import org.linqs.psl.model.atom.RandomVariableAtom;+import org.linqs.psl.model.predicate.Predicate;+import org.linqs.psl.model.predicate.StandardPredicate;+import org.linqs.psl.model.term.Constant;+import org.linqs.psl.util.StringUtils;++import java.util.ArrayList;+import java.util.Collections;+import java.util.HashMap;+import java.util.List;+import java.util.Map;++/**+ * Compute ranking-based statistics.+ */+public class RankingEvaluator extends Evaluator {+    public enum RepresentativeMetric {+        MRR+    }++    public static final String DELIM = ":";++    private RepresentativeMetric representative;+    private String defaultPredicate;+    private List<Integer> categoryIndexes;++    // This is the truth value threshold that truth atoms must pass+    // for us to use their corresponding target atom in a ranking+    // metric calculation.+    private double threshold;++    // Save the map from target atoms to truth atoms+    // for truth value lookups in ranking metric calculations.+    private Map<RandomVariableAtom, ObservedAtom> labelMap;++     // Maintain a map from predicted atoms+     // to their ranks (with respect to their individual+     // entities) for use in ranking metric calculations.+    private Map<GroundAtom, Integer> rankMap;++    public RankingEvaluator() {+        this(RepresentativeMetric.valueOf(Options.EVAL_RANK_REPRESENTATIVE.getString()),+                StringUtils.splitInt(Options.EVAL_RANK_CATEGORY_INDEXES.getString(), DELIM));+    }++    public RankingEvaluator(int... rawCategoryIndexes) {+        this(Options.EVAL_RANK_REPRESENTATIVE.getString(), rawCategoryIndexes);+    }++    public RankingEvaluator(String representative, int... rawCategoryIndexes) {+        this(RepresentativeMetric.valueOf(representative.toUpperCase()), rawCategoryIndexes);+    }++    public RankingEvaluator(RepresentativeMetric representative, int... rawCategoryIndexes) {+        this.representative = representative;++        categoryIndexes = new ArrayList<Integer>(rawCategoryIndexes.length);++        for (int catIndex : rawCategoryIndexes) {+            categoryIndexes.add(catIndex);+        }++        threshold = Options.EVAL_RANK_THRESHOLD.getDouble();+        defaultPredicate = Options.EVAL_RANK_DEFAULT_PREDICATE.getString();+    }++    /**+     * Grab the Constant arguments of an atom at specified positions.+     */+    private List<Constant> getArgsAtPositions(GroundAtom atom, List<Integer> indexes) {+        Constant[] atomArgs = atom.getArguments();+        List<Constant> argsAtPositions = new ArrayList<Constant>(indexes.size());+        for (int index : indexes) {+            argsAtPositions.add(atomArgs[index]);+        }+        return argsAtPositions;+    }++    @Override+    public void compute(TrainingMap trainingMap) {+        if (defaultPredicate == null) {+            throw new UnsupportedOperationException("RankingEvaluators must have a default predicate set (through config).");+        }++        compute(trainingMap, StandardPredicate.get(defaultPredicate));+    }++    @Override+    public void compute(TrainingMap trainingMap, StandardPredicate predicate) {+        labelMap = trainingMap.getLabelMap();+        rankMap = new HashMap<GroundAtom, Integer>();++        int predicateArity = predicate.getArity();+        List<Integer> entityIndexes = new ArrayList<Integer>(predicateArity - categoryIndexes.size());++        for (int index = 0; index < predicateArity; index++) {+            if (categoryIndexes.contains(index)) {+                continue;+            } else {+                entityIndexes.add(index);+            }

Invert this guard and don't bother with the continue in this case (so just a single if with no else).

almumill

comment created time in a day

Pull request review commentlinqs/psl

Introduce RankingEvaluator, a test, and updates to options

+/*+ * This file is part of the PSL software.+ * Copyright 2011-2015 University of Maryland+ * Copyright 2013-2021 The Regents of the University of California+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.linqs.psl.evaluation.statistics;++import org.linqs.psl.application.learning.weight.TrainingMap;+import org.linqs.psl.config.Options;+import org.linqs.psl.model.atom.GroundAtom;+import org.linqs.psl.model.atom.ObservedAtom;+import org.linqs.psl.model.atom.RandomVariableAtom;+import org.linqs.psl.model.predicate.Predicate;+import org.linqs.psl.model.predicate.StandardPredicate;+import org.linqs.psl.model.term.Constant;+import org.linqs.psl.util.StringUtils;++import java.util.ArrayList;+import java.util.Collections;+import java.util.HashMap;+import java.util.List;+import java.util.Map;++/**+ * Compute ranking-based statistics.+ */+public class RankingEvaluator extends Evaluator {+    public enum RepresentativeMetric {+        MRR+    }++    public static final String DELIM = ":";++    private RepresentativeMetric representative;+    private String defaultPredicate;+    private List<Integer> categoryIndexes;++    // This is the truth value threshold that truth atoms must pass+    // for us to use their corresponding target atom in a ranking+    // metric calculation.+    private double threshold;++    // Save the map from target atoms to truth atoms+    // for truth value lookups in ranking metric calculations.+    private Map<RandomVariableAtom, ObservedAtom> labelMap;++     // Maintain a map from predicted atoms+     // to their ranks (with respect to their individual+     // entities) for use in ranking metric calculations.+    private Map<GroundAtom, Integer> rankMap;++    public RankingEvaluator() {+        this(RepresentativeMetric.valueOf(Options.EVAL_RANK_REPRESENTATIVE.getString()),+                StringUtils.splitInt(Options.EVAL_RANK_CATEGORY_INDEXES.getString(), DELIM));+    }++    public RankingEvaluator(int... rawCategoryIndexes) {+        this(Options.EVAL_RANK_REPRESENTATIVE.getString(), rawCategoryIndexes);+    }++    public RankingEvaluator(String representative, int... rawCategoryIndexes) {+        this(RepresentativeMetric.valueOf(representative.toUpperCase()), rawCategoryIndexes);+    }++    public RankingEvaluator(RepresentativeMetric representative, int... rawCategoryIndexes) {+        this.representative = representative;++        categoryIndexes = new ArrayList<Integer>(rawCategoryIndexes.length);++        for (int catIndex : rawCategoryIndexes) {+            categoryIndexes.add(catIndex);+        }++        threshold = Options.EVAL_RANK_THRESHOLD.getDouble();+        defaultPredicate = Options.EVAL_RANK_DEFAULT_PREDICATE.getString();+    }++    /**+     * Grab the Constant arguments of an atom at specified positions.+     */+    private List<Constant> getArgsAtPositions(GroundAtom atom, List<Integer> indexes) {+        Constant[] atomArgs = atom.getArguments();+        List<Constant> argsAtPositions = new ArrayList<Constant>(indexes.size());+        for (int index : indexes) {+            argsAtPositions.add(atomArgs[index]);+        }+        return argsAtPositions;+    }++    @Override+    public void compute(TrainingMap trainingMap) {+        if (defaultPredicate == null) {+            throw new UnsupportedOperationException("RankingEvaluators must have a default predicate set (through config).");+        }++        compute(trainingMap, StandardPredicate.get(defaultPredicate));+    }++    @Override+    public void compute(TrainingMap trainingMap, StandardPredicate predicate) {+        labelMap = trainingMap.getLabelMap();+        rankMap = new HashMap<GroundAtom, Integer>();++        int predicateArity = predicate.getArity();+        List<Integer> entityIndexes = new ArrayList<Integer>(predicateArity - categoryIndexes.size());++        for (int index = 0; index < predicateArity; index++) {+            if (categoryIndexes.contains(index)) {+                continue;+            } else {+                entityIndexes.add(index);+            }+        }++        // We keep a map from entities to Lists of all GroundAtoms which contain that entity.+        Map<List<Constant>, List<GroundAtom>> sortedAtoms = new HashMap<List<Constant>, List<GroundAtom>>();++        // Partition the predicted atoms into Lists+        // according to what entity they contain.+        for (GroundAtom atom : trainingMap.getAllPredictions()) {+            if (atom.getPredicate() != predicate) {+                continue;+            }++            List<Constant> entity = getArgsAtPositions(atom, entityIndexes);++            if (!sortedAtoms.containsKey(entity)) {+                sortedAtoms.put(entity, new ArrayList<GroundAtom>());+            }++            sortedAtoms.get(entity).add(atom);+        }++        // Sort these Lists and populate the rankMap.+        for (List<Constant> entity : sortedAtoms.keySet()) {+            Collections.sort(sortedAtoms.get(entity));

The direction of the sort matters here. There will probably need to be a boolean config option describing which direction to sort (defaulting to high values first).

almumill

comment created time in a day

Pull request review commentlinqs/psl

Introduce RankingEvaluator, a test, and updates to options

+/*+ * This file is part of the PSL software.+ * Copyright 2011-2015 University of Maryland+ * Copyright 2013-2021 The Regents of the University of California+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.linqs.psl.evaluation.statistics;++import org.linqs.psl.application.learning.weight.TrainingMap;+import org.linqs.psl.config.Options;+import org.linqs.psl.model.atom.GroundAtom;+import org.linqs.psl.model.atom.ObservedAtom;+import org.linqs.psl.model.atom.RandomVariableAtom;+import org.linqs.psl.model.predicate.Predicate;+import org.linqs.psl.model.predicate.StandardPredicate;+import org.linqs.psl.model.term.Constant;+import org.linqs.psl.util.StringUtils;++import java.util.ArrayList;+import java.util.Collections;+import java.util.HashMap;+import java.util.List;+import java.util.Map;++/**+ * Compute ranking-based statistics.+ */+public class RankingEvaluator extends Evaluator {+    public enum RepresentativeMetric {+        MRR+    }++    public static final String DELIM = ":";++    private RepresentativeMetric representative;+    private String defaultPredicate;+    private List<Integer> categoryIndexes;++    // This is the truth value threshold that truth atoms must pass+    // for us to use their corresponding target atom in a ranking+    // metric calculation.+    private double threshold;++    // Save the map from target atoms to truth atoms+    // for truth value lookups in ranking metric calculations.+    private Map<RandomVariableAtom, ObservedAtom> labelMap;++     // Maintain a map from predicted atoms+     // to their ranks (with respect to their individual+     // entities) for use in ranking metric calculations.+    private Map<GroundAtom, Integer> rankMap;++    public RankingEvaluator() {+        this(RepresentativeMetric.valueOf(Options.EVAL_RANK_REPRESENTATIVE.getString()),+                StringUtils.splitInt(Options.EVAL_RANK_CATEGORY_INDEXES.getString(), DELIM));+    }++    public RankingEvaluator(int... rawCategoryIndexes) {+        this(Options.EVAL_RANK_REPRESENTATIVE.getString(), rawCategoryIndexes);+    }++    public RankingEvaluator(String representative, int... rawCategoryIndexes) {+        this(RepresentativeMetric.valueOf(representative.toUpperCase()), rawCategoryIndexes);+    }++    public RankingEvaluator(RepresentativeMetric representative, int... rawCategoryIndexes) {+        this.representative = representative;++        categoryIndexes = new ArrayList<Integer>(rawCategoryIndexes.length);++        for (int catIndex : rawCategoryIndexes) {+            categoryIndexes.add(catIndex);+        }++        threshold = Options.EVAL_RANK_THRESHOLD.getDouble();+        defaultPredicate = Options.EVAL_RANK_DEFAULT_PREDICATE.getString();+    }++    /**+     * Grab the Constant arguments of an atom at specified positions.+     */+    private List<Constant> getArgsAtPositions(GroundAtom atom, List<Integer> indexes) {+        Constant[] atomArgs = atom.getArguments();+        List<Constant> argsAtPositions = new ArrayList<Constant>(indexes.size());+        for (int index : indexes) {+            argsAtPositions.add(atomArgs[index]);+        }+        return argsAtPositions;+    }++    @Override+    public void compute(TrainingMap trainingMap) {+        if (defaultPredicate == null) {+            throw new UnsupportedOperationException("RankingEvaluators must have a default predicate set (through config).");+        }++        compute(trainingMap, StandardPredicate.get(defaultPredicate));+    }++    @Override+    public void compute(TrainingMap trainingMap, StandardPredicate predicate) {+        labelMap = trainingMap.getLabelMap();+        rankMap = new HashMap<GroundAtom, Integer>();++        int predicateArity = predicate.getArity();+        List<Integer> entityIndexes = new ArrayList<Integer>(predicateArity - categoryIndexes.size());++        for (int index = 0; index < predicateArity; index++) {+            if (categoryIndexes.contains(index)) {+                continue;+            } else {+                entityIndexes.add(index);+            }+        }++        // We keep a map from entities to Lists of all GroundAtoms which contain that entity.+        Map<List<Constant>, List<GroundAtom>> sortedAtoms = new HashMap<List<Constant>, List<GroundAtom>>();++        // Partition the predicted atoms into Lists+        // according to what entity they contain.+        for (GroundAtom atom : trainingMap.getAllPredictions()) {+            if (atom.getPredicate() != predicate) {+                continue;+            }++            List<Constant> entity = getArgsAtPositions(atom, entityIndexes);++            if (!sortedAtoms.containsKey(entity)) {+                sortedAtoms.put(entity, new ArrayList<GroundAtom>());+            }++            sortedAtoms.get(entity).add(atom);+        }++        // Sort these Lists and populate the rankMap.+        for (List<Constant> entity : sortedAtoms.keySet()) {+            Collections.sort(sortedAtoms.get(entity));+            for (GroundAtom atom : sortedAtoms.get(entity)) {+                rankMap.put(atom, sortedAtoms.get(entity).indexOf(atom) + 1);+            }+        }+    }++    /**+     * Returns the mean reciprocal rank of target atoms+     * that have a corresponding truth atom with a value above+     * the specified threshold.+     */+    public double mrr() {+        // These are the numerator and denominator of the MRR.+        // recRankSum keeps a running sum of reciprocal ranks,+        // and rankedAtomCount keeps track of how many+        // atoms are being ranked in this evaluation.+        double recRankSum = 0.0;+        int rankedAtomCount = 0;++        for (Map.Entry<GroundAtom, Integer> entry : rankMap.entrySet()) {+            // If the target atom's corresponding truth value is below+            // the threshold or it doesn't have a match truth atom, we skip it.+            if (!labelMap.containsKey(entry.getKey()) || labelMap.get(entry.getKey()).getValue() < threshold) {

I don't think the threshold makes sense in this context. What if all the values are under 0.5 (the default value)? With several items and a functional constraint, this is a very strong possibility.

I don't think it even make senses for this evalautor at all.

almumill

comment created time in a day

Pull request review commentlinqs/psl

Introduce RankingEvaluator, a test, and updates to options

+/*+ * This file is part of the PSL software.+ * Copyright 2011-2015 University of Maryland+ * Copyright 2013-2021 The Regents of the University of California+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.linqs.psl.evaluation.statistics;++import org.linqs.psl.application.learning.weight.TrainingMap;+import org.linqs.psl.config.Options;+import org.linqs.psl.model.atom.GroundAtom;+import org.linqs.psl.model.atom.ObservedAtom;+import org.linqs.psl.model.atom.RandomVariableAtom;+import org.linqs.psl.model.predicate.Predicate;+import org.linqs.psl.model.predicate.StandardPredicate;+import org.linqs.psl.model.term.Constant;+import org.linqs.psl.util.StringUtils;++import java.util.ArrayList;+import java.util.Collections;+import java.util.HashMap;+import java.util.List;+import java.util.Map;++/**+ * Compute ranking-based statistics.+ */+public class RankingEvaluator extends Evaluator {+    public enum RepresentativeMetric {+        MRR+    }++    public static final String DELIM = ":";++    private RepresentativeMetric representative;+    private String defaultPredicate;+    private List<Integer> categoryIndexes;++    // This is the truth value threshold that truth atoms must pass+    // for us to use their corresponding target atom in a ranking+    // metric calculation.+    private double threshold;++    // Save the map from target atoms to truth atoms+    // for truth value lookups in ranking metric calculations.+    private Map<RandomVariableAtom, ObservedAtom> labelMap;++     // Maintain a map from predicted atoms+     // to their ranks (with respect to their individual+     // entities) for use in ranking metric calculations.+    private Map<GroundAtom, Integer> rankMap;++    public RankingEvaluator() {+        this(RepresentativeMetric.valueOf(Options.EVAL_RANK_REPRESENTATIVE.getString()),+                StringUtils.splitInt(Options.EVAL_RANK_CATEGORY_INDEXES.getString(), DELIM));+    }++    public RankingEvaluator(int... rawCategoryIndexes) {+        this(Options.EVAL_RANK_REPRESENTATIVE.getString(), rawCategoryIndexes);+    }++    public RankingEvaluator(String representative, int... rawCategoryIndexes) {+        this(RepresentativeMetric.valueOf(representative.toUpperCase()), rawCategoryIndexes);+    }++    public RankingEvaluator(RepresentativeMetric representative, int... rawCategoryIndexes) {+        this.representative = representative;++        categoryIndexes = new ArrayList<Integer>(rawCategoryIndexes.length);+

Remove newline. We want readers to see creating and populating the list as a single action (since population is trivial).

almumill

comment created time in a day

push eventlinqs/psl

Charles Dickens

commit sha 66eba9b524f66e7b2eabcda7107e8b5967f5c9cc

RDBMSDatabase getAtomDelete statement will delete atoms from all partitions. (#303) Make atom deletion more flexible with respect to partitions.

view details

push time in a day

PR merged linqs/psl

RDBMSDatabase getAtomDelete statement will delete atoms from all partitions.

This is a part of the changes made in the larger onlinePSL project. Database getAtomDelete statement will delete atoms from all partitions.

+26 -11

1 comment

2 changed files

dickensc

pr closed time in a day

startedCamDavidsonPilon/lifelines

started time in a day

release tensorflow/recommenders

v0.5.0

released time in a day

issue commentjmschrei/pomegranate

Trouble initializing GeneralMixtureModel.from_samples() with MultivariateGaussianDistribution to embed with HMM

@lipinoelbreve is correct. When you train a GeneralMixtureModel you should be passing in a data matrix X that has two dimensions: the number of examples, and the number of features. When you train an HMM you should pass in a list, where each item in that list is a sequence in the form of a 2D matrix.

tracktorr1

comment created time in a day

issue closedjmschrei/pomegranate

Trouble initializing GeneralMixtureModel.from_samples() with MultivariateGaussianDistribution to embed with HMM

Trying to initialize multivariate gaussian in GMM from_samples and am getting "ValueError: need more than 1 value to unpack"

My input data is list of numpy array lists of MFCC sequences for speech:

GMM = GeneralMixtureModel.from_samples(MultivariateGaussianDistribution, n_components=3, X=X)
X = [numpy.array([[-64.11, 31.28, ...], [-66.83, 33.45, ...], ... [-62.03, 54.89, ...]]), numpy.array([ ... ]), ...]

I have 400 files of spoken sentences so I assume for each file to append every new numpy array list of MFCC frames sequence?

I need GeneralMixtureModel.from_samples() to use HMM emissions but that means to have GMM element initialized for each HMM state.

closed time in a day

tracktorr1

issue commentjmschrei/pomegranate

model for wind turbine prediction

I think that HMMs would work for this problem as long as you manually defined the distributions of the underlying states and then didn't do any training. The problem with training is that you begin to lose physical connections between a(t) and the other variables. For example, let's say that each turbine produces some amount of energy + noise and all you have is the total energy production. If each turbine produces ~10 units, you'd want your state corresponding to 1 turbine active to be like N(10, 1), the state for 2 turbines active to be N(20, 1)... etc. You can then use that model to decode any time series of power observations. But once you start training the model you might get weird things like 1 turbine is N(5, 3.7) and 2 turbines is N(25, 0.8), which is not physically possible.

sdementen

comment created time in a day

startedyago-naga/yago3

started time in a day

startedImmediate-Mode-UI/Nuklear

started time in a day