Computational Model for learning Computability and Complexity

I was reading the book by Kozen-Theory of Computation. There is a statement that Turing machine is the best model for defining basic time and space complexity because atleast for higher levels of complexity the definitions are robust and reflect fairly accurately our expectations of real life computation. I did not clearly understand the statement. Why is definition said to be robust?

user research – Is it a good idea for me (a freshman in college) to focus on front end web dev and UI/UX at the same time, essentially learning to be a hybrid?

I studied Human-Computer-Interaction, which was basically what you describe as hybrid. Though it was more in-depth and a very well mixed assortment of classes, like data structures in coding and SQL, but at the same time stuff like psychology, ergonomy, prototypes and user research.

I’m not sure how much more into the UX field you can or will go, besides this one specific topic that you mentioned. I’m also not sure if “just” doing this one specific UX research topic is already basis enough to completely go in that direction. You have to be the judge of that, I can only make assumtions.

But regarding the actual question if it is viable:
I will say it is literally comparable to multi-classing in RPG games. You learn 50/50 of both and, thus, can contribute to both sides equally when it’s necessary. But at the same time, you aren’t as qualified in either of the halves as someone who focuses only & specifically on that.

And oftentimes people are looking for someone to solve a specific problem or fill a specific role in their company, and they’d rather have two experts than to have one person who only knows half of each. On the contrary, a smaller company or a start-up is often more interested in that type of hybrid. Have the necessary fundamentals of both sides and only pay one salary? Great! Because they may not need the very deep expertise and are happy with the basics.
So it’s also a question about the size of the company; one that is huge and established won’t be interested in doing experiments with someone in both fields, whereas those with a very lenient and free structure very well might be.

My suggestion: This is based solely on my personal experience, maybe someone else can share others views on this, but I would suggest to not go strictly 50/50 on UX and coding. Instead, go for a major role with a complementing minor role. Like 70% UX and 30% frontend.
Because, as I said, oftentimes they want someone for a specific problem, and it’s easier to take someone who’s majorly focused on the topic they need AND has some extra knowledge of a related topic (“wow, valuable!”) than to have someone where they aren’t sure if you have enough expertise in this ONE topic they need to even hire you.

I, for example, have went with a 80% UX – 20% code representation of myself for my professional career, but do about 50/50 in personal projects on the side. So I still get to use both parts equally.

Personal note: I also have to add that when you’re planning on doing your own thing and going freelancer or starting your own project, it’s super valuable to have both skills, because you oftentimes only need the basics and can cover nearly everything by yourself. I am very glad to have both skills.

What is softmax in reinforcement learning?

There are multiple very complicated articles about softmax online. I just want to know a few things about it:

  1. Why do we need softmax? What is the “problem”? What does it do?
  2. How does it do it?

I find it very hard to get through all the math when I don’t really get what it is all about. The problem is that all the things I read online is very complicated written and no one seems to just get to the point.

I hope you can help.

machine learning – cross_val_score is returning nan list of scores in scikit learn

I am trying to handle imbalanced multi label dataset using cross validation but scikit learn cross_val_score is returning nan list of values on running classifier.
Here is the code:

import pandas as pd
import numpy as np
data = pd.DataFrame.from_dict(dict, orient = 'index') # save the given data below in dict variable to run this line

from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.preprocessing import MultiLabelBinarizer
from sklearn.multiclass import OneVsRestClassifier

multilabel = MultiLabelBinarizer()
y = multilabel.fit_transform(data('Tags')) 
from nltk.corpus import stopwords 
stop_words = set(stopwords.words('english')) 
tfidf = TfidfVectorizer(stop_words = stop_words,max_features= 40000, ngram_range = (1,3))
X = tfidf.fit_transform(data('cleaned_title'))

from skmultilearn.model_selection import IterativeStratification
k_fold = IterativeStratification(n_splits=10, order=1)

from sklearn.linear_model import LogisticRegression
from sklearn.metrics import jaccard_score
class_weight = {0:1,1:10}
lr = LogisticRegression(class_weight = class_weight, n_jobs = -1)
scores = cross_val_score(lr, X, y, cv=k_fold, scoring = 'f1_micro')

Here is the data (first 10 rows) using data.head(10).to_dict()

{0: {'Tags': ('python', 'list', 'loops', 'for-loop', 'indexing'),
  'cleaned_title': 'for loop we use any local variable   what if we use any number present in a list  ',
  'cleaned_text_of_ques': 'in the for   loop we use any local variable   what if we use any number in a list   what will be the output   a   ( 1 2 3 4 5 6 ) b   ( ) for a( 1 ) in a   b append a( 1 )   print b  '},
 1: {'Tags': ('python', 'loops', 'tkinter', 'algorithm-animation'),
  'cleaned_title': 'contain a mainloop ( duplicate )',
  'cleaned_text_of_ques': 'my code be a bubble sort that i be try to visualise   but i be struggle to find a way to make a block of code only be use once   i also think that if i could only mainloop a section that would'},
 2: {'Tags': ('android',
  'cleaned_title': 'when onrestoreinstancestate be not call  ',
  'cleaned_text_of_ques': 'docs describe when onrestoreinstancestate be call   this method be call after onstart     when the activity be be re   initialize from a previously save state   give here in savedinstancestate  '},
 3: {'Tags': ('python', 'r', 'bash', 'conda', 'spyder'),
  'cleaned_title': 'point conda r to already   instal version of r',
  'cleaned_text_of_ques': 'my problem have to do with the fact that rstudio and conda be point to different version of r  my r and rstudio be instal independent of anaconda   and everything be work great   in my    '},
 4: {'Tags': ('android',
  'cleaned_title': 'how to use a recycleview with several different layout   accord to the datum collect in firebase   ( close )',
  'cleaned_text_of_ques': 'i have a problem   there be day that i do research and test code   but nothing work   my application will have a window where i will post datum take in firebase   use a recycleview   with the'},
 5: {'Tags': ('html', 'css', 'layout'),
  'cleaned_title': 'how to create side by side layout of an image and label  ',
  'cleaned_text_of_ques': 'i have be try for a while now and can not seem to achive the bellow design    exploreitem   background   color     353258       rgba 31   31   31   1       border   1px solid   4152f1   color  '},
 6: {'Tags': ('php', 'jquery', 'file'),
  'cleaned_title': 'php jquery ajax   _ files( file   ) undefined index error',
  'cleaned_text_of_ques': 'i have a form that upload image file and it be not work   i have try submit and click event   the error appear when i have remove the if statement   thank in advance for your help  '},
 7: {'Tags': ('python', 'pandas', 'dataframe'),
  'cleaned_title': 'how to update value in pandas dataframe in a for loop  ',
  'cleaned_text_of_ques': 'i be try to make a data frame that can store variable coeff value after each iteration   i be able to plot the graph after each iteration   but when i try to insert the value in the data frame'},
 8: {'Tags': ('xpath', 'web-scraping', 'scrapy'),
  'cleaned_title': 'scrapy   how can i handle a random number of element  ',
  'cleaned_text_of_ques': 'i have a scrapy crawler that i can comfortably acquire the first desire paragraph   but sometimes there be a second or third paragraph   response xpath f string   h2(contains text           card   ) '},
 9: {'Tags': ('bootstrap-4', 'tabs', 'collapse'),
  'cleaned_title': 'collapse three column with bootstrap',
  'cleaned_text_of_ques': 'i be try to make three tab with cross   reference with one tab visible at the time   i be use the bootstrap v4 collapse scheme with functionality support by jquery   here be the example   https  '}}

This is how I get the cross_val_score in scores variable
array((nan, nan, nan, nan, nan, nan, nan, nan, nan, nan)). It should have each value in range 0-1. However, this is happening with every algorithm model.

machine learning – How does Pointnet’s Shared MLP work?

When reading about Pointnet’s Shared MLP, I kept hearing it described as 1×1 convolution, where each point is process separately. During the Shared MLP, I understand that each point’s are expanded into more features. For example, a point cloud might go from 1024×3 to 1024×64 to 1024×256 to 1024×1024, then with the maxpool, all the features are brought back to 1024×1. I understand that the maxpool is used to make the model invariant to point order, but I can’t understand how pointnet shares information between different points. Could someone help clarify however pointnet learns shapes and pattern over the entire point cloud, and how information is shared in the Shared MLP?

dnd 5e – Do Order of the Scribes wizards have reduced spell learning GP costs?

The Player’s Handbook uses the following language to explain how wizards obtain spells:

Copying a Spell into the Book. When you find a wizard spell of 1st level or higher, you can add it to your spellbook if it is of a spell level you can prepare and if you can spare the time to decipher and copy it.

Copying that spell into your spellbook involves reproducing the basic form of the spell, then deciphering the unique system of notation used by the wizard who wrote it. You must practice the spell until you understand the sounds or gestures required, then transcribe it into your spellbook using your own notation.

For each level of the spell, the process takes 2 hours and costs 50 gp. The cost represents material components you expend as you experiment with the spell to master it, as well as the fine inks you need to record it. Once you have spent this time and money, you can prepare the spell just like your other spells.

The “Wizardly Quill” ability in the Unearthed Arcana that first described Order of the Scribes wizards used the following language:

• The quill doesn’t require ink. When you write with it, it produces ink in a color of your choice on the writing surface.

• The gold and time you must spend to copy a spell into your spellbook are halved if you use the quill for the transcription.

In the final release of the class through Tasha’s Cauldron of Everything, the language has changed to the following:

• The quill doesn’t require ink. When you write with it, it produces ink in a color of your choice on the writing surface.

• The time you must spend to copy a spell into your spellbook equals 2 minutes per spell level if you use the quill for the transcription.

There are, it seems, at least two interpretations of how this affects spell learning costs:

  1. Wizardly Quill does not say anything about the GP cost of learning spells, and therefore, the costs remain unchanged.
  2. Wizardly Quill reduces the cost of ink to 0 GP. Spells cost 50 GP/level when learning spells that require costly material components (e.g. Find Familiar). Spells cost 0 GP/level when learning spells whose material components are substituted by an arcane focus (e.g. Feather Fall).

My inclination, based on the Rule of Specificity, is to rule for the first option.

machine learning – Signal Convulation in python

So we got this task in Artificial Intelligence, and i have no idea what is a singal convulation is.
we have nx2 matrice (time,signal) and we are supposed to make an f(t) matice to multiply it with the signal matrice and produce a flattened signal. i searched google it it was pretty advanced stuff to what we learn atm.
how to flatten a signal in python? and what is it exactly?

any help would be appreciated.

machine learning – Java Weka setClassValue classifying numbers instead of illness

I’m working on a school project to classify, bases on antibody data, what type of illness someone has. I’m using the Weka API to load in a .model file I created while running Weka and then I try to run it on a file the user will input. The problem is that, instead of classifying the illness someone has, it is classifying a number.

import weka.classifiers.AbstractClassifier;
import weka.classifiers.bayes.NaiveBayes;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.converters.ConverterUtils.DataSource;
import weka.core.pmml.jaxbbindings.NaiveBayesModel;


public class Wrapper {
    private final String wekaFile = "testdata/naivebayes_model.model";

    public static void main(String() args) {
        Wrapper runWeka = new Wrapper();
        String unknownFile = "data.csv";

    private void start(String unknownFile) {
        String datafile = "locatie.arff";

        try {
            // Modifying data by using an Rscript
            Instances instances = loadData();
            AbstractClassifier classifier = loadClassifier();
            classifyNewInstance(classifier, instances);

        } catch (Exception e) {

    private void modifyData(String unknownFile) throws IOException, InterruptedException {
        ProcessBuilder pb = new ProcessBuilder("Rscript", "./src/main/resources/R_script.R",
        Process p = pb.start();

        BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String readline;
        int i = 0;
        while ((readline = reader.readLine()) != null) {
            System.out.println(++i + " " + readline);


    private void printInstances(Instances instances) {
        int numAttributes = instances.numAttributes();

        for (int i =0; i < numAttributes; i++) {
            System.out.println("Attribute: " + i + " = " + instances.attribute(i));

    private void classifyNewInstance(AbstractClassifier classifier, Instances instances) throws Exception {
        // creating copy
        Instances labeled = new Instances(instances);
        // label instances
        for (int i = 0; i < instances.numInstances(); i++) {
            double clsLabel = classifier.classifyInstance(instances.instance(i));
        System.out.println("nNew, labeled = n" + labeled);

    private AbstractClassifier loadClassifier() throws Exception {
        return (AbstractClassifier);

    private Instances loadData() throws IOException {
        try {
            DataSource source = new DataSource("./src/main/resources/data.arff");
            Instances data = source.getDataSet();
            if (data.classIndex() == -1)
                data.setClassIndex(data.numAttributes() - 1);
            return data;
        } catch (Exception e) {
            throw new IOException("Something went wrong while reading file. Please check if the" +
                    "file is the right format.");

And the output:


So, the last column in the csv results should be a illness, but it’s 0.00062.

Why is this not working properly?

python – Suggestions on how to compress my for and while loops, reinforcement learning agent

I coded a deep q learning network to act as my agent in a custom reinforcement learn env. However, I feel as if my code screams rookie programmer. I am looking for general advice on how to improve the structure of it (feel free to leave little pinpointers) but specifically, is there any way to compress my long for statements?

full code:

import numpy as np
import gym
import matplotlib
import matplotlib.pyplot as plt
import tensorflow as tf
from env.BeamEnv import BeamEnv

class DeepQLearning:
    def __init__(self, learning_rate):
        # Build the network to predict the correct action

        input_dimension = 4
        hidden_dimension = 36

        self.input = tf.placeholder(dtype=tf.float32, shape=(None, input_dimension))

        hidden_layer = tf.contrib.layers.fully_connected(

        logits = tf.contrib.layers.fully_connected(

        # Sample an action according to network's output
        # use tf.multinomial and sample one action from network's output
        self.action = tf.reshape(tf.multinomial(logits, 1), ())

        # Optimization according to policy gradient algorithm
        self.action_probs = tf.nn.softmax(logits)
        log_action_probabilities = tf.log(self.action_probs)

        self.n_actions = tf.placeholder(tf.int32)

        self.rewards = tf.placeholder(tf.float32)

        ind = tf.range(0, tf.shape(log_action_probabilities)(0)) * tf.shape(log_action_probabilities)(1) + self.n_actions

        probs = tf.gather(tf.reshape(log_action_probabilities, (-1)), ind)

        loss = -tf.reduce_sum(tf.multiply(probs, self.rewards))

        self.optimizer = tf.train.RMSPropOptimizer(learning_rate)  # use one of tensorflow optimizers

        self.train_op = self.optimizer.minimize(loss)

        self.saver = tf.train.Saver()
        config = tf.ConfigProto(
            device_count={'GPU': 0}
        ) = tf.Session(config=config)

    def train(self, observation, n_actions, rewards):, feed_dict={self.input: observation,
                                               self.n_actions: n_actions,
                                               self.rewards: rewards})

    def save(self):, "SavedModel/")

    def load(self):
        self.saver.restore(, "SavedModel/")

    def get_action(self, observation):
        return, feed_dict={self.input: (observation)})

    def get_prob(self, observation):
        return, feed_dict={self.input: observation})

epochs = 500
max_steps_per_game = 2000
games_per_epoch = 10
learning_rate = 0.1
early_stop = 0

agent = DeepQLearning(learning_rate)
game = BeamEnv()

def convert_rewards(rewards):
    return (1) * len(rewards)

dr = .99

def discount(R, discount_rate=dr):
    discounted_r = np.zeros_like(R, dtype=np.float32)
    running_add = 0
    for t in reversed(range(len(R))):
        running_add = running_add * discount_rate + R(t)
        discounted_r(t) = running_add

    return discounted_r

max_state = np.array((-100, -100, -100, -100))
min_state = np.array((100, 100, 100, 100))
rewards = ()
total_rewards = ()
for epoch in range(epochs):
    epoch_rewards = ()
    epoch_actions = ()
    epoch_observations = ()
    epoch_average_reward = 0
    for episode in range(games_per_epoch):
        obs = game.reset()
        step = 0
        episode_rewards = ()
        episode_actions = ()
        episode_observations = ()
        game_over = False
        while not game_over and step < max_steps_per_game:
            step += 1
            action = agent.get_action(obs)
            max_state = np.maximum(max_state, np.array(obs))
            min_state = np.minimum(min_state, np.array(obs))

            obs, reward, game_over = game.step(obs, action)

        print('Episode steps: {}'.format(len(episode_observations)))

        epoch_average_reward += sum(episode_rewards)

    epoch_average_reward /= games_per_epoch

    print("Epoch = {}, , Average reward = {}".format(epoch, epoch_average_reward))

    if epoch_average_reward >= max_steps_per_game:
        cnt += 1
        cnt = 0
    if cnt > early_stop:

    normalized_rewards = (epoch_rewards - np.mean(total_rewards))
    agent.train(epoch_observations, epoch_actions, normalized_rewards)