Need to extrapolate missing monthly data from annual data; the monthly/seasonal index is reasonably…

I have a revenue dataset for various businesses. For about half of those businesses, monthly data is available. For the other half, only annual revenue data is present. I know the seasonality of the revenues fairly well from the half of the businesses who have reported their monthly revenue. In addition, the data goes back at least five years, so I know that seasonal effects are real. What is the best way to go about extrapolating monthly revenue for businesses with missing data given the information I have on hand? Even though it is not strictly true, I am assuming that the businesses with missing data and businesses with complete data are sufficiently similar that we need not worry about any underlying issues.

Form returned from AJAX callback missing JS and CSS

I have a form set up like this:

function mymodule_form_{my_form_id}_alter(&$form, &$form_state, $form_id) {
    $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Save',
        '#ajax' => array(
            'wrapper' => 'ajax-node',
            'method' => 'replace',
            'callback' => 'mymodule_callback',
            'effect' => 'fade'
        ),
        '#submit' => array('node_form_submit'),
    );          
}

And then the callback:

function ajax_complaint_save_callback($form, &$form_state) {
    $nid = $form_state['build_info']['args'][0]->nid;
    $node = node_load($nid);

    return drupal_render(node_view($node));
}

Now this does work sort of, but the node is not rendered correctly. I have some more AJAX stuff on the same page which uses the ajax links api and that produces the node forms correctly. Here are some pictures to demonstrate.

In this picture, one of the links in the table was clicked and the stuff circled with blue was loaded using the links api – this is how it should look.

With links api

But if go to the edit tab on the loaded node (which is also loaded up through the ajax links api) then press the save button, I get this:

with form api

There’s more to this picture, but this is loaded in the same div as the other stuff was – but it seems like it is missing style information, and also the view/edit tabs are missing.

How do I make it load up the node form properly?

Sharepoint Online – missing webparts on team site

On Sharepoint Online we have two different sites.

First site is created throught Office 365 Group. So, we created Office 365 group and sharepont site is created automatically with various web parts available (Planner, Connectors,…)

Second site is “regular” team site and in that team site we are missing those webparts. Please check images.

In apps there are no those apps.
How to add all webparts from first site to team site?

Group site web parts

Group site web parts

Team site web parts

Team site web parts

The missing modules don’t get installed after updating with Composer

To update a site locally, I cloned the code base with git to my local computer and imported the database, then ran “composer update –with-dependencies”, there were no errors, then I went to /web directory and ran “drush updb -y”, it showed me 8 missing modules:

The following module is missing from the file system: add_to_head    [warning]
bootstrap.inc:276
The following module is missing from the file system: context        [warning]
bootstrap.inc:276
The following module is missing from the file system: context_ui     [warning]
bootstrap.inc:276
The following module is missing from the file system: libraries      [warning]
bootstrap.inc:276
The following module is missing from the file system: menu_target    [warning]
bootstrap.inc:276
The following module is missing from the file system: panelizer      [warning]
bootstrap.inc:276
The following module is missing from the file system: phpmailer      [warning]
bootstrap.inc:276
The following module is missing from the file system: site_verify    [warning]
bootstrap.inc:276
The following module is missing from the file system:                [warning]
special_menu_items bootstrap.inc:276
No database updates required                                         [success]

I tried to log in to the local site, but first ran “drush pm-uninstall captcha”, but the site returned the white screen and:

“The website encountered an unexpected error. Please try again later.”

I thought that the problem was due to the missing modules and started running “composer require” for each of them.
But they either didn’t get installed or returned:

 Using version ^3.0@beta for drupal/phpmailer
./composer.json has been updated
> DrupalProjectcomposerScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating drupal/phpmailer (dev-3.x 950f2af => 3.0.0-beta2):     Update failed (The .git directory is missing from web/modules/contrib/phpmailer, see https://getcomposer.org/commit-deps for more information)
    Would you like to try reinstalling the package instead [yes]? yes
  - Removing drupal/phpmailer (dev-3.x)
  - Installing drupal/phpmailer (3.0.0-beta2): Cloning 8.x-3.0-beta2 from cache
Writing lock file
Generating autoload files
> DrupalProjectcomposerScriptHandler::createRequiredFiles

I don’t what else to do. Is the “unexpected error” caused by those missing modules? What should I do to fix it?

UPDATE:
I looked at /admin/reports/dblog and here’s the php error I saw:

SymfonyComponentRoutingExceptionRouteNotFoundException: Route “”
does not exist. in DrupalCoreRoutingRouteProvider->getRouteByName()
(line 201 of
/sites/bak/web/core/lib/Drupal/Core/Routing/RouteProvider.php).

How to deal with missing data for Bernoulli Naive Bayes?

I am dealing with a dataset of categorical data that looks like this:

    content_1   content_2   content_4   content_5   content_6   
0         NaN         0.0         0.0         0.0         NaN 
1         NaN         0.0         0.0         0.0         NaN   
2         NaN         NaN         NaN         NaN         NaN   
3         0.0         NaN         0.0         NaN         0.0   

These represent user downloads from an intranet, where a user is shown the opportunity to download a particular piece of content. 1 indicates a user seeing content and downloading it, 0 indicates a user seeing content and not downloading it, and NaN means the user did not see/was not shown that piece of content.

I am trying to use the scikit-learn Bernoulli Naive Bayes model to predict the probability of a user downloading content_1, given if they have seen downloaded / not downloaded content_2-7.

I have removed all data where content_1 is equal to NaN as I’m obviously only interested in data points where a decision was actively made by the user. This gives data as:

    content_1   content_2   content_3   content_4   content_5   content_6   
0         1.0         NaN         1.0         NaN         NaN         1.0 
1         0.0         NaN         NaN         0.0         1.0         0.0    
2         1.0         0.0         NaN         NaN         NaN         1.0    

In the above framework, NaN, is a missing value. For data points where a Nan is present, I want the algorithm to ignore that category, and use only those categories present in the calculation.

I know from these questions: 1, that there are essentially 3 options when dealing with missing values:

  1. ignore the data point if any categories contain a NaN (I.e. remove the row)
  2. Impute some other placeholder value (e.g. -1 etc.) or
  3. Impute some average value corresponding to the overall dataset
    distribution.

However, these are not the best option for the following reason:

  1. Every single row contains at least 1 NaN. This means, under this
    arrangement I would discard the entire dataset. Obviously a no go.
  2. I do not want the missing value to add to the probability
    calculation, which will happen if I replace Nan with say -1. I’m also using a Bernoulli Naive Bayes, so as I understand, this requires singly 0 or 1 values.
  3. As this is categorical data, it does not make sense for me to do this,
    in this way (it was either seen or not, and if not, it is not needed).

The answer here indicated that the best way to do this, is, when calculating probabilities, to ignore that category if it is a missing value (essentially you are saying: only compute a probability based on the specific categories I have provided with non missing values).

I do not know how to encode this when using the scikit-learn Naive Bayes model, whether to do this as a missing value.

Here’s what I have so far:

df=pd.read_clipboard()
from sklearn import datasets
from sklearn.naive_bayes import BernoulliNB
# Create train input / output data
y_train = df['content_1'].values
X_train = df.drop('content_1', axis=1).values
# Loud Bernoulli Naive Bayes model
clf = BernoulliNB()
clf.fit(X_train, y_train)

Obviously, this returns an error because of the present NaNs. So how can I adjust the scikit-learn Bernoulli model to automatically ignore the columns with NaNs, and instead take only those with 0 or 1?

I am aware this may not be possible with the stock model, and reviewing the documentation seems to suggest this. As such, this may require significant coding, so I’ll say this: I am not asking for someone to go and code this (nor do I expect it); I’m looking to be pointed in the right direction, for instance if someone has faced this problem / how they approach it / relevant blog or tutorial posts (my searches have turned up nothing).

Thanks in advance – appreciate you reading.

custom service respond me : 401 Unauthorized: Missing required argument foo

I have this custom service:

function zbs_services_resources() {
  return array(
    'productQuestionForm' => array(
      'actions' => array(
        'send' => array(
          'help' => 'save a FOO entity via send form',
          'file' => array('file' => 'inc', 'module' => 'zbs'),
          'callback' => '_zbs_productQuestionForm_create',
          //'access arguments' => array('note resource create'),
          //'access arguments append' => FALSE,
          'args' => array(
              array(
                'name' => 'foo',
                'type' => 'struct',
                'description' => 'The FOO to create',
                'source' => 'data',
                'optional' => false,
              ),
            ),
        ),
      )
    )

  );
}

And this little jQuery code in a simple html test file:

$.ajax({
    url: "/rest1/productQuestionForm/send",
    headers: { 'Content-Type': 'application/json','X-CSRF-Token':'MY_WORKING_TOKEN' },
    success: function (res) {
      alert("success");
      console.log(res);
    },
    data : {
      'foo' : 'pippo',
      "type":"page",
      "title":"Page submitted via entity JSON REST",
      "body": {
          "value": "

test

n", "format": "filtered_html" } }, type: 'post', dataType: 'json', });

But when I load the simple test html page I see this in developer suite for the POST url:

401 Unauthorized: Missing required argument foo

Where am I doing wrong?

What is that is missing in the dynamic utility maximization problem that requires us to add the…

We can set the maximization problem of an agent that decides how much to save and how much to consume. I can’t see why our maximization technique fails if we don’t add the TVC. Of course, it makes sense that the TVC has to be satisfied in an optimal plan, but why is not automatically satisfied?

ps2pdf produces output with missing text (except math symbols) with T1 font encoding

I have recently discovered this problem with using Latex=>ps=>pdf: the final output does not contain any text except for mathematical symbols.

This is my preamble, with an easy example:

documentclass{article}

usepackage{amssymb}
usepackage{amsfonts}
usepackage{xcolor}
usepackage[T1]{fontenc}

begin{document}
Hello, my name is Riccardo and this is $mathstyle$.
end{document}

Using Latex=>ps=>pdf only “mathstyle” would be visible. However, Latex=>pdf and Latex=>ps would both work well separately, and produce their outputs with no issue. Only when I try to pass from the one to the other I get the problem. The log file does not contain any special error message as far as I can see.

I am compiling inside TexnicCenter (with MikTex 2.9), but the issue turns out if I use the command line as well. I have mentioned the T1 encoding only because it might be relevant, although other issues related to that seem to be solved by just downloading the cm-super package which I have downloaded already.

It is not at all clear to me what is going wrong, and I have not found any related issue on the Internet that could be useful to me with this. Any help?

Thanks in advance.

Riccardo

terms checkbox missing in checkout

In Magento 2.1.7 when arrive to the payment checkout there is a line for the terms: I accept the terms and conditions but there is no checkbox.

When I click on pay button it displays an error message that I have to accept the terms, but I can’t accept them without checkbox!

In

magento_root/vendor/magento/module-checkout-agreements/view/frontend/web/template/checkout/checkout-agreements.html 

can see the code:

but in the web there is:

So all the code that references the checkbox input is missing.

I have configured in admin panel -> stores/terms and conditions the terms with status enabled and applied automatically.

I have configured in admin panel -> stores/configuration/sales/order/payment process options the terms and conditions enabled.

As I configured the terms and conditions in both places it should display the checkbox, but there is no checkbox.

Is like the ko if: ($parent.isAgreementRequired($data)) is false always.

I cleared the cache several times: php bin/magento cache:flush

I reindexed: php bin/magento indexer:reindex

I made a setup upgrade, setup di compile and setup deploy static but still no checkbox.

Finally I tried disabling all the terms and conditions, but still can’t pay. Not sure what’s happening as the code of the checkout remains untouched yet.