예제 #1
0
 def test_get_figure_invalid_2(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/-1/"
     py.sign_in(un, ak)
     with self.assertRaises(exceptions.PlotlyError):
         py.get_figure(url)
def display_cumulative_variance_dataset(X, scaler_method=None):
    n_components = X.shape[1]
    pca = PCA(n_components=n_components)
    # pca = PCA(n_components=2)

    #X_pca = pca.fit_transform(X)
    pca = pca.fit(X)
    _ = pca.transform(X)
    fig = show_cum_variance_vs_components(pca, n_components)

    py.sign_in('franec94', 'QbLNKpC0EZB0kol0aL2Z')
    if scaler_method is None:
        py.iplot(fig, filename='selecting-principal-components')
        # py.plot(fig, filename='selecting-principal-components')
    else:
        py.iplot(fig, filename='selecting-principal-components {}'.format(scaler_method))
        # py.plot(fig, filename='selecting-principal-components {}'.format(scaler_method))
    
    principal_components = [pc for pc in '2,5,6,7,8,9,10'.split(',')]
    for _, pc in enumerate(principal_components):
        n_components = int(pc)
    
        cum_var_exp_up_to_n_pcs = np.cumsum(pca.explained_variance_ratio_)[n_components-1]
        print(f"Cumulative varation explained up to {n_components} pcs = {cum_var_exp_up_to_n_pcs}")
    pass
예제 #3
0
 def test_get_figure_does_not_exist(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/1000000000/"
     py.sign_in(un, ak)
     with self.assertRaises(_plotly_utils.exceptions.PlotlyError):
         py.get_figure(url)
예제 #4
0
 def test_get_figure_invalid_2(self):
     un = "PlotlyImageTest"
     ak = "786r5mecv0"
     url = "https://plot.ly/~PlotlyImageTest/-1/"
     py.sign_in(un, ak)
     with self.assertRaises(exceptions.PlotlyError):
         py.get_figure(url)
예제 #5
0
 def test_get_figure_invalid_3(self):
     un = "PlotlyImageTest"
     ak = "786r5mecv0"
     url = "https://plot.ly/~PlotlyImageTest/2/"
     py.sign_in(un, ak)
     with self.assertRaises(ValueError):
         py.get_figure(url)
예제 #6
0
 def test_get_figure_does_not_exist(self):
     un = "PlotlyImageTest"
     ak = "786r5mecv0"
     url = "https://plot.ly/~PlotlyImageTest/1000000000/"
     py.sign_in(un, ak)
     with self.assertRaises(_plotly_utils.exceptions.PlotlyError):
         py.get_figure(url)
예제 #7
0
 def test_get_figure_invalid_3(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/2/"
     py.sign_in(un, ak)
     with self.assertRaises(ValueError):
         py.get_figure(url)
예제 #8
0
 def test_get_figure_invalid_1(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/a/"
     py.sign_in(un, ak)
     with self.assertRaises(exceptions.PlotlyError):
         py.get_figure(url)
예제 #9
0
def makeHoroplethMap(df):
    API='Vn3DdeYNzJ9f44m9ykeb'
    USER_NAME='irisdrei'
    fig = px.choropleth(df, locations="country", color="Clustering", hover_name="country", color_continuous_scale=px.colors.sequential.Plasma, locationmode="country names")
    # fig.show()
    py.sign_in(USER_NAME, API)
    py.image.save_as(fig, filename='countries.png')

    # choromap = px.choropleth(df,color="Bergeron",locations='country', projection="mercator")
    # choromap = px.choropleth(df, locations="country", color="Clustering", hover_name="country",color_continuous_scale=px.colors.sequential.Plasma, locationmode="country names")
    # choromap.update_geos(fitbounds="locations", visible=False)
    # choromap.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
    # choromap.show()

    # df_new = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')
    # fig = go.Figure(data=go.Choropleth(locations=df_new['CODE'], z=df['Clustering'], text=df['country'], colorscale='Blues', autocolorscale=False, reversescale=True))
    # fig.update_layout(geo=dict(showframe=False,showcoastlines=False,projection_type='equirectangular'),annotations=[dict()])
    # fig.show()

    # py.sign_in(USER_NAME, API)
    # py.image.save_as(choromap, filename='name.png')

# df = preProcessing.preProcess("C:\\Users\\Chen\\Desktop\\Dataset.xlsx")
# runModel(df,3,2)
예제 #10
0
 def test(self):
     py.sign_in('username', 'key', **plot_options['parent'])
     options = py._plot_option_logic(plot_options['child'])
     for option, value in plot_options['expected_output'].items():
         self.assertEqual(options[option], value)
예제 #11
0
 def setUp(self):
     super(TestPlot, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.simple_figure = {'data': [{'x': [1, 2, 3], 'y': [2, 1, 2]}]}
예제 #12
0
 def test_get_figure_with_url(self):
     un = "PlotlyImageTest"
     ak = "786r5mecv0"
     url = "https://plot.ly/~PlotlyImageTest/13183/"
     py.sign_in(un, ak)
     py.get_figure(url)
예제 #13
0
 def test_proper_escaping(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/13185/"
     py.sign_in(un, ak)
     py.get_figure(url)
예제 #14
0
 def setUp(self):
     super(TestImage, self).setUp()
     py.sign_in("PlotlyImageTest", "786r5mecv0")
     self.data = [{"x": [1, 2, 3], "y": [3, 1, 6]}]
예제 #15
0
 def test_get_figure(self):
     un = "PlotlyImageTest"
     ak = "786r5mecv0"
     file_id = 13183
     py.sign_in(un, ak)
     py.get_figure("PlotlyImageTest", str(file_id))
예제 #16
0
 def setUp(self):
     super(TestPlot, self).setUp()
     py.sign_in("PlotlyImageTest", "786r5mecv0")
     self.simple_figure = {"data": [{"x": [1, 2, 3], "y": [2, 1, 2]}]}
예제 #17
0
 def test_get_figure_raw(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     file_id = 2
     py.sign_in(un, ak)
     py.get_figure('PlotlyImageTest', str(file_id), raw=True)
예제 #18
0
 def test(self):
     py.sign_in('username', 'key', **plot_options)
     self.assertRaises(PlotlyError, py._plot_option_logic, {})
예제 #19
0
 def test(self):
     py.sign_in('username', 'key', **plot_options['parent'])
     options = py._plot_option_logic(plot_options['child'])
     for option, value in plot_options['expected_output'].items():
         self.assertEqual(options[option], value)
예제 #20
0
 def test_get_figure(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     file_id = 13183
     py.sign_in(un, ak)
     py.get_figure('PlotlyImageTest', str(file_id))
예제 #21
0
 def test_get_figure(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     file_id = 13183
     py.sign_in(un, ak)
     py.get_figure('PlotlyImageTest', str(file_id))
예제 #22
0
 def setUp(self):
     super(TestImage, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}]
예제 #23
0
 def test_get_figure_raw(self):
     un = "PlotlyImageTest"
     ak = "786r5mecv0"
     file_id = 2
     py.sign_in(un, ak)
     py.get_figure("PlotlyImageTest", str(file_id), raw=True)
예제 #24
0
 def test(self):
     py.sign_in('username', 'key', **plot_options)
     self.assertRaises(PlotlyError, py._plot_option_logic, {})
예제 #25
0
 def test_proper_escaping(self):
     un = "PlotlyImageTest"
     ak = "786r5mecv0"
     url = "https://plot.ly/~PlotlyImageTest/13185/"
     py.sign_in(un, ak)
     py.get_figure(url)
예제 #26
0
 def test_get_figure_with_url(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/13183/"
     py.sign_in(un, ak)
     py.get_figure(url)
def setup_image():
    py.sign_in("PlotlyImageTest", "786r5mecv0")
    data = [{"x": [1, 2, 3], "y": [3, 1, 6]}]

    return data
예제 #28
0
 def test_get_figure_raw(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     file_id = 2
     py.sign_in(un, ak)
     py.get_figure('PlotlyImageTest', str(file_id), raw=True)
예제 #29
0
 def setUp(self):
     super(TestPlot, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.simple_figure = {'data': [{'x': [1, 2, 3], 'y': [2, 1, 2]}]}
예제 #30
0
 def setUp(self):
     super(TestImage, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}]
예제 #31
0
 def test(self):
     py.sign_in("username", "key", **plot_options)
     self.assertRaises(PlotlyError, py._plot_option_logic, {})
예제 #32
0
 def setUp(self):
     py.sign_in("PlotlyImageTest", "786r5mecv0", plotly_domain="https://plot.ly")
예제 #33
0
 def test(self):
     py.sign_in("username", "key", **plot_options["parent"])
     options = py._plot_option_logic(plot_options["child"])
     for option, value in plot_options["expected_output"].items():
         self.assertEqual(options[option], value)
예제 #34
0
 def setUp(self):
     py.sign_in('PlotlyImageTest', '786r5mecv0',
                plotly_domain='https://plot.ly')