Git Product home page Git Product logo

main's People

Contributors

aronwc avatar thetechie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

main's Issues

problem with reading twitter.cfg in Windows 7

Dear Aron,

I have read the issue related to this in GitHub but my issue seems quite different from that one.

If I hard code my twitter credentials(keys) in twitter_request method. My entire code is working fine.

But if use twitter.cfg file I am facing issue in my get_friends() method like below:

C:\Users\dell\Anaconda\lib\site-packages\TwitterAPI\TwitterAPI.pyc in iter(self)
177 :raises: TwitterConnectionError, TwitterRequestError
178 """
--> 179 return self.get_iterator()
180
181 def get_rest_quota(self):

C:\Users\dell\Anaconda\lib\site-packages\TwitterAPI\TwitterAPI.pyc in get_iterator(self)
164 """
165 if self.response.status_code != 200:
--> 166 raise TwitterRequestError(self.response.status_code)
167
168 if self.stream:

TwitterRequestError: Twitter request failed (401)

When I reviewed this error, it looks like Unauthorized access or Time zone issue.

But if it is Unauthorized access, then it should not work if I hard code my values. My time zone is correct. I have cross verified it.

Please let me know what can be done to resolve this.

About lec 16,18,20?

Hi Professor,

Can you upload the lecture 16,18,20.

I can't find it from github. But I think they are very useful for learning social network and prepareing the final.

Thank you

Getting more than 20 friends per request

A student writes:

For every request, you get 20 friends for a given candidate. Since we have fifteen candidates and we're trying to get 200 friends, we're going to have to make 10 requests for each candidate. This amounts to 150 requests, Twitter I thought is going to time us out at 30 requests within a 15 minute window, how are we supposed to get 200 friends?

See the count parameter of the API request.

result return by twitter api is not in a proper format

Hi,
The twitter api call for friends/list returns result as a class
this class contains attribute text which contains the raw data in unicode format
when i simply print it shows a dict
but not able to access the elements in it
it says " TypeError: string indices must be integers "
so when i look at the type it says unicode
so how to convert to dict or is there any other way to access it

Notebook Version Control

Is there a good way to see git diffs between commits when using an ipython notebook? It picks up a lot of metadata changes. And there is a lot of json that contains the code. A quick google search revealed a couple tools, but I'm wondering if you have any suggestions? Or if you would be opposed to us writing code in a separate file and placing the proper calls in the notebook?

unable to get updated repository

I am trying to get the latest version of my private repository, i.e. a2 files. I used the command:

git pull

and I get Already up-to-date.. However, when I check the a2 folder the only file there is README.md and the other files are not there. I am on the master branch. Also, I tried git fetch with no luck.

If I check the repository online I am able to see all files and folders e.g. a2.ipynb. I tried pulling the repository using a different machine but I get the same results.

Any suggestions?

LogisticRegression: ValueError: setting an array element with a sequence

I am using logisticRegression model for my project , my code is as folows,i don't know why every time after do it there is an error: "ValueError: setting an array element with a sequence."

I don't know why?

from sklearn.linear_model import LogisticRegression

trainX= [['39', 'State-gov', '77516', 'Bachelors', '13', 'Never-married', 'Adm-clerical', 'Not-in-family', 'White', 'Male', '2174', '0', '40', 'United-States'], ['50', 'Self-emp-not-inc', '83311', 'Bachelors', '13', 'Married-civ-spouse', 'Exec-managerial', 'Husband', 'White', 'Male', '0', '0', '13', 'United-States']]

model = LogisticRegression()

trainY=['<=50K', '<=50K']

model.fit(dataX,dataY)

Collecting data!

Do we have options for choosing APIs other than social networks?
For example airlines APIs (tourists interests), museum APIs, etc...

Looking to join project team

Does any group of two still need another member to join their project team? I would like to join one! Thanks!

Are small changes allowed in the given code?

separate candidates by party.

republicans = [c[0] for c in candidates if c[1] == 'R']
democrats = [c[0] for c in candidates if c[1] == 'D']
print('%d republicans, %d democrats' % (len(republicans), len(democrats)))

This doesnt work for me.
c[0] loops through each elem of the string and not each candidate. For example, [c[0] for c in candidates if c[1] == 'R'] processes the elements as follows:
H
I
L
A
R
Y
C
L
I
N
T
O
N

....

I get the correct output for this code after modifying it as follows:
republicans = [c.split(' ')[0] for c in candidates if c.split(' ')[1] == 'R']
democrats = [c.split(' ')[0] for c in candidates if c.split(' ')[1] == 'D']
print('%d republicans, %d democrats' % (len(republicans), len(democrats)))

similarly for the code:
candidate2friends = get_all_friends(c[0] for c in candidates) I had to change it to--

candidate2friends = get_all_friends(c.split(' ')[0] for c in candidates)

Is this fine?

Twitter status code 400

connection has been established. last night i was getting my status code 200 and all queries were working completely fine. Now it is 200. What is the reason for that?

how to use Networks(python) draw method?

import ConfigParser
import sys
import time
import matplotlib.pyplot as plt
import networkx as nx
import json
from networkx.algorithms import bipartite

def create_graph(dots):

 G= nx.Graph()

 G.add_nodes_from(dots)

 return G

dots=["ab","cd","ef"]
graph = create_graph(dots)
nx.draw(graph,with_labels=True)
plt.savefig("p1.png")

graph.clear()
graph = nx.DiGraph()
print graph.nodes()

nx.draw(graph,with_labels=True)
plt.savefig("p2.png")

In my code I try to draw two pictures:p1.png and p2.png. After I draw p1.png , I clear graph. However, p2.png has the same node with p1.png.

I don't know what's wrong with my code . Because I have clear graph, so there should be nothing in p2.png

I google it ,but no answer. What is the problem?

score_republicans

would someone want to compare their output to this call? I would like to compare and see if I am getting the same thing. Its a bit different from the professor's output and I know this is expected because data changes. For this reason, I would like to compare with someone else who has a recent result for the output of this function.

the args. 'property_fn' in plot_property_histogram()

As the instruction says, "A function that takes a graph as input and returns a list of values to be plotted."
I want to use a if-elif structure for the plot_property_histogram() ,because there are three different functions.

for example
pseudocode:
if property_fn == degree:
use plot_degree_dist()
elif property_fn == clustering_coef:
use plot_clustering_dist()
elif property_fn == distance:
use plot_shortest_paths_dist(G, title)

However, it shows an error
qq20140914-1

So I'm wondering if I make a mistake about the if-elif method?
And how to use variable to represents a function ?

alert different output

Hi,
The output graph given for our reference has changed.

McConnellPress node has no connection before but now there is a edge between
McConnellPress and kaybaileyhutch .

I searched though twitter and the relation do exists between those two nodes.

Any one getting result as me or am i doing something wrong?

Extension for project submission

Hi Professor,

Please could you provide us extension of a day or two to submit the code for our project? We shall do the presentation on December 3 as allotted to us.

Thank you.

TwitterConnectionError

Hi, all, I got this error when I was trying to get all the friends for all candidates:
TwitterConnectionError: HTTPSConnectionPool(host='api.twitter.com', port=443): Read timed out.

it's totally fine when I got friends for one candidate.

Can't plt!

I guess I am doing something wrong but not sure what it is,
I reviewed lecture 04 and when running the code nothing happened (no plot),

Any thoughts?

how to change cell number?

I have a problem when I run ipynb.

The index of the cell alwasy change. How can I edit the number of the index?

I don't know I can change it?
qq 20140919142620

About lec08

qq 20141007111026
In lec 8, In denomiatorde, why P(b1|B) = 1/2 *(2/3), rather than p(b1|B)=2/3?

I don't understand?

path_of_length

For assignment 2, there is a question confused me that in the "path_of_length(graph, source, target, length)โ€ function, we just need to find one path that satisfy this condition or all the paths? Thanks!

Just one path is fine.

-Aron

A1: PNG or PDF?

Did you mean to tell us to name the codecademy screen shot in assignment 1 python.pdf? I tried to save my codecademy screenshot as a PDF, but after I did I couldn't open it because OSX thought it was corrupt. Is it OK to submit a PNG instead? In my experience screenshots aren't usually saved as PDF, but if there's a reason to do it that way, I'd like to know.

What should we return for "distance"?

def distance(graph):
""" Return a list containing the average shortest path to all other nodes for each node in the graph. """
None

For example we have senators A,B,C
The shortest distance between A, B and A C is
{A,[{B:2},{C:3}]}
The shortest distance between B, A and B C is
{B,[{A:4},{C:3}]}
The shortest distance between C, A and C B is
{C,[{A:5},{B:6}]}

So the list should be:
{ {A,[{B:2},{C:3}]},{B,[{A:4},{C:3}]},{C,[{A:5},{B:6}]}}

am I right?

Assignment 1

Sorry, I am a little confused, are we doing our coding inside the python notebook?

Problem with plotting nodes in the graph.

The real-time plotting (using networkx) doesn't seem to be working.

Here's my code:

def create_graph(senators):
for i in senators:
graph.add_node(i)
return graph

graph = nx.DiGraph()
graph = create_graph(senators)
nx.draw(graph, with_labels = True)
plt.savefig("senators.png")

The output graph that I get is as follows:

index

However if I replace 'senators' in the for loop with 'len(senators)', then I obtain the proper graph, only not with the desired labels (the senator names):

index2

Any help on why I'm not getting the expected graph in the first instance? Thanks.

what exactly the function used for def get_betweenness_centrality(graph)?

I looked the NetworkX documentation, there is a function used for computing betweenness centrality for nodes in a bipartite network.


betweenness_centrality(G, nodes)

Parameters :
G : graph
A bipartite graph

nodes : list or container
Container with all nodes in one bipartite node set.

Returns :
betweenness : dictionary
Dictionary keyed by node with bipartite betweenness centrality as the value.


I have tried to used it, but it shows a Name Error as follow:

qq20140906-2 2x

Do I need to import extra library to let it work? Or I just choose an inappropriate function?

Should I implement some methods by my self?

There are some codes in homework 2:

def degree(graph):
    """ Return a list containing the degree for each node in the graph. """
    return None

def clustering_coef(graph):
    """ Return a list containing the clustering coefficient for each node in the graph. """
    return None

def distance(graph):
    """ Return a list containing the average shortest path to all other nodes for each node in the graph. """
    return None

We can get some of them results by using networkx.some_function(). Can I use these functions or I should follow the definitions and implement them by myself?

path_of_length

I am using to implement this, a function called nx.all_simple_paths(), however it seems that this function return an infinite number of paths !!
How to avoid that?

Error on running given function bipartisan_count()

Any one facing this issue with this function? (I made no changes to the code in this function)

TypeError: unhashable type: 'dict'
----> 5 print('%20s %d' % (r, len(set(democrats) & set(candidate2friends[r]))))

image

Networkx graph issue

Graph does not open beneath the code. It opens on a new window only if I write plt.show(). Is this fine?

Is the network supposed to change each time the module is run?

I am getting a slightly different network each time I run the network module. Is it supposed to be like that?

Also in my network the edges aren't seen clearly! like the one in ideal output(rather cannot be seen atall)
PS: the previous output of graph module is- "graph has 129 nodes and 274 edges" is satisfied. But the network still does not show edges.

Did anyone face same problem?

Expected shape/orientation of drawn graph?

This is a similar questions to #47, regarding the network changing every time you run the code.

I have drawn a graph that seems very close to the example in the sample code. But if I run the code again by creating a new graph and drawing it, the orientation of the nodes and edges changes slightly. I am using a digraph, so the resolution from #47 does not apply to my question.

1st example:
g1

2nd example:
g2

3rd example:
g3

All of these graphs have the same number of nodes and edges, but as you can see they look different. Is this behavior expected? Or is there a better way to create the graph that will result in it being drawn consistently each time?

the numerical order regular_graph(n,k)....

I used the function which professor showed in the lecture
nx.random_regular_graph(k,n)
k : degree
n: number of node
but I haven't found a way to control the numerical order of the neighbors of nodes.
Does anyone know how to control? Or give me some tips?

Number of friends fetched for few candidates in asg1

Hi,

While trying to fetch friends for candidates mentioned in asg1 there are some candidates whose number of friends are not matching with the assignment results. For e.g. "HillaryClinton" has 142 friends as mentioned in asg1, however, on twitter it shows that she has 159 friends (screensot attached) also the twitter API returns 159 results.

The reason for this may be, that, additional friends were added to her list after the results for asg1 were posted.

In such cases, should we filter the results returned from twitter API until the date asg1 was given so should we go ahead and get all the current results till date?

image

Could not authenticate

I've tried to get friend list. I can connect the API. But I found there is an error: {"errors":[{"message":"Could not authenticate you","code":32}]}. At first, I thought is the problem of my consumer_key. I have checked it and even regenerated it. It still had this problem. I even tried the "follower" example from the l02. And it also had error. Does anyone else can help me fix it? Thanks!

Number of parameters to score_republicans

A student writes:

You have listed four arguments in the documentation to score_republicans(), but I only see three passed in. That should change to four, correct?

In fact there should only be three parameters. The code is correct, but the documentation is not.
I've updated a1.ipynb to fix this (see commit 6381616 )

twitter.cfg location

I am trying to experiment with the a1.ipynb file in the ipython notebook, but I am having trouble connecting to Twitter. I keep getting a "NoSectionError" when I try to run the get_twitter method, which I assume means it cannot find the twitter.cfg file. (I already edited my twitter.cfg file with the relevant information). Where do I need to put twitter.cfg so it can be found by the notebook (or what else might I be doing wrong)?

Here is a screenshot with the error:
image

Thanks for any suggestions!

Ryan

Twitter Request Failed Error

Hi,
I am getting a Twitter Request Error : Twitter Request Failed error when giving higher counts like 200. For smaller counts, I am getting the output. Is this because of any connectivity problem to the Twitter or some issue with the code? Is there any way I can get rid of this error?

Thank You

Filling out Twitter Application form

A student writes:

"I started working on the first homework and have had a question regarding Twitter application. It looks like that I should have to create an application to go to next step, Generating Tokens.

There are several blanks, Name, Description, and Website, that I have to fill out, but I have no idea what is typed in to 'Website' blank. It will be great if you give me an advice for the 'Description' as well."

How should the network be displayed?

A student writes:

I have finished the TODO list till graph creation. Do we have to modify the graph to make it resemble like the one displayed in the main repository?
In the main repository, more candidates are near the outer end of the graph. In my case, white nodes are outside of candidates.

The exact layout may be slightly different, but all the nodes and edges should be the same. That is, you don't need to modify the draw_network method.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.