Predict prices with tensorflow

This is a sample of my dataset: dolar selic barril diesel ipca data 2012-01-02 1.7376 0.039270 193.79 2.040 0.47 2012-01-03 1.7152 0.039270 210.87 2.042 0.26 2012-01-04 1.7152 0.039270 210.87 2.042 0.26 2012-01-05 1.7152 0.039270 210.87 2.042 0.26 2012-01-06 2.0350 0.031976 185.79 2.045 0.07 I need to predict the diesel variable for the next 30, 60 and 90 days. My dataset has values from 2012-01-02 to 2022-03-16. dolar selic barril diesel ipca count 3727.000000 3727.000000 3727.000000 3727.000000 3727.000000 mean 3.500505 0.032195 …
Category: Data Science

How to limit the selection of the first level block in Gutenberg editor

I have my own custom block with an InnerBlock component which is kind of a container for the contents of each section in the document. The whole process of adding content always starts with adding this block. Therefore, I would like to limit the selection of first level blocks to only this one block. Once the user has added this block, then he can add other blocks inside. This is a question without a code example as I have no …
Category: Web

Add Image Before Posts Entry Title

This code adds the image before all titles on the page. How do i add one single image before the posts entry title? function adt_abovetitle($title){ //Return new title if called inside loop if ( in_the_loop() ) { $x = do_shortcode('[shortcode id="'. $id . '"]'); return $x . $title; } else { //Else return regular return $title; } } add_filter( 'the_title', 'adt_abovetitle');
Category: Web

How to plot the bar charts of precision, recall, and f-measure?

I have used 4 machine learning models on a task and now I am struggling to plot their bar charts just like shown below in the image. I am printing classification report to get precision, recall etc. My code is shown: def Statistics(data): # Classification Report print("Classification Report is shown below") print(classification_report(data['actual labels'],data['predicted labels'])) # Confusion matrix print("Confusion matrix is shown below") cm=confusion_matrix(data['actual labels'],data['predicted labels']) plt.figure(figsize=(10,7)) sn.heatmap(cm, annot=True,cmap='Blues', fmt='g') plt.xlabel('Predicted') plt.ylabel('Truth') Statistics(data) How can I plot this type of chart …
Category: Data Science

Looking to exclude blog posts from category Previous/Next buttons

I'm working on some conditional elements here and I thought I had it but it's still not working right. You can see my site here. What I've done is displayed only category Legal Libation Columns (98) on this page and excluded it form the blog itself. Perfect. But when you click on a post to view the whole article then head to either the previous or next links to read another blog post it has them all mixed up. Here …
Category: Web

the size of training data set in the context of computer vision

Generally speaking, for training a machine learning model, the size of training data set should be bigger than the number of predictors. For a neural network, or even a deep learning model, the number of parameters are usually tens of thousands or even millions. It seems that in practice, the number of training data set, i.e., the number of images, is usually less than the number of parameters. How to explain this? I know, we can claim that the pre-trained …
Category: Data Science

Decision Trees change result at every run, how can I trust of my results?

Given a database, I split the data in train and test. I want to use a decision-tree classifier (sklearn) for a binary classification problem. Considering I already found the best parameters for my model, if I run the model on the test set I obtain at each run (considering the same hyper-parameters) a different result. Why that? Considering I am using as metric the accuracy score, I have variations from 0.5 to 0.8. Which result should I take as correct, …
Category: Data Science

Which data mining or machine learning algorithm would be appropriate for learning ordered frequent patterns?

I have a dataset as (var1, var2, out), where the ordered pair <var1, var2> gives out. Most of the frequent pattern mining algorithms like the Apriori and FP growth algorithms does not preserve the order of var1 and var2. Which are some of the available pattern mining algorithms (may also be a NN trick), to find association rules between ordered pair <var1, var2> and output variable out? Thanks.
Category: Data Science

how do you get one specific term from a shortcode attribute?

I'm working on a function where I just want to output a button that links to a specific term. I have used get_the_terms and have gotten it to work successfully, but I've been trying get_term and I've have no luck. I want the shortcode to look like this [see_all_products category="bakery"] and output a button that links to it. This is my function so far: function product_category_button($atts) { extract(shortcode_atts(array( 'category' => '', ), $atts)); // if( $category ) : // Vars …
Category: Web

Meaningful predictive analytics for small (n=114) dataset with just 1 explanatory variable and 1 response variable?

I am given an Excel pivot table that aggregates data from a somewhat sizable data source (a database table with 1.9m records and another of about 490k). The data within the Excel file consists of 3 columns: dates of Mondays which represent their respective weeks, quantity of items, and number of shipments (that it takes for the quantity of items). I am supposed to concoct a model that predicts the number of shipments that would be required for a given …
Category: Data Science

Using Ajax to submit a form, and run a SQL Select query based on user input from the form

I'm creating a web form on my WordPress powered website. The form is intended to allow the user to enter a ZIP Code (aka postal code). When the user submits the form, the page should query a MySQL table, SELECT the rows which match the search criteria and dispense those values into a table on the same page. Unfortunately, I have been unsuccessful thus far. Per the example I followed, three components are necessary to query a SQL table from …
Category: Web

The next_posts_link() works only with original $wp_query

I've got custom template that I want to display paged blog posts. This is the beginning of my file: $wp_query = new WP_Query($args); if($wp_query->have_posts()){ while($wp_query->have_posts()){ $wp_query->the_post(); //something... <?php next_posts_link('Older Entries'); ?> <?php previous_posts_link('Newer Entries'); ?> It works fine - it displays OLDER and NEWER links when it should. On the first page it will display only a link to older entires. On the second page both to newer entries and yet older ones etc. But I don't want to overwrite …
Category: Web

How to solve this ValueError: Dimensions must be equal

I'm trying to train an autoencoder model with colored image samples but I got this error ValueError: Dimensions must be equal, but are 476 and 480 for '{{node mean_squared_error/SquaredDifference}} = SquaredDifference[T=DT_FLOAT](model_4/conv2d_28/BiasAdd, IteratorGetNext:1)' with input shapes: [?,476,476,1], [?,480,480,3]. although i have checked the dimensions of the test and training sets all are (480,480,3) from matplotlib import image,pyplot import cv2 IMG_HEIGHT=480 IMG_WIDTH=480 def prepro_resize(input_img): oimg= cv2.imread( input_img, cv2.COLOR_BGR2RGB) return cv2.resize(oimg, (IMG_HEIGHT, IMG_WIDTH),interpolation = cv2.INTER_AREA) x_train_ = [(prepro_resize(x_train[i])).astype('float32')/255.0 for i in range(len(x_train))] x_test_ …
Category: Data Science

Multiple languages menus problem

I'm trying to add language option to my website. I've coded my theme and I need to show the web in three different languages. I've got the little flags and I've managed to pass a php variable with the language it's selected. With that variable I've made a if for the wp_nav_menu assignment in the header.php. It works actually. When I change the language the correct menu in the correct language comes up. The problem is that when I hit …
Category: Web

How to get tf tensor value computed in loss function in keras train_on_batch without computing it twice or writing custom loop?

I have a model and I've implemented a custom loss function something along the lines: def custom_loss(labels, predictions): global diff #actual code uses decorator so no globals diff = labels - predictions return tf.square(diff) model.compile(loss=custom_loss, optimizer=opt.RMSprop()) ... model.train_on_batch(input, labels) # How to get diff after I've run train_on_batch without causing it to rerun predict a second time behind the scenes(unnecessary slowdown) and mess up with trainable/batchnorm etc(possible problems)? I want to avoid making a manual raw tensorflow train_op loop etc, …
Category: Data Science

LSTM - How to prepare train from a dataset which contains multiple observations for different events

I m using LSTM in a project related to MobiFall dataset which contains falls and daily activitives - such as walking, sitting etc - sensed by accelerometer, gyroscope and orientation sensors in x,y,z axes. So I need to modify LSTM into multi-variate form. How could it be done? And after this problem is solved, I have to deal with another, there are multiple time-series events in different files which were done by different people. For example, I have got ADL_1_walking_1_.txt, …
Category: Data Science

Link to Portfolio page by id instead of name

I'm trying to make a dynamic button that goes to portfolio page (no matter what ID/name it has), it's currently like this: $portfolio_page = get_option('theme_portfolio_page'); $portfolio_pid = get_page_by_title($portfolio_page); <a href="<?php echo get_option ('theme_portfolio_page') ?>">Voltar</a> The problem is that it links based on the page name, and when it has space on the name it bugs... So I would need a code that links dynamically to the portfolio page by ID When I try to change to get_page_by_id FATAL ERROR: CALL …
Category: Web

Generate Wordpress salt

I am in need of a function that automatically generates and returns salts for Wordpress wp-config.php (Don't link me to their API, I'm looking for offline solution). Does Wordpress core has this function defined somewhere? If it doesn't, can these salts be generated randomly or are there any specific rules for creating them? Edit: This is what I ended up with: $keys = array('AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT'); $salts = ''; foreach ($keys as $key) { $salt …
Category: Web

Wordpress Multisite with cPanel Addon Domains and SSL

I've been trawling google and looking through various articles but seem to have ended up in a massive mess now! I have had domain myprivatesite.com. The domain is registered with a different company to the hosting. It's been running (non-multisite) Wordpress for a while, with the Wordpress install in a sub-dir. I have an SSL cert on the domain (provided by the web host) and then enabled cloudflare for CDN via the hosts cPanel plugin. This has been running great! …
Category: Web

How to weigh imbalanced softlabels?

The target is a probability between N classes, I don't want it to predict the class with the highest probability but the 'actual' probability per class. For example: | | Class 1 | Class 2 | Class 3 | ------------------------------------ | 1 | 0.9 | 0.05 | 0.05 | | 2 | 0.2 | 0.8 | 0 | | 3 | 0.3 | 0.3 | 0.4 | | 4 | 0.7 | 0 | 0.3 | ------------------------------------ | + | …
Category: Data Science

How can I statistically measure/determine if A performs better than B?

Hi Data Science Community! I am a new Data Intern and I have been stuck on this question for a while. Here is a sample dataset I am working with: Customer Manufacturer A Spending Manufacturer B Spending Manufacturer A Cost per Product (CPP) Manufacturer B Cost per Product (CPP) Product Cost Difference (B-A) Product Cost Difference in % 1 400000 360000 44 45 1 1/45 2 300000 310000 23 21 -2 -2/21 3 100000 106000 1.4 1.6 0.2 0.2/1.6 I …
Category: Data Science

Hourly scheduled wp_cron job keeps getting rescheduled

Every time I refresh the page, my cron job update_backup_now_feed seems to have its timer reset. I'm using a plugin called "crontrol" that displays the time until next call, and every time I refresh it resets to 1 hour. The only time the schedule seems to fire off is when I avoid the site for over an hour and then refresh. Am I doing something wrong with my code below or is this a bug? I'm working on Multisite. I …
Category: Web

Are there any methods of supervised learning that return a bitmap instead of a set of parameters?

For example, the SVM or ANN methods perform search of a surface which would separate the data points in a best way. This surface is returned in the vector or parametric form. Are there methods returning a spatial bitmap each voxel of which contains a numeric value defining a class for all points lying within a given voxel? I would like to share some of the results of my attempts in this direction. Since I'm relatively new in machine learning …
Category: Data Science

Need an example of a custom class whose instance is fed to sklearn Pipeline / make_pipeline to use with GridSearchCV

According to sklearn.pipeline.Pipeline documentation, the class whose instance is a pipeline element should implement fit() and transform(). I managed to create a custom class that has these methods and works fine with a single pipeline. Now I want to use that Pipeline object as the estimator argument for GridSearchCV. The latter requires the custom class to have set_params() method, since I want to search over the range of custom instance parameters, as opposed to using a single instance of my …
Category: Data Science

Sub Categories in drop down menu

I have lot of categories and sub categories. I want to add all these in WordPress menu. But i want to add subcategories aligned properly under their parent categories without drag and drop each and every time. Right now when i select all menus from categories these does not aligned under their parent category.Is there any automated way to do this so it will save my lot of my time? Your help will be much appreciated.
Category: Web

Choose whether to automatically add a taxonomy with the same name as the post

I created a custom taxonomy within the blog post. It's called "FootNotes." I would like there to be a checkmark inside in the creation of the post that asks me "Are there any notes inside this post?" If I choose "yes" it automatically creates within the custom taxonomy this "note" with the same name as the published article. Thank you
Category: Web

Admin toolbar not displaying on pages

The admin bar displays on the dashboard, but does not display on pages or posts. I'm working with a child theme of Twenty Thirteen that I did not code. I'm a beginning level coder and work mostly with builders. So the builder plugin I installed is also not showing up either. I've read some potential causes and checked those off. There are things I've tried that did not correct the problem: The display is set correctly in the user settings. …
Category: Web

Modeling the influence of events order on probability

The case is to model if the sequence of events influences the probability of binary target variable. We have for example five different events which occur in time (event: A,B,C,D,E). They can occur in order from 1 to 5. I would like to check if the order of their occurrence influences the target variable. My first idea was to convert the time of occurrence into numbers from 1 to 5 and then for example use logistic regression. Do You know …
Category: Data Science

Exclude post from wp_query based on custom field boolean

I am trying to give users an option to select "Exclude from homepage bloglist" on a post, and then pick this up on my homepage query so certain posts won't surface on the homepage. I'm using the Wordpress custom field "true/false". On a post where the box has been ticked, I would assume this post would then not surface on the homepage based on the below query args: $query_args = array( 'meta_query' => array( 'key' => 'exclude_from_homepage_bloglist', 'value' => false …
Category: Web

Using KNN to categorise inventory (physical stock items) - is it the best way?

I'm working on a machine learning problem involving inventory (i.e. physical retail stock), however through the cleaning (outlier removal) process some of the items (via their corresponding transactions) will be removed. Therefore, I thought of using KNN to group similar items into respective categories. There are 1245 items The info for each item is Average Weighted Price Total Quantity Sold Total Revenue Achieved Min Sold per Transaction Max Sold per Transaction Min Sell Price Max Sell Price Number of Unique …
Category: Data Science

Why is style.css not being enqueued?

I got a pretty basic theme and just found out my style.css file doesn't get loaded into the <head>. I already searched around but can't find out, why it's not loading. I inspected the global $wp_styles object already but couldn't find anything: function style_test() { $wp_styles = new WP_Styles(); echo '<pre>'; // $wp_styles->enqueue == completely empty print_r( $wp_styles->registered ); echo '</pre>'; } add_action( 'wp_print_scripts', 'style_test', 0 ); Inside the object i also can't find my registered/enqueued stylesheets (they get loaded), …
Category: Web

Setting Parent Page to Post

Does anyone know how to achieve different parent pages for posts? I've managed to code a Custom Post Type that sits under a specific parent page, but I want the option to change this from post to post. Example; /page-1/custom-post-1/ /page-1/custom-post-2/ /page-2/custom-post-3/ /page-2/custom-post-4/ The final result would be URL structure like the above, but all posts sitting on one archive page. I know by default this isn't possible as posts are non-hierarchical. Thanks
Category: Web

About

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