I implemented a module in python for oversampling skewed datasets. Would love to hear your thoughts on it!
It is an implementation of the ADASYN algorithm (link to paper: bit.ly/22KgAnP) and is designed to work along the scikit-learn API. I ran into the need of an oversampling module that focuses more on examples that are harder to classify, and I said, what the heck... I will implement it on my own. Feel free to use it in your projects and if you find any bugs just open an issue
https://github.com/stavskal/ADASYN
Don't forget to star if you find it useful ;)
/r/pystats
https://redd.it/44r9ye
It is an implementation of the ADASYN algorithm (link to paper: bit.ly/22KgAnP) and is designed to work along the scikit-learn API. I ran into the need of an oversampling module that focuses more on examples that are harder to classify, and I said, what the heck... I will implement it on my own. Feel free to use it in your projects and if you find any bugs just open an issue
https://github.com/stavskal/ADASYN
Don't forget to star if you find it useful ;)
/r/pystats
https://redd.it/44r9ye
ieeexplore.ieee.org
ADASYN: Adaptive synthetic sampling approach for imbalanced learning - IEEE Xplore Document
This paper presents a novel adaptive synthetic (ADASYN) sampling approach for learning from imbalanced data sets. The essential idea of ADASYN is to use a
[OC] Single and Multiple Regression using Python
https://cheekynomics.wordpress.com/2016/01/30/indicators-of-deprivation-2-2/
/r/pystats
https://redd.it/43djn7
https://cheekynomics.wordpress.com/2016/01/30/indicators-of-deprivation-2-2/
/r/pystats
https://redd.it/43djn7
cheekynomics
Indicators of Deprivation (2)
Indicators of Deprivation Part 2 Part 1 of this analysis can be found here. By the end of the last part, I had loaded and cleaned all of the different data and collected them together into a single…
Supervisord project: Python 2 to 3 porting help needed
Supervisor is a process supervisor used by hundreds of thousands (millions?) of production systems. It is used by people who don't even use Python as their application language.
supervisord is one of the most useful tools to run production systems.. and is more relevant when we look at the Docker world..Where is it is usually run as "init 1".
For us (and a crazy ton of systems people who dont even use python for application code), the "supervisor" incompatibility is a blocker to move to py3.
Unfortunately, I think the maintainers are handicapped by py3 expertise - https://github.com/Supervisor/supervisor/labels/python%203
>Supervisor has some major issues on Python 3. Many of these issues are encoding related as well so merging this one patch doesn't move the needle much. We need someone who has strong experience in Python 2/3 porting and is willing to spend a non-trivial amount of time looking at these bytes/strings issues together.
https://github.com/Supervisor/supervisor/pull/471#issuecomment-267793117
/r/Python
https://redd.it/5k1875
Supervisor is a process supervisor used by hundreds of thousands (millions?) of production systems. It is used by people who don't even use Python as their application language.
supervisord is one of the most useful tools to run production systems.. and is more relevant when we look at the Docker world..Where is it is usually run as "init 1".
For us (and a crazy ton of systems people who dont even use python for application code), the "supervisor" incompatibility is a blocker to move to py3.
Unfortunately, I think the maintainers are handicapped by py3 expertise - https://github.com/Supervisor/supervisor/labels/python%203
>Supervisor has some major issues on Python 3. Many of these issues are encoding related as well so merging this one patch doesn't move the needle much. We need someone who has strong experience in Python 2/3 porting and is willing to spend a non-trivial amount of time looking at these bytes/strings issues together.
https://github.com/Supervisor/supervisor/pull/471#issuecomment-267793117
/r/Python
https://redd.it/5k1875
GitHub
Supervisor/supervisor
supervisor - Supervisor process control system for UNIX
a Py3.6 fizzBuzz oneliner with f-strings
print(*map(lambda i: f"{'Fizz' * (not i%3)}{'Buzz' * (not i%5)}" or i, range(1,101)), sep='\n')
/r/Python
https://redd.it/5k7lnb
print(*map(lambda i: f"{'Fizz' * (not i%3)}{'Buzz' * (not i%5)}" or i, range(1,101)), sep='\n')
/r/Python
https://redd.it/5k7lnb
reddit
a Py3.6 fizzBuzz oneliner with f-strings • /r/Python
print(*map(lambda i: f"{'Fizz' * (not i%3)}{'Buzz' * (not i%5)}" or i, range(1,101)), sep='\n')
What do Tim O'Reilly, Lady Gaga, and Marissa Mayer all have in common? (from: Mining the Social Web)
http://nbviewer.jupyter.org/github/ptwobrussell/mining-the-social-web-2nd-edition/blob/master/ipynb/__What%20do%20Tim%20O'Reilly,%20Lady%20Gaga,%20and%20Marissa%20Mayer%20all%20have%20in%20common.ipynb
/r/JupyterNotebooks
https://redd.it/48cnh1
http://nbviewer.jupyter.org/github/ptwobrussell/mining-the-social-web-2nd-edition/blob/master/ipynb/__What%20do%20Tim%20O'Reilly,%20Lady%20Gaga,%20and%20Marissa%20Mayer%20all%20have%20in%20common.ipynb
/r/JupyterNotebooks
https://redd.it/48cnh1
nbviewer.jupyter.org
Notebook on nbviewer
Check out this Jupyter notebook!
How to build an interactive dashboard?
Do any packages exist allowing a dashboard with greater layout flexibility than the notebook allows?
/r/IPython
https://redd.it/4ogcgg
Do any packages exist allowing a dashboard with greater layout flexibility than the notebook allows?
/r/IPython
https://redd.it/4ogcgg
reddit
How to build an interactive dashboard? • /r/IPython
Do any packages exist allowing a dashboard with greater layout flexibility than the notebook allows?
My YouTube channel on Python programming (specialized in Data Science)
https://www.youtube.com/c/Pyrevolution/sub_confirmation=1
/r/pystats
https://redd.it/430gaf
https://www.youtube.com/c/Pyrevolution/sub_confirmation=1
/r/pystats
https://redd.it/430gaf
YouTube
PyRevolution
Free Python Programming tutorials for all!!! Come and Join the Python Revolution to learn about GUI Development, APIs, Data Science and much much more... Aut...
Awesome O: The really big list of really interesting open source projects in Python.
https://github.com/lk-geimfari/awesomeo/blob/master/languages/PYTHON.md
/r/Python
https://redd.it/5k8ocx
https://github.com/lk-geimfari/awesomeo/blob/master/languages/PYTHON.md
/r/Python
https://redd.it/5k8ocx
GitHub
lk-geimfari/awesomeo
awesomeo - The really big list of really interesting open source projects in all languages.
pandas-profiling: Create beautiful HTML profiling reports from pandas DataFrame objects
https://github.com/JosPolfliet/pandas-profiling
/r/pystats
https://redd.it/42upfp
https://github.com/JosPolfliet/pandas-profiling
/r/pystats
https://redd.it/42upfp
GitHub
JosPolfliet/pandas-profiling
pandas-profiling - Create HTML profiling reports from pandas DataFrame objects
[AF] redirection issues
What I'm trying to do is redirect back to the home page (index.html) after a user has submitted their email. Once they submit their email address on a form located on index.html, they are sent to a thank you page (thanks.html). I'm having problems redirecting them back to index.html
I've already tried the official documentation and looked for help online.
I couldn't get return redirect or url_for to work. And all my html files are located in the template directory so that's no the problem.
here is a link to the code. http://pastebin.com/sMAKUu3d
Thanks for the help!
/r/flask
https://redd.it/5k8mlw
What I'm trying to do is redirect back to the home page (index.html) after a user has submitted their email. Once they submit their email address on a form located on index.html, they are sent to a thank you page (thanks.html). I'm having problems redirecting them back to index.html
I've already tried the official documentation and looked for help online.
I couldn't get return redirect or url_for to work. And all my html files are located in the template directory so that's no the problem.
here is a link to the code. http://pastebin.com/sMAKUu3d
Thanks for the help!
/r/flask
https://redd.it/5k8mlw
Pastebin
[Python] from flask import Flask, render_template, request, redirect, url_for app = Flas - Pastebin.com
Plotting multiple data series side by side in Bokeh
I'm trying to something that seems like it should be really simple, but I haven't been able to figure it out. I have a pandas dataframe with two columns of data, targets and actuals achieved. I want to plot these two side by side in a Bokeh bar chart. However, I can't seem to figure out how to pass multiple data series to the Bar function. I'd rather not have to re-shape my entire dataframe to work with the Bokeh group function, which seems to require that the data to be plotted is all in one series. Thanks.
/r/IPython
https://redd.it/4oc9fy
I'm trying to something that seems like it should be really simple, but I haven't been able to figure it out. I have a pandas dataframe with two columns of data, targets and actuals achieved. I want to plot these two side by side in a Bokeh bar chart. However, I can't seem to figure out how to pass multiple data series to the Bar function. I'd rather not have to re-shape my entire dataframe to work with the Bokeh group function, which seems to require that the data to be plotted is all in one series. Thanks.
/r/IPython
https://redd.it/4oc9fy
reddit
Plotting multiple data series side by side in Bokeh • /r/IPython
I'm trying to something that seems like it should be really simple, but I haven't been able to figure it out. I have a pandas dataframe with two...
Tutorial: How to build a blog from iPython/Jupyter notebooks
https://www.dataquest.io/blog/how-to-setup-a-data-science-blog/
/r/IPython
https://redd.it/4o7lde
https://www.dataquest.io/blog/how-to-setup-a-data-science-blog/
/r/IPython
https://redd.it/4o7lde
Dataquest
Building a Data Science Blog for Your Portfolio – Dataquest
Data science blogs provide an ideal forum to show off your work in job applications and to the public. Learn to build one with Pelican, Jupyter Notebook, and Github pages.
Introducing geodjango-tigerleaflet, a django app for displaying US States and Counties on Leaflet maps and navigating through them.
I've written a quick django package to help me split out some functionality related to US Census data (with code borrowed from geodjango-tigerline) and serve it for use on leaflet. It's a pretty niche thing, but offering it on github/pypi in case anybody else can make use of it. Of course, if you want to offer pull requests, make github issues or code review then I certainly won't turn it down.
[geodjango-tigerleaflet github](https://github.com/jlillest/geodjango-tigerleaflet)
[geodjango-tigerleaflet example project github](https://github.com/jlillest/geodjango-tigerleaflet-example)
I'm still learning the package creation process, as well as pypi documentation, so any pointers there are also appreciated. I found the process of creating the example app, package and submitting to pypi very easy using the cookiecutter utility. Many thanks to pydanny!
The overall utility of the package is to offer the state and county shapefiles/geojson files for use in the lightweight GIS toolset of leaflet. The templates provided are mostly to show how to get it up and running, though I'd love to make it more generic and use template tags for some of this. The real utility is the geojson views for providing data directly.
The app requires postgresql with the postgis extension, but if you're doing GIS-type work and need the shapefiles stored in your database then you already understand why this is required. Geodjango is such a great toolset for GIS.
Enjoy!
/r/django
https://redd.it/5k8nke
I've written a quick django package to help me split out some functionality related to US Census data (with code borrowed from geodjango-tigerline) and serve it for use on leaflet. It's a pretty niche thing, but offering it on github/pypi in case anybody else can make use of it. Of course, if you want to offer pull requests, make github issues or code review then I certainly won't turn it down.
[geodjango-tigerleaflet github](https://github.com/jlillest/geodjango-tigerleaflet)
[geodjango-tigerleaflet example project github](https://github.com/jlillest/geodjango-tigerleaflet-example)
I'm still learning the package creation process, as well as pypi documentation, so any pointers there are also appreciated. I found the process of creating the example app, package and submitting to pypi very easy using the cookiecutter utility. Many thanks to pydanny!
The overall utility of the package is to offer the state and county shapefiles/geojson files for use in the lightweight GIS toolset of leaflet. The templates provided are mostly to show how to get it up and running, though I'd love to make it more generic and use template tags for some of this. The real utility is the geojson views for providing data directly.
The app requires postgresql with the postgis extension, but if you're doing GIS-type work and need the shapefiles stored in your database then you already understand why this is required. Geodjango is such a great toolset for GIS.
Enjoy!
/r/django
https://redd.it/5k8nke
GitHub
jlillest/geodjango-tigerleaflet
Contribute to geodjango-tigerleaflet development by creating an account on GitHub.
Plotting a transformed random variable
Let's say I've got a random variable X ~ uniform(-1,1) (is a random number between -1 and 1), and Y=X^2.
Using scipy.stats.uniform I can easily plot X's pdf by doing:
x=numpy.linspace(-4,4,100)
plot(x,uniform.pdf(x))
But I'm not sure how to plot Y's pdf/cdf.
Is there some sort of module that will do what I need?
/r/pystats
https://redd.it/42n7ge
Let's say I've got a random variable X ~ uniform(-1,1) (is a random number between -1 and 1), and Y=X^2.
Using scipy.stats.uniform I can easily plot X's pdf by doing:
x=numpy.linspace(-4,4,100)
plot(x,uniform.pdf(x))
But I'm not sure how to plot Y's pdf/cdf.
Is there some sort of module that will do what I need?
/r/pystats
https://redd.it/42n7ge
reddit
Plotting a transformed random variable • /r/pystats
Let's say I've got a random variable X ~ uniform(-1,1) (is a random number between -1 and 1), and Y=X^2. Using scipy.stats.uniform I can easily...
Saving form with foreign key: 'NOT NULL constraint failed'
Hello fellow Django learners,
I am currently working an a 'IMDB' clone for me and my friends to use. The idea is that each of us gets an account and can either submit new movies or vote on already submitted ones. These movies are sorted by rating and users can access the detail view to see the individual reviews.
To achieve this I'm using foreign keys in my models.py - one for the movie entries (with information like director, title, etc) and one for the individual votes. The latter one uses foreign keys to fetch the movies title and the user that submitted the review.
However when testing the form that submits reviews I encountered the 'NOT NULL constraint failed: list_vote.voter_id_id' error. When browsing through the error page I discovered that the foreignkey values are not submitted to the database
params: [None, None, 9.0]
query: ('INSERT INTO "list_vote" ("movie_id_id", "voter_id_id", "rating") VALUES (?, ' '?, ?)')
self <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7f77b8907dc8>
Yet, when I browse the error page for the local vars at the moment of the 'post.save()' command the missing variables seem to be there
entry: <Entry: Starwars 4>
form: <VoteForm bound=True, valid=True, fields=(rating)>
movie_id: 'Starwars 4'
post: <Vote: Vote object>
request: <WSGIRequest: POST '/vote/starwars-4/'>
slug: 'starwars-4'
voter_id : <SimpleLazyObject: <User: admin>>
If I add the ' movie_id' and ' user_id' values to my modelform (in the 'fields' variable) the form actually works. (though this is not what I want, as there could potentially be hundreds of movies in this database, making selection rather difficult. And right now, any user can pretend to be anyone)
I'm probably missing something very obvious, but for the life of me I cannot figure out what I'm doing wrong. The models, forms etc are based on both the Django_girls tutorial (where they work) and the 'Hello WebApp' book (though foreign keys are not used in this book)
Does anyone know what I'm doing wrong here?
I've included the relevant code below, many thanks in advance!
**These are the models used:**
class Entry(models.Model):
movie = models.CharField(max_length=255)
director = models.CharField(max_length=255)
total_votes = models.IntegerField(default=0)
rating = models.FloatField(default=0)
length = models.IntegerField(default=0)
year = models.IntegerField(default=0)
added_by = models.ForeignKey(User)
slug = models.SlugField(unique=True)
def __str__(self):
return self.movie
########################
Vote-model:
########################
class Vote(models.Model):
class Meta:
unique_together = (('voter_id','movie_id'),)
movie_id = models.ForeignKey(Entry)
voter_id = models.ForeignKey(User)
rating = models.FloatField(validators=[MinValueValidator(0), MaxValueValidator(10)])
**This is my form.py:**
class VoteForm(ModelForm):
class Meta:
model = Vote
fields = ('rating',)
**This is the relevant function form the view.py:**
def lets_vote(request, slug):
entry = Entry.objects.get(slug=slug)
if request.method == "POST":
form = VoteForm(request.POST)
if form.is_valid():
voter_id = request.user
movie_id = Entry.objects.get(slug=slug).movie
post = form.save(commit=False)
post.save()
return redirect('/movies/')
else:
form = VoteForm()
return render(request, 'list/lets_vote.html', {'entry':entry, 'form': form})
**Last but not least: the voteform from the html page:**
<form role="form" action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
{% endblock %}
/r/djangolearning
https://redd.it/5k87bx
Hello fellow Django learners,
I am currently working an a 'IMDB' clone for me and my friends to use. The idea is that each of us gets an account and can either submit new movies or vote on already submitted ones. These movies are sorted by rating and users can access the detail view to see the individual reviews.
To achieve this I'm using foreign keys in my models.py - one for the movie entries (with information like director, title, etc) and one for the individual votes. The latter one uses foreign keys to fetch the movies title and the user that submitted the review.
However when testing the form that submits reviews I encountered the 'NOT NULL constraint failed: list_vote.voter_id_id' error. When browsing through the error page I discovered that the foreignkey values are not submitted to the database
params: [None, None, 9.0]
query: ('INSERT INTO "list_vote" ("movie_id_id", "voter_id_id", "rating") VALUES (?, ' '?, ?)')
self <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7f77b8907dc8>
Yet, when I browse the error page for the local vars at the moment of the 'post.save()' command the missing variables seem to be there
entry: <Entry: Starwars 4>
form: <VoteForm bound=True, valid=True, fields=(rating)>
movie_id: 'Starwars 4'
post: <Vote: Vote object>
request: <WSGIRequest: POST '/vote/starwars-4/'>
slug: 'starwars-4'
voter_id : <SimpleLazyObject: <User: admin>>
If I add the ' movie_id' and ' user_id' values to my modelform (in the 'fields' variable) the form actually works. (though this is not what I want, as there could potentially be hundreds of movies in this database, making selection rather difficult. And right now, any user can pretend to be anyone)
I'm probably missing something very obvious, but for the life of me I cannot figure out what I'm doing wrong. The models, forms etc are based on both the Django_girls tutorial (where they work) and the 'Hello WebApp' book (though foreign keys are not used in this book)
Does anyone know what I'm doing wrong here?
I've included the relevant code below, many thanks in advance!
**These are the models used:**
class Entry(models.Model):
movie = models.CharField(max_length=255)
director = models.CharField(max_length=255)
total_votes = models.IntegerField(default=0)
rating = models.FloatField(default=0)
length = models.IntegerField(default=0)
year = models.IntegerField(default=0)
added_by = models.ForeignKey(User)
slug = models.SlugField(unique=True)
def __str__(self):
return self.movie
########################
Vote-model:
########################
class Vote(models.Model):
class Meta:
unique_together = (('voter_id','movie_id'),)
movie_id = models.ForeignKey(Entry)
voter_id = models.ForeignKey(User)
rating = models.FloatField(validators=[MinValueValidator(0), MaxValueValidator(10)])
**This is my form.py:**
class VoteForm(ModelForm):
class Meta:
model = Vote
fields = ('rating',)
**This is the relevant function form the view.py:**
def lets_vote(request, slug):
entry = Entry.objects.get(slug=slug)
if request.method == "POST":
form = VoteForm(request.POST)
if form.is_valid():
voter_id = request.user
movie_id = Entry.objects.get(slug=slug).movie
post = form.save(commit=False)
post.save()
return redirect('/movies/')
else:
form = VoteForm()
return render(request, 'list/lets_vote.html', {'entry':entry, 'form': form})
**Last but not least: the voteform from the html page:**
<form role="form" action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
{% endblock %}
/r/djangolearning
https://redd.it/5k87bx
reddit
Saving form with foreign key: 'NOT NULL... • /r/djangolearning
Hello fellow Django learners, I am currently working an a 'IMDB' clone for me and my friends to use. The idea is that each of us gets an account...
Data Viz: A tutorial on Bokeh in notebooks
https://github.com/chdoig/bokeh-tutorial-ipynb/tree/master/.ipynb_checkpoints
/r/JupyterNotebooks
https://redd.it/47w6xl
https://github.com/chdoig/bokeh-tutorial-ipynb/tree/master/.ipynb_checkpoints
/r/JupyterNotebooks
https://redd.it/47w6xl
GitHub
chdoig/bokeh-tutorial-ipynb
bokeh-tutorial-ipynb - Bokeh tutorial in IPython Notebooks
Lung cancer incidence decreases with elevation: evidence for oxygen as a carcinogen (R)
http://nbviewer.jupyter.org/github/dhimmel/elevcan/blob/master/manual/tutorial/tutorial.ipynb
/r/JupyterNotebooks
https://redd.it/47w62p
http://nbviewer.jupyter.org/github/dhimmel/elevcan/blob/master/manual/tutorial/tutorial.ipynb
/r/JupyterNotebooks
https://redd.it/47w62p
nbviewer.jupyter.org
Notebook on nbviewer
Check out this Jupyter notebook!
AJAX & Django
Hi, I'm creating a Django app (I'm really new still) as a player control panel for a game. When another player creates a character, I'd like it to update live from MySQL and the character name appear in a list.
Here's a demonstration made with JavaScript:
https://gyazo.com/332cdcbc19c498d599c9f65071d88fcf
Apart from the amount of characters are limited to 5 (already have that covered), it is ordered from creation date (have that covered). I just need it to live update.
Thanks!
/r/django
https://redd.it/5k9cp7
Hi, I'm creating a Django app (I'm really new still) as a player control panel for a game. When another player creates a character, I'd like it to update live from MySQL and the character name appear in a list.
Here's a demonstration made with JavaScript:
https://gyazo.com/332cdcbc19c498d599c9f65071d88fcf
Apart from the amount of characters are limited to 5 (already have that covered), it is ordered from creation date (have that covered). I just need it to live update.
Thanks!
/r/django
https://redd.it/5k9cp7
Gyazo
GIF