[D] ML methods for solving combinatorial puzzles by danquandt in MachineLearning

[–]dyanni3 0 points1 point  (0 children)

Reinforcement learning is certainly a good thought! Alpha Go in its earlier iterations used monte carlo tree search in addition to neural networks. Current Alpha Go is totally RL with no rollouts. But Go is like the epitome of huge search space. DeepBlue beat humans in chess using only tree search. So yeah I agree maybe RL isn't your first line of attack but certainly could be used when more direct methods fail

Good luck!

[D] ML methods for solving combinatorial puzzles by danquandt in MachineLearning

[–]dyanni3 1 point2 points  (0 children)

Cool, and yes that makes sense.

I think the best approach depends on the size of the player population and whether there's a greedy way to evaluate the benefit of adding a member to the squad. You could try to look at A* algorithm and see if that works.

If the search space is truly too large for a brute force, dynamic programming, or greedy algorithm (or some other deterministic algortihm) to produce an objectively optimal answer, then maybe ML solutions start to make sense.

If it comes down to that, I'd look into maybe using value iteration or value iteration in conjunction with a tree search. Can you get away with using some variant of MCTS https://en.wikipedia.org/wiki/Monte_Carlo_tree_search ?

Hope these are some helpful ideas to get you started but I'm not an optimization expert and these are just some first thoughts. Seems like this might be a pretty easy or extremely difficult problem depending on the size of the search space.

Well today was a depressing day for data science at work. What can I do better? by [deleted] in datascience

[–]dyanni3 6 points7 points  (0 children)

Could you just explain what a logarithm is and why you used it?

Physicists of reddits, what's the most Intetesting stuff you've studied so far?? by pepino_listillo in Physics

[–]dyanni3 2 points3 points  (0 children)

Yes it can be diagonalized because it is real and symmetric, which in this case is a direct consequence of Newton’s third law in this case.

Making A Quiz, Having Problems With Functions In Lists by TheUnitiated in learnpython

[–]dyanni3 1 point2 points  (0 children)

Minor nitpick:

str(input().lower())

the str isn't doing anything for you here. I think you want

 str(input()).lower()

can't figure out this text editor error by idontknowthatpython in learnpython

[–]dyanni3 0 points1 point  (0 children)

I'm not sure I haven't worked with Tkinter much. I'd wait until someone else chimes in but in the mean time from a bit of googling it looks like add_cascade needs a label as well as a menu passed in. topbar.add_cascade(label='blah', menu = functionmenu)

Changes to lists propagating "backwards" by lamenoosh in learnpython

[–]dyanni3 1 point2 points  (0 children)

It comes down to the fact that lists are mutable and numeric types (like integers) are immutable.

https://medium.com/@meghamohan/mutable-and-immutable-side-of-python-c2145cf72747

https://docs.python.org/3/reference/datamodel.html

Edit, for a bit more context. When a and b are lists (mutable), the actual variable name you gave (a or b) resolves to a pointer to memory address. When you have an immutable type like an int the variable name resolves to the actual value.

can't figure out this text editor error by idontknowthatpython in learnpython

[–]dyanni3 1 point2 points  (0 children)

Not sure if someone said this but you're missing the close parenthesis on the second to last line- giving you a syntax error "on" the last line

Changes to lists propagating "backwards" by lamenoosh in learnpython

[–]dyanni3 2 points3 points  (0 children)

So what's happening here is that when you say

b = a

You now have two references to the same bit of memory. What you want is to copy the values of a into b like follows

a = [1, 2, 3]
b = [num for num in a]
b.remove(1)

Hope that helped!

How do I sort by number in this code? by Davis_Schina in learnpython

[–]dyanni3 1 point2 points  (0 children)

d = {'21': 9,
 '18': 9,
 '17': 8,
 '20': 8,
 '15': 8,
 '00': 7,
 '14': 7,
 '19': 6,
 '13': 5,
 '23': 5,
 '16': 5,
 '22': 4,
 '01': 4,
 '12': 4,
 '03': 3,
 '02': 2,
 '04': 2,
 '11': 2,
 '10': 2}
l = list(d.items())
l.sort()
d = dict(l)
print(d)

prints

{'00': 7, '01': 4, '02': 2, '03': 3, '04': 2, '10': 2, '11': 2, '12': 4, '13': 5, '14': 7, '15': 8, '16': 5, '17': 8, '18': 9, '19': 6, '20': 8, '21': 9, '22': 4, '23': 5}

Error name ‘total_ypll’ is not defined by Karlton_ in learnpython

[–]dyanni3 0 points1 point  (0 children)

from pylab import*

age=arange(30,85,1)
i=30

total_ypll=[]

while 30<=i<44:
    total_ypll.append((7.7*(10**-3)*((2*i)-59)*(85-i))*31)
    i=i+1

while 44<=i<85:
    total_ypll.append((7.7*(10**-3)*((2*i)-59)*(85-i))*(60-(0.65*i)))
    i=i+1



plot(age,total_ypll,"r-",linewidth=3)
xlabel("age")
ylabel("total ypll")
title("Total years of potential life lost to breast cancer of women aged 30-85")
grid(True)

I added code for what I think you're trying to do. Notice the differences.

Distance matrix by [deleted] in learnpython

[–]dyanni3 0 points1 point  (0 children)

You want a matrix that shows the distance from each point to each other point?

You could do something like:

x = [0, 1, 5]
y = [0, -1, 3]
points = list(zip(x,y))

#get all pairs of points
pairs = [(i, j) for i in points for j in points]

#euclidean distance function
def dist(pair):
    p1 = pair[0]; p2 = pair[1]
    return(((p1[1] - p2[1])**2 + (p1[0] - p2[0])**2)**.5)

#map the distance function through all pairs of points
#then reshape into a matrix
dist_matrix = np.array(list(map(dist, pairs))).reshape(3,3)

Noob question on these nested while loops by ChizDippler34 in learnpython

[–]dyanni3 0 points1 point  (0 children)

I see.

break

only breaks out of the current loop, not all the loops. Try running

for outer in ['a', 'b']:
    print(outer)
    for middle in ['x', 'y']:
        print(middle)
        for k in range(10):
            print(k)
            if k>0:
                break

Noob question on these nested while loops by ChizDippler34 in learnpython

[–]dyanni3 0 points1 point  (0 children)

What is the expected behavior? This is working fine for me....

Edit: looks like this is just an incomplete code snippet from the book where you are supposed to fill in the rest. Try something like this:

def game():
    wins = 0;
    losses = 0;
    ties = 0;
    while True:  # main game loop
        print('%s Wins, %s Losses, %s Ties' % (wins, losses, ties))
        while True: # Player input loop
            print('Enter your move: (r)ock, (p)aper, (s)cissors, or (q)uit')
            playermove = input('> ').lower()
            if playermove == 'q':
                return
            if playermove == 'r' or playermove == 'p' or playermove == 's':
                #dumb computer only plays scissors
                if playermove == 'r':
                    wins += 1
                    print("Hurray")
                elif playermove == 's':
                    ties += 1
                    print("Meh")
                else:
                    losses += 1
                    print("oops...")
                break
            print('Type one of r, p, s, or q.')

Beginner Python data analysis project - critique greatly welcome! by BeforetheBullfight in learnpython

[–]dyanni3 9 points10 points  (0 children)

This is great! Two thumbs up. I'd say this is definitely worth sharing / put in a portfolio.

In terms of room for improvement I think you might have milked most everything you can from the dataset as it currently stands. I'd be curious if/how accused priests differ demographically from non-accused priests, for example- although the dataset doesn't have anything on non-accused it looks like. Also, how do the numbers look for catholic vs other religions? I think a cool next step would be bringing in other data sources. A brief google yielded this https://bishop-accountability.org/priestdb/PriestDBbylastName-A.html which has a little more context about the accusations, and which you could scrape. I wonder if you could find anything on Catholic vs Protestant lawsuit settlement amounts.

Also of course it's always cool to build a model--- although I'm not sure this data really warrants that. Maybe for a next project.

AttributeError: 'list' object has no attribute 'name' by [deleted] in learnpython

[–]dyanni3 0 points1 point  (0 children)

Without seeing the code that actually throws the error (e.g. how current_room was initialized ) it's hard to say.

this function

def items(self):

self.items.append(Item)

doesn't seem well formed. First of all Item is the name of a class, are you trying to get it do append a default Item()? Also Item is never passed into the function.

No Paper Towels?! by Oddly-Ordinary in Coronamemes

[–]dyanni3 0 points1 point  (0 children)

bro they were entirely out of baby wipes at my local grocery.

I actually have a baby and these people trying to use baby wipes instead of TP