please tell me how to use the input.time function to force the ta.sma to be calculated from the specified time, ignoring the previous one. If possible, an example code. Thanks
Related
I am using a H2ORandomForestEsimator. What is the default target metric that H2O models use for their predict() method?
https://docs.h2o.ai/h2o/latest-stable/h2o-py/docs/modeling.html#h2o.automl.H2OAutoML.predict
Is there a way to set this? (Eg. to use one of the other metric maximizing thresholds that can be seen when looking at the results of get_params() method)
Currently am doing something like...
df_preds = mymodel.predict(df)
activation_threshold = mymodel.find_threshold_by_max_metric('f1', valid=True)
# adjust the predicted label for the desired metric's maximizing threshold
df_preds['predict'] = df_preds['my_positive_class'].apply(lambda probability: 'my_positive_class' if probability >= activation_threshold else 'my_negative_class')
see
https://docs.h2o.ai/h2o/latest-stable/h2o-py/docs/model_categories.html?highlight=find_threshold#h2o.model.binomial.H2OBinomialModel.find_threshold_by_max_metric
https://docs.h2o.ai/h2o/latest-stable/h2o-py/docs/frame.html?highlight=apply#h2o.H2OFrame.apply
There's no concept of a "target metric" when generating predictions, since you're just predicting the response for a row of data (there's no scoring here).
Edit: Thanks for clarifying your question. If you want to change how the threshold is generated, then what you're doing above is a good solution. If you have a suggestion for a utility function that would make this more straight-forward, please file a JIRA with your idea (it could definitely be improved).
Setup:
I have a Google sheet where I would like to run a custom function implemented using a script. This script is used to perform a relatively lengthy URL lookup and decode process (10 ms per call, dependent on bandwidth and ping). The custom function uses one column as input, and returns the result.
Problem:
When my Google sheet is opened, the column that uses this calculation is refreshed. This grinds the Google sheet to a halt for about 10 seconds, until each cell in the column is recalculated. This will only become worse as I add to my spreadsheet.
Question:
Can I change my function script, or change a setting in Google sheets so that the slow custom function is only calculated when the input cell is changed?
For anyone curious, here is a demo sheet with my problem
On my answer to In google sheets can I wrap a standard function in a custom function to control when it is run? I shared the idea of having a couple of buttons called "freeze" / "unfreeze" to control when the recalculation of "expensive formulas" is done.
On this case, you could "freeze" the range with your custom function before closing the spreadsheet so the next time that you open it will open faster, then when you need to update the frozen range you "unfreeze" it.
After posting the original version the OP asked for a simple version but as my original implementation was something quick and dirty with stuff in Spanish I shared there just the most important code lines. The core methods services are
A global variable to store the formula if it will always be the same
copyTo to overwrite the formula results range with the values a la copy-paste-values-only
clear to delete the formula results pasted previously
setFormula to add the formula back to the spreadsheet.
Then I realized that I could improved that published an unlisted Google Sheets add-on that use the PropertiesService to implement a "formula store" with functions to add/remove/list the formulas and a dynamic menu instead of buttons.
Something else to try is to use a time-driven trigger that runs, let say nightly just in case that you forgot to freeze the range for the custom function results.
Slightly better performance if there are less custom functions. You can rewrite your function to take in an array, so you'd only have one function instead of 100 running at once.
function mySlowFunction(x) {
//Utilities.sleep(x*100); //100 ms
if (x.map) {
return x.map(function(y) {return mySlowFunction(y) });
} else {
return x * 100;
}
}
Struggling to find rank values from highest to lowest, please see attached example of what I'm trying to achieve.
My current custom expression is:
Sum([ViolationAmt])
I have tried this:
Sum([ViolationAmt]) over Rank([ViolationAmt])
I've played around with the rank expressions however unable to implement...would be very grateful for some help.
Spotfire Rank Example
I need to make a lot of assumptions here because I don't know anything about your data set or really what your end goal is, so please comment back and/or provide more info in your question if I am off base.
the first assumption is that each row in your dataset represents one, for simplicity, [AccountID] with a [ViolationAmt]. I'm also guessing you want to show the top N accounts with the highest violations in a table, since that's what you've shown here.
so it sounds like you are going to need two calculated columns: one for getting the total [ViolationAmt] per account, and then another to rank them.
for the first, create a column called [TotalViolationAmt] or somesuch and use:
Sum([ViolationAmt]) OVER ([AccountID])
for the second:
Rank([TotalViolationAmt])
it will be useful to read the documentation on ranking functions if you haven't already.
you could probably combine these two into a single column with something like:
Rank(Sum([ViolationAmt]) OVER ([AccountID]))
but I haven't tested this at all. again, if you put in a bit more detail about what you're trying to accomplish it will help you get a better, more detailed answer :)
I have been looking for few hours now and can't figure out a solution.
I need a way to round up a price to it's upper decimal, in my template (smarty, I can't edit any php file)
I tried with the round function, but can't figure out how to give the mode parameter "PHP_ROUND_HALF_UP".
Here is what I got so far, that makes a standard round
{(($x+7.5+($x-15)*0.3)/15)|round:"1"}
But it returns 3.2 for x=35 instead of 3.3
Tell me if you need any additional infos.
A bit of sleep and here comes a solution !
Instead of looking for a function, I found that nifty use of ceil :
{(((($x+7.5+($x-15)*0.3)/15)/0.1)|ceil)*0.1}
Simple math, thanks php.net comments !
Quick rundown, basically, the idea of the prolog program (GNU Prolog) is to search a database containing people with available time slots to a set of times (beginning time, end time) and return the first person who can meet in that time. The input has the syntax
meeting(Person,slot(time(10,0),time(12,30)))
I have a predicate which matches the above as such:
meeting(Person, slot(time(A,B),time(C,D))) :- %insert code
and the database entries look as such:
free(george,slot(time(9,30),time(11,0)))
Where I am stuck is that I'm not sure how I can compare the times in the database with the times entered when calling my meeting predicate. Not looking for a free answer, just wanting a push in the right direction and a good example :) Thanks everyone!
Doing what mbratch said, I saw better how prolog runs through the database and I was able to easily write come comparing logic which would satisfy the requirements.
The idea is, calling free(...) as above, Person receives the first individual in the list and all the passed variables receive the data. Then I could use my logic on the data and if all the logic passes, the method runs through and the proper response is returned.
Thanks for your help!