Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create features_plot function added to visualization.py #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/dist/
*.pypirc
/*.pypirc
/build/
/idea/
/.vscode/
/pytest_cache/
/venv/
/venv/
/build/
49 changes: 47 additions & 2 deletions datasist/visualizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from . import structdata
from datasist import structdata
from IPython.display import display
from sklearn.metrics import confusion_matrix
from sklearn.utils.multiclass import unique_labels
import sklearn.metrics as sklm
from ipywidgets import widgets



Expand Down Expand Up @@ -658,4 +659,48 @@ def autoviz(data):
from autoviz.AutoViz_Class import AutoViz_Class

av = AutoViz_Class()
av.AutoViz(filename='', dfte=data, max_cols_analyzed=50)
av.AutoViz(filename='', dfte=data, max_cols_analyzed=50)


def features_plot(data,target):
'''
Makes a scatter plot for a particular numerical feature chosen by a drawdown to show their relationship with the target.

Parameters
------------

data : DataFrame, array, or list of arrays.

The data to plot.

target: string or integer.

The target(label) column name in the dataset, if not provided,
we this function throw an error.



Returns
-------
A drawsown containing only numerical features together with the selected features scatter plot against the target
'''

if data is None:
raise ValueError("data: Expecting a DataFrame or Series, got 'None'")

if data[target].dtype != 'float64' and data[target].dtype != 'int64':
raise ValueError("target: target not a continous value")

features = [c for c in data.columns if (data[c].dtype == 'float64' or data[c].dtype == 'int64') and c != target]


def plot_feature(column):
plt.plot(data[column], data[target], '.')
plt.xlabel(column)
plt.ylabel('target')

dropdown_menu = [k for k in features]

return widgets.interact(plot_feature, column=dropdown_menu);