<jupyter_start><jupyter_text>Feature Scaling<jupyter_code>max_, min_ = float(max(niviewslstcpy)), float(min(niviewslstcpy))
niviewslstcpyf3 = [(i - min_)/(max_ - min_) for i in niviewslstcpy]
plt.plot(t,niviewslstcpyf3,'k', label='Initially')
#plt.legend(loc='upper right')
#plt.yscale('log')
#plt.xscale('log')
plt.ylim(0.0, 1.0)
#plt.lim(0.0, 1.0)
plt.legend(loc='upper center', bbox_to_anchor=(0.5, 1.25), ncol=1, fancybox=True, shadow=True)
plt.grid(True)
max_, min_ = float(max(n2viewslstcpy)), float(min(n2viewslstcpy))
n2viewslstcpyf3 = [(i - min_)/(max_ - min_) for i in n2viewslstcpy]
max_, min_ = float(max(n3viewslstcpy)), float(min(n3viewslstcpy))
n3viewslstcpyf3 = [(i - min_)/(max_ - min_) for i in n3viewslstcpy]
max_, min_ = float(max(n4viewslstcpy)), float(min(n4viewslstcpy))
n4viewslstcpyf3 = [(i - min_)/(max_ - min_) for i in n4viewslstcpy]
#https://en.wikipedia.org/wiki/Feature_scaling
plt.plot(t,n4viewslstcpyf3,'b', label='After 1 month')
plt.plot(t,n3viewslstcpyf3,'g', label='After 1 week')
plt.plot(t,n2viewslstcpyf3,'r', label='After 2 days')
plt.plot(t,niviewslstcpyf3,'k', label='Initially')
#plt.legend(loc='upper right')
#plt.yscale('log')
plt.legend(loc='upper center', bbox_to_anchor=(0.5, 1.25), ncol=1, fancybox=True, shadow=True)
plt.grid(True)
nratingslsttemp = [(index,row['n4ratings']) for index, row in dfn4views.iterrows()]
ncommentslsttemp = [(index,row['n4comments']) for index, row in dfn4views.iterrows()]
#print(nratingslsttemp)
nratingslst = [b for a,b in nratingslsttemp]
ncommentslst = [b for a,b in ncommentslsttemp]
plt.plot(t,nratingslst,'b', label='Number of ratings')
#plt.plot(t,ncommentslst,'g', label='Number of comments')
plt.legend(loc='upper right')
plt.xlabel('Normalized video index(ranked by popularity)', fontsize=10)
#plt.ylim(0, 6000)
plt.show()
#plt.plot(t,nratingslst,'b', label='Number of ratings')
plt.plot(t,ncommentslst,'g', label='Number of comments')
plt.legend(loc='upper right')
plt.xlabel('Normalized video index(ranked by popularity)', fontsize=10)
#plt.ylim(0, 6000)
plt.show()
#import matplotlib.transforms as ax
#N = 50
#colors = np.random.rand(N)
#area = np.pi * (15 * np.random.rand(N))**2  # 0 to 15 point radiuses
#import matplotlib.pyplot as plt
#import matplotlib.patches as patches
#fig = plt.figure()
#left, width = .25, .5
#bottom, height = .25, .5
#right = left + width
#top = bottom + height

#p = patches.Rectangle(
#    (left, bottom), width, height,
#    fill=False, transform=ax.transAxes, clip_on=False
#    )
#ax.add_patch(p)
#ax = plt.add_axes([0,0,1,1])
plt.xlim(0, 1000)
plt.ylim(0, 1000)
plt.scatter(nratingslst, ncommentslst)
plt.xlabel('Number of ratings', fontsize=10)
plt.ylabel('Number of comments', fontsize=10)
plt.text(600, 800, 'PearsonCoeff = 0.7407 \nSpearmanCoeff = 0.8118')
#ax.text(0.1, 0.9,'matplotlib', ha='center', va='center',transform = ax.transAxes)
#ax.text(right, top, 'right top',        horizontalalignment='right',        verticalalignment='top',        transform=ax.transAxes)
#ax.set_axis_off()
plt.show()
from scipy.stats.stats import pearsonr
pearsonr(nratingslst, ncommentslst)
from scipy.stats.stats import spearmanr
spearmanr(nratingslst, ncommentslst)
import numpy as np
a = np.arange(1,1001)
p1 = np.random.choice(a,size=100,replace=0)
p2 = np.setdiff1d(a,p1)
#a
p1
#p2
p1_idx = np.random.randint(0,p1.size,(8000))
p2_idx = np.random.randint(0,p2.size,(2000))
p1_idx
p2_idx
max(p1_idx)
max(p2_idx)
out = np.random.permutation(np.hstack((p1[p1_idx], p2[p2_idx])))
out
len(out)
lst = list()
lst = list(out)
#lst
max(lst)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17512548800892358, 'fraction_numerical': 0.04294478527607362, 'mean_word_length': 6.50418410041841, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '619654', 'license': 'MIT', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1484, 'n_words': 289, 'path': 'Trials2.ipynb', 'repo_name': 'SubhankarGhosh/NetworkX', 'size': '3586'}