Deeply Nested Menu Loop with Twig using Timber

Using TimberMenu() and I have a menu for mobile that needs to go pretty deep. There must be a better way to write this with twig. Using macros and/or loop.parent or loop.index? It's basically this loop with one nested loop but I need to go all the way down to a great great grandchild. <ul class="menu primary dropdown float-right" aria-hidden="true" data-dropdown-menu data-hover-delay="0" data-closing-time="0"> {% for item in primary_menu.get_items %} <li class="{{ item.class }}"> <a href="{{ item.link }}">{{ item.title }}</a> {% …
Category: Web

Speed for different kernels in scikit-learn's SVM

I'm using scikitlearn in Python to create some models while trying different kernels. I was surprised to see that rbf was fit in under a second, whereas linear took a minute and poly took hours. Can anyone explain why to help me? My code: import numpy as np from sklearn.svm import SVR import matplotlib.pyplot as plt from sklearn.metrics import mean_squared_error, r2_score f = open(datafile) X = np.empty([0,1], dtype = int) y = np.array([]) for i in range(100): my_lines = f.readline().split(" …
Category: Data Science

Contact form 7 send product PDF after submit

We are trying to display a cf7 form on woocommerce product pages, where users can submit the form and receive a pdf file related to the product (either as an email file attachment, as a link in the email body or even as a link that opens in a new browser tab). So far we have tried adding the pdf link as a product attribute and returning it with a shortcode, but... shortcodes don't work on CF7 e-mails. Does any …
Category: Web

Best way to narrow down a list and rank based on attributes?

I have a mortgage/credit data set that contains a list of customers (600k rows) and has a 100 columns inclusive of the customer's general info (address, city, zipcode, etc), income, fico scores, number of current mortgages, mortgages in the past, aggregate mortgage amounts, number of bank card trades, etc. The data pertains to customers that are already good candidates to contact for issuing a credit product, however if one is to narrow down the list to 350K: What would be …
Category: Data Science

WP_Query and NULL meta keys

I have a bunch of custom posts with two meta keys - _claimed and _average_rating. The _average_rating is only added as a meta key if someone leaves a rating on the post and the _claimed meta key is only set to 1 if a user claims the listing - otherwise the listings have no values for _claimed or _average_rating. What I would like to do is to arrange the listings as so: - Show all listings that are claimed first …
Category: Web

BertTokenizer on custom data returns same index for all tokens

I'm trying to train Bert tokenizer on a custom dataset but when running tokenizer.tokenize on sample data, it returns the same index for every tokens which is clearly not what is expected. Running bert_vocab_from_dataset on the below sample dataset returns a vocabulary of 88 tokens long. After saving this and reusing it in tensorflow_text.BertTokenizer, I get [88] for all the tokens of the provided two test sentences. Fully reproducible example code: import tensorflow as tf import tensorflow_text from pathlib import …
Category: Data Science

Using synthetic dataset for training NVIDIA NeMo Matchbox

Does anyone has success in training small command recognition models on synthetic dataset? The full details is the following: I need a small model to run a command recognition (about 30 commands) on embedded device. It looks like NVIDIA NeMo MatchboxNet is a good solution, but I have no standard dataset covering my set of commands. The model should be adapted to a broad variation of speakers. Obtaining real dataset seems difficult. I consider using NVIDIA models like Waveglow/Flowtron to …
Category: Data Science

Random kernels in multivariate Rocket sktime

Does anyone know for when Rocket is applied in the multivariate setting how random kernels are generated? Namely is a 1-D kernel randomly generated and applied to a randomly selected feature? Or is a 2-D kernel generated randomly and this kernel is applied using all features? Neither the original paper nor the documentation of packages that implement the algorithm seem to mention anything about it.
Category: Data Science

RNN/LSTM timeseries, with fixed attributes per run

I have a multivariate time series of weather date: temperature, humidity and wind strength ($x_{c,t},y_{c,t},z_{c,t}$ respectively). I have this data for a dozen different cities ($c\in {c_1,c_2,...,c_{12}}$). I also know the values of certain fixed attributes for each city. For example, altitude ($A$), latitude $(L)$ and distance from ocean ($D$) are fixed for each city (i.e. they are time independent). Let $p_c=(A_c,L_c,D_c)$ be this fixed parameter vector for city $c$. I have built a LSTM in Keras (based on this …
Category: Data Science

Blog Title not showing up on main Blog page

I cannot get the main blog page with the current blog to show the current blog title. It shows on all other pages, just not the current/most recent blog. Any help will be greatly appreciated. Thank you. <div id="page"> <div id="contentleft"> <?php if ( $paged < 2 ) { // Do stuff specific to first page?> <?php $my_query = new WP_Query('category_name=featured&showposts=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?> <div class="featurepost" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link …
Category: Web

Transfer learning: Poor performance with last layer replaced

I am using a transfer learning approach. For this I followed the tensorflow for poets tutorial. I use a pre-trained InceptionV3 architecture trained on the Imagenet dataset. The last layer and the softmax classification is replaced and retrained, using a new set of 7 classes. Data Per class I have around 4.000 - 5.000 images. I tried multiple training parameters with an AdamOptimizer. The labels are noisy, about 15-20% of the labels are incorrect. The images show products of a …
Category: Data Science

Auto populate a user custom field from another user custom field

I have a WP theme with its own custom fields including one for Phone Number. I also installed the Digits Plugin which allows users to sign up/login with their phone number and OTP, which has its own phone number custom field. What I want to do is to use the phone number they use to sign up/login to also be the phone number used within the theme and also within Woocommerce if possible. Any help would be appreciated
Category: Web

Hard time finding literature on feature clustering using Principal Component Analysis

Im new to StackExchange, so i am sorry if this is not the right way to ask a question on StackExhange. For my thesis I wish to propose a methode for future research on using PCA to cluster features (feature clustering) and then apply per-cluster PCA. I got the idea from this paper: this paper. But I have a hard time finding literature about PCA being used to cluster variables (not reduce variables). I could imagine that it is not …
Category: Data Science

Does t-SNE have to result in clear clusters / structures?

I have a data set which, no matter how I tune t-SNE, won't end in clearly separate clusters or even patterns and structures. Ultimately, it results in arbitrary distributed data points all over the plot with some more data points of the one class there and some of another one somewhere else. Is it up to t-SNE, me and/or the data? I'm using Rtsne(df_tsne , perplexity = 25 , max_iter = 1000000 , eta = 10 , check_duplicates = FALSE)
Topic: tsne r clustering
Category: Data Science

How to change the "Woocommerce Status" text in dashboard widget

I want to change the "Woocommerce Status" text in dashboard widget. See the image: I found this code in http://stackoverflow.com but it not working. function change_add_to_cart_message( $translated, $text, $domain ) { global $pagenow; if( $text === 'WooCommerce status' && $domain === 'woocommerce' && is_admin() && $pagenow === 'index.php' ){ $translated = __( 'WooCommerce summary', $domain ); } return $translated; } add_filter( 'gettext', 'change_add_to_cart_message', 10, 3 );
Category: Web

Running an LSTM with Music Data

I'm working on a project for a class where I'm trying to create an algorithm that learns music and creates its own music. I'm having trouble on how to set up the data for it to be inputted into the LSTM. A single training example consists of a chord that is a vector of binary values based on what keys are pressed in MIDI form (indices 0-127), a value that denotes duration of the note, beat strength, numerator of the …
Category: Data Science

Very simple wordpress block to display posts from an api call

I've been banging my head on this for a bit now. I'm trying to create a simple wordpress block that fetches custom post types from the rest api, then displays the fetched posts via react. It only needs to do this, and requires no other editor functionality. However, I'm a bit of a react/wp noob and I may be fundamentally misunderstanding how wordpress react functions, as I can't seem to get anywhere. Here is my code so far: class oupSeriesBlock …
Category: Web

How to make entire <article> in blog post page linked?

I am using a theme where on the blog page only the featured image and the post title are using anchor link. On clicking it redirects to that respective post page. But I want to link the entire so that if anybody clicks on that area it will redirect to that respective post page. I saw a website &quot;https://www.tidio.com/blog/&quot; where their entire article section was linked. So when i inspect their code, I found that they are using pseudo-element ::before …
Category: Web

Redeclaring a plugin function within a class

In the code below, a user defined add_meta_box() function is hooked to add_meta_boxes action. How does wordpress know that the add_meta_box() function used inside the user-defined add_meta_box( $post_type ) function is a plugin function and not a recursive one? class someClass { /** * Hook into the appropriate actions when the class is constructed. */ public function __construct() { add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) ); add_action( 'save_post', array( $this, 'save' ) ); } /** * Adds the meta box …
Category: Web

Contact form 7 radio button default:get

I have three radio buttons and each should be selected according to which link the user click on some previous page [radio saletype use_label_element default:get &quot;Commission sale&quot; &quot;Immediate sale&quot; &quot;Car exchange&quot;] and /?saletype=2 dont work. Help please
Category: Web

Reciving Error 404 blog/page/2/

I can't seem to understand the issue here with my pagination? when visiting /blog/page/2 page goes to 404 page. Help me guys? &lt;div class=&quot;row&quot;&gt; &lt;?php // $paged = get_query_var('paged') ? get_query_var('paged') : 1; if (get_query_var('paged')) { $paged = get_query_var('paged'); } elseif (get_query_var('page')) { $paged = get_query_var('page'); } else { $paged = 1; } $querys = new WP_Query(array( 'post_type' =&gt; 'blog', 'post_status' =&gt; 'publish', 'paged' =&gt; $paged )); if ($querys-&gt;have_posts()) { while ($querys-&gt;have_posts()) { $querys-&gt;the_post(); ?&gt; &lt;div class=&quot;col-lg-6 col-md-6&quot;&gt; &lt;a href=&quot;&lt;?= …
Category: Web

why is translation not working on theme?

Background I am using the theme Rookie from Sportpress. I created a child theme. Translation files are existing, especially german in my case. Wordpress is set to german language. The Problem Translation is working fine everywhere except on themes provided templates like the search results page content or pagination. Affected are the SRP title, nothing found page title and nothing found page content. They just stay in default english language. Pagination is affected too. The search form in the content …
Category: Web

Error reproducing Eland Demo Notebook

I was trying to reproduce Python Elasticsearch client Eland notebook, available in Eland documentation. Here are the first lines of code for producing an eland dataframe from my local Elasticsearch index called sensor_index: import eland as ed import pandas as pd import numpy as np import matplotlib.pyplot as plt from elasticsearch import Elasticsearch ed_sensors = ed.read_es(localhost,'sensor_index') Unfortunately, in line 1, occurs the following Import error: ImportError: cannot import name 'ABCIndexClass' from 'pandas.core.dtypes.generic' (/home/user/miniconda3/envs/my_env/lib/python3.9/site-packages/pandas/core/dtypes/generic.py) Pandas v.1.3.1 is being used. What could …
Topic: pandas python
Category: Data Science

Why should the data be shuffled for machine learning tasks

In machine learning tasks it is common to shuffle data and normalize it. The purpose of normalization is clear (for having same range of feature values). But, after struggling a lot, I did not find any valuable reason for shuffling data. I have read this post here discussing when we need to shuffle data, but it is not obvious why we should shuffle the data. Furthermore, I have frequently seen in algorithms such as Adam or SGD where we need …
Category: Data Science

How to add site tags in alphabetical order to shortcode?

Good morning. There is a shortcode that displays site tags on a separate page. function tag_cloud_shortcode($atts) { extract(shortcode_atts(array( 'cat' =&gt; '' ), $atts)); $query_args = array( 'cat' =&gt; $atts, 'posts_per_page' =&gt; -1 ); $custom_query = new WP_Query( $query_args ); if ($custom_query-&gt;have_posts()) : while ($custom_query-&gt;have_posts()) : $custom_query-&gt;the_post(); $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { $all_tags[] = $tag-&gt;term_id; } } endwhile; endif; $tags_arr = array_unique($all_tags); $tags_str = implode(&quot;,&quot;, $tags_arr); $args = array( 'echo' =&gt; false, 'smallest' =&gt; 10, 'largest' …
Category: Web

K-Means R vs K-Means Python different cluster values generating different bar Graphs

Below are 2 sets of code that do the same thing one in Python the other in R. They both graph the Kmeans the same with respect to PCA but once I do the bar chart at the end using the cluster Center the Graphs are totally different. I believe there is something wrong about the Kmeans and the cluster calculation in python. The original code was provided in R. I am trying to see why the bar chart in …
Category: Data Science

Stateful loss function and online regression

Working in tensorflow + keras I'm trying to define a custom loss function. N.B. I'm more interested in the value of the loss rather than the actual value of the predictions (this will be used for anomaly detection). My network outputs predictions for the next n-steps ahead. At time t, I receive an input which is the current observation (y_t), I have a history of x time steps into the past. I wish to compare the value y_t, to those …
Category: Data Science

Active menu item state on all menu items

My homepage is type of onepage site and I've created menu with anchor links for it, where users can navigate through sections. When user is on subpage, for example listing of posts and clicks menu item he goes back to the specific section of the homepage. My anchors look like this: / /#about /#products etc. I'm using Bem_Menu_Walker for BEM class names. Problem is - when I'm on the homepage all my links are set to the active state. Any …
Category: Web

How to avoid saving empty data to sql while using add_meta_box

I'm trying not to save empty data (null) while using add_meta_box function. My code is /** * Register meta boxes. */ function hcf_register_meta_boxes() { add_meta_box( 'hcf-1', __( 'Hello Custom Field', 'hcf' ), 'hcf_display_callback', 'post' ); } add_action( 'add_meta_boxes', 'hcf_register_meta_boxes' ); /** * Meta box display callback. * * @param WP_Post $post Current post object. */ function hcf_display_callback( $post ) { include plugin_dir_path( __FILE__ ) . './form.php'; } /** * Save meta box content. * * @param int $post_id Post ID …
Category: Web

random_state on train_test_split() appears to have large effect in performance metrics?

To summarize the problem: I have a data set with ~1450 samples, 19 features and a binary outcome where classes are fairly balanced (0.51 to 0.49). I split the data into a train set and a test set using train_test_split(X, Y, test_size = 0.30, random_state = 42). I am using the train set to tune hyper-parameters in algorithms optimizing for specificity, using GridSearchCV, with a RepeatedStratifiedKFold (10 splits, 3 repeats) cross-validation, and scoring=make_scorer(recall_score, pos_label=0). I am then using the predictions …
Category: Data Science

Admin Panel Development

How to create Tab on Admin Panel like &quot;General Settings&quot; screenshot ? How to create List on Admin Panel like &quot;Pages&quot; screenshot ?
Category: Web

How can I automatically hyperlink tag names that are in my post body to the tag page

I have a number of sports sites with hundreds of thousands of existing news posts. The site also has a custom post type for team and a custom post type for person. I wish to be able to somehow automatically find team names and player names in news post body and hyperlink them to the correct team / player post. The post names exist with exact player and team names. For example Lionel Messi &lt;&lt; Player post Manchester United &lt;&lt; …
Topic: tags Wordpress
Category: Web

Wysiwyg editor not working on 4.2.2

I've recently upgraded a site for the Add Media button wasn't working. Now, having upgraded to 4.2.2 the Add Media works, but the Wysiwyg editor isn't showing. The only console messages I'm receiving are: Uncaught ReferenceError: edButtons is not defined (anonymous function) @ post-new.php:131 The new post screen appears with the Text tab selected, instead of Visual, and when I try to select the Visual tab I get: Uncaught TypeError: Cannot read property 'canvas' of undefined a.closeAllTags @ quicktags.min.js?ver=4.2.2:1 window.switchEditors.go …
Category: Web

Database missing extensions:tym_system_time,quantile orange widget error

I'm working with the orange data mining tool. In most of the examples data taken from files or google sheets links but in the blog link they given that we can take data from postgresql database tables also but when follow the steps of blog I'm getting error.I attached the screen shots of error. I need help in solving this error.
Topic: orange
Category: Data Science

Use WordPress page instead of post type archive

Sorry if this is a duplicate – I can't find an answer. How do I rewrite a custom post type archive page to a 'man-made' WordPress page? For example: Single page: http://www.mywebsite.com/cool-post-type/awesome-single-post/ Archive page: http://www.mywebsite.com/cool-post-type/ I want http://www.mywebsite.com/cool-post-type/ to rewrite to http://www.mywebsite.com/about-cool-post-types/. Can I just do this with htaccess and what would the syntax be? (I'm not good at htaccess!) This does not work: RewriteRule ^cool-post-type\/\?$ /about-cool-post-types [L] Or do I have to do this in the WordPress source code? …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.