Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

to update python code for clean code#179

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
minjk-bl merged 4 commits intovisualpython:oss22_libraryfromMinku-Koo:osskoo
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
7 changes: 3 additions & 4 deletionspython/pandasCommand.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,15 +36,14 @@ def _vp_get_columns_list(df):
cInfo['value'] = "'{}'".format(c)
elif type(c).__name__ == 'Timestamp':
cInfo['value'] = str(c)

# category - iopub data rate limit issue...
cInfo['category'] = []
if str(df[c].dtype) == 'object':
uniqValues = df[c].dropna().unique()
if len(uniqValues) <= 20:
cInfo['category'] = [{ "value": "'{}'".format(u) if type(u) == str else u, "label": u } for u in uniqValues]
else:
cInfo['category'] = []
else:
cInfo['category'] = []

colList.append(cInfo)
return colList

Expand Down
16 changes: 13 additions & 3 deletionspython/userCommand.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@
import fitz
import nltk
nltk.download('punkt')

######
# Visual Python: Data Analysis > PDF
######
Expand DownExpand Up@@ -43,6 +44,7 @@ def vp_pdf_get_sentence(fname_lst):
df = _vp_pd.concat([df,df_doc])

return df.reset_index().drop('index', axis=1)

######
# Visual Python: Data Analysis > Frame
######
Expand All@@ -63,6 +65,7 @@ def vp_drop_outlier(df, col, weight=1.5):
df_res = df.drop(outlier_index).copy()

return df_res

######
# Visual Python: Machine Learning > Model Info
######
Expand All@@ -74,10 +77,12 @@ def vp_create_feature_importances(model, X_train=None, sort=False):

df_i = _vp_pd.DataFrame(model.feature_importances_, index=feature_names, columns=['Feature_importance'])
df_i['Percentage'] = 100 * (df_i['Feature_importance'] / df_i['Feature_importance'].max())
if sort: df_i.sort_values(by='Feature_importance', ascending=False, inplace=True)
if sort:
df_i.sort_values(by='Feature_importance', ascending=False, inplace=True)
df_i = df_i.round(2)

return df_i

######
# Visual Python: Machine Learning > Model Info
######
Expand All@@ -91,10 +96,13 @@ def vp_plot_feature_importances(model, X_train=None, sort=False, top_count=0):
df_i['Percentage'].sort_values().plot(kind='barh')
else:
df_i['Percentage'].plot(kind='barh')

_vp_plt.xlabel('Feature importance Percentage')
_vp_plt.ylabel('Features')

_vp_plt.show()

return

######
# Visual Python: Visualization > Seaborn
######
Expand DownExpand Up@@ -134,4 +142,6 @@ def _single(ax):
for idx, ax in _vp_np.ndenumerate(axs):
_single(ax)
else:
_single(axs)
_single(axs)

return
13 changes: 5 additions & 8 deletionspython/variableCommand.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
import numpy as _vp_np
import random as _vp_rd
"""
Search Variables
"""
Expand DownExpand Up@@ -77,8 +79,6 @@ def _vp_get_profiling_list():

return result

import numpy as _vp_np
import random as _vp_rd
def _vp_sample(data, sample_cnt):
"""
Sampling data
Expand All@@ -94,16 +94,13 @@ def _vp_sample(data, sample_cnt):
return data[_vp_np.random.choice(data.shape[0], sample_cnt, replace=False)]
elif dataType == 'list':
return _vp_rd.choices(data, k=sample_cnt)

return data

def _vp_check_module_loaded(fname_list):
"""
Check if this module is loaded
"""
result = []
for fname in fname_list:
if fname in globals():
result.append(True)
else:
result.append(False)
result = [True if fname in globals() else False for fname in fname_list]

return result
10 changes: 4 additions & 6 deletionspython/visualizationCommand.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,12 +7,10 @@ def _vp_seaborn_show_values(axs, precision=1, space=0.01):
pstr = '{:.' + str(precision) + 'f}'

def _single(ax):
# check orient
# check orient / if 0
orient = 'v'
if len(ax.patches) == 1:
# check if 0
if ax.patches[0].get_x() == 0:
orient = 'h'
if len(ax.patches) == 1 and ax.patches[0].get_x() == 0:
orient = 'h'
else:
# compare 0, 1 patches
p0 = ax.patches[0]
Expand All@@ -36,7 +34,7 @@ def _single(ax):
ax.text(_x, _y, value, ha='left')

if isinstance(axs, _vp_np.ndarray):
foridx, ax in _vp_np.ndenumerate(axs):
for_, ax in _vp_np.ndenumerate(axs):
_single(ax)
else:
_single(axs)

[8]ページ先頭

©2009-2025 Movatter.jp