The following block of code
%matplotlib inline
import sys
import pandas as pd
sys.path.append("C:\Users\%USER%\PycharmProjects\cap_rate")
import mongo
import c_lib
import t_lib
import matplotlib.pyplot as plt
matplotlib.style.use('ggplot')
Is taking upwards of ten minutes to run.
Does anyone have an idea as to what may be the root cause of this?
No major warnings/output on my end outside of severe slowness.
I rebooted and it is much faster.
Related
from sklearn.decomposition import PCA as sklearnPCA
pca = PCA(n_components=2)
pca_representation = pca.fit_transform(dataset_norm[index])
import numpy as np
from sklearn.datasets import make_s_curve
import matplotlib.pyplot as plt
from sklearn.manifold import Isomap as sklearnisomap
from mpl_toolkits.mplot3d import Axes3D
iso = Isomap(n_components=2, n_neighbors=40)
iso_representation = iso.fit_transform(dataset_norm[index])
I use google colab.
When I run the code:
iso_representation = iso.fit_transform(dataset_norm[index]),
It doesn't work, the system message says: Your session crashed after using all available RAM.
But the PCA module is working correctly, I have looked up many answers but can't solve this problem, and other codes are not working correctly, am I overlooking something?
I run visual studio code on Windows 10. Current version of my visual studio code is 1.45.1. I am running a Python (version 3.7.4 64-bit) on it. My visual studio code takes 5 to 10 minutes to load following libraries:
import pandas as pd
import numpy as np
from datetime import datetime, date
from scipy.stats import ttest_ind
from scipy.stats import ttest_ind_from_stats
from scipy.stats import ttest_1samp
import seaborn as sns
import matplotlib.pyplot as plt
I tried to find a solution online to speed up, but couldn't find it. Is anyone experience the same issue? How could we speed up the visual code?
from time import perf_counter
a=perf_counter()
import pandas as pd
b=perf_counter()
import numpy as np
c=perf_counter()
from datetime import datetime, date
d=perf_counter()
from scipy.stats import ttest_ind
e=perf_counter()
from scipy.stats import ttest_ind_from_stats
f=perf_counter()
from scipy.stats import ttest_1samp
g=perf_counter()
import seaborn as sns
h=perf_counter()
import matplotlib.pyplot as plt
i=perf_counter()
print(b-a)
print(c-b)
print(d-c)
print(e-d)
print(f-e)
print(g-f)
print(h-g)
print(i-h)
Take this to analyze which imports take too much time.
Then take 'cProfile' to do exactly analysis. you can refer to this page.
I'm writing code in a Jupyter Notebook that involves cleaning and analyzing a large amount of consumer data. I'm trying to use dill to save the dataframes with thousands of rows so I don't have to run the code every time I want to make an adjustment, so dill seems like the perfect package to do so... Except I'm getting this error when attempting to pickle the notebook:
AttributeError: module 'dill' has no attribute 'dump_session'
Let me know if the program code is necessary - I don't think it should make a difference. The imports are:
import numpy as np
import pandas as pd
import dill
import scipy
from matplotlib import pyplot as plt
from __future__ import division
from collections import OrderedDict
from sklearn.cluster import KMeans
pd.options.display.max_columns = None
and when I run this code I get the error from above:
dill.dump_session('recengine.db')
Is there another package that's interfering with dill's use of pickle vs. cpickle?
I've seen many times online that people use
import pylab
pylab.imshow(some_arg)
or
from pylab import *
imshow(some_arg)
but it gives the following error on my computer
NameError: name 'imshow' is not defined
however if I directly use matplotlib, it works fine
import matplotlib.pyplot as plt
plt.imshow(some_arg) # works fine
I've tried search about how pylab works, but there doesn't seem to be much information.
What should be the problem in my case?
Thank you.
Title says it all, I somehow can not find that function. Obviously it's inside the Numpy package (numpy.core.umath.deg2rad) and I've tried importing it but to no avail. Anyone care to chime in?
import numpy as np - np.deg2rad doesn't even show up
from numpy import* - umath.deg2rad shows up, but it raises an error, ''name 'umath' is not defined''
from numpy.core.umath import deg2rad
# then
deg2rad(...)
Or
import numpy as np
np.core.umath.deg2rad(...)