Пример #1
0
def plot_data(df):

    #LABEL COUNT
    flag = False
    if flag:
        counts = []
        labels = [
            'angry-aggresive', 'sad-lonely', 'quiet-still', 'relaxing-calm',
            'happy-pleased', 'amazed-suprised'
        ]
        for i in labels:
            print(i)
            c = df[i].value_counts()
            counts.append(c[1])

        #my_colors = [(0.5, 0.4, 0.5), (0.75, 0.75, 0.25)] * 5  # <-- make two custom RGBs and repeat/alternate them over all the bar elements.
        sns.set(style="whitegrid", color_codes=True)
        color = cm.inferno_r(np.linspace(.3, .90, 10))

        Number_of_data = pd.DataFrame(list(zip(labels, counts)),
                                      columns=['Label', 'Number of Data'])

        Number_of_data.plot(x="Label",
                            y="Number of Data",
                            kind="bar",
                            color=color,
                            legend=None,
                            figsize=(8, 8))
        plt.gcf().subplots_adjust(bottom=0.02, top=0.5)
        plt.tight_layout()
        #plt.title("Label Count")
        plt.ylabel('Number of songs', fontsize=12)
        plt.xlabel('Labels', fontsize=12)
        plt.xticks(rotation=45)
        plt.savefig("LabelCounts.png", dpi=300, bbox_inches="tight")
        plt.show()

    else:
        # SONGS HAVING MULTIPLE LABELS
        rowSums = df.loc[:, 'amazed-suprised':'angry-aggresive'].sum(axis=1)
        multiLabel_counts = rowSums.value_counts()
        print(multiLabel_counts.sort_index())

        color = cm.inferno_r(np.linspace(.3, .90, 10))

        sns.set(style="whitegrid", color_codes=True)
        multiLabel_counts.sort_index().plot(x="number of labels",
                                            y="Number of Songs",
                                            kind="bar",
                                            color=color)
        #plt.title("Songs having multiple labels ")
        plt.ylabel('Number of songs', fontsize=12)
        plt.xlabel('Number of labels', fontsize=12)
        plt.savefig("NumberOfLabels.png", dpi=300, bbox_inches="tight")
        plt.show()
        print(len(df))
Пример #2
0
def arrest_analysis(analysis_df):
    '''
	displays no of arrests and non-arrests for each crime type
	'''
    color = cm.inferno_r(np.linspace(.4, .8, 30))
    analysis_df.groupby(['Primary Type',
                         'Arrest']).size().unstack().plot(kind='barh',
                                                          stacked=True,
                                                          figsize=(10, 10))
    plt.show()
Пример #3
0
def plotCuisine(cui,count,type = 'bar',city='Dublin'):
    if type == 'bar':
        fig, axes = plt.subplots(1,1, figsize = (20,20))
    elif type == 'pie':    
        fig, axes = plt.subplots(1,1, figsize = (7,7))
    lists = sorted(cui.items(), key=operator.itemgetter(1),reverse=True)
    x, y = zip(*lists[:count])
    col = cm.inferno_r(np.linspace(.7,.2, len(x)))
    if type == 'bar':
        axes.bar(x,y,color = col)
        axes.set_ylabel('Count')
        axes.set_xlabel('Cuisine')
        axes.set_xticklabels(x,rotation = 90)
    elif type == 'pie':
        axes.pie(y, labels = x, autopct=lambda pct: func(pct, y))
        axes.set_title(city,fontsize=15)
    axes.set_facecolor('lightgrey')
Пример #4
0
def app():
    st.title('NEWARK')

    st.write(
        "Newark is an up and coming city looking to disrupt the tech space. Being just across the Hudson from the tech mecca of NYC, Newark is home to startups and tech businesses in fintech, telecom, big data, cybersecurity and AI.  Also, take a look at resources such as The Knowledge House for further information about salaries, companies, job postings and opportunities to upskill."
    )

    st.write("")
    st.write("Tech Jobs in Newark")
    ax = data[data["location_category"] == "newark new jersey"].groupby(
        "job_category").size()
    st.bar_chart(ax)
    #---------graph for software engineer-----------------------------

    x = top_tech_se_newark['technology']
    y = top_tech_se_newark['frequency']
    # x = ['Scala', 'Java', 'Python', 'AWS', 'SQL', 'Git', 'React', 'JavaScript', 'Kubernetes', 'IDEs']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x, y, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(
        'The Top Technologies Required by Employers For Software Engineers in Newark, NJ'
    )
    st.write(fig)
    #---------graph for data analyst------------------------------

    x_da = top_tech_da_newark['technology']
    y_da = top_tech_da_newark['frequency']

    # colors = cm.inferno_r(np.linspace(.5, .8, 5))
    colors = [
        'lightcoral', 'b', 'cadetblue', 'turquoise', 'palegreen', 'indigo'
    ]
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_da, y_da, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    'The Top Technologies Required by Employers For Data Analyst in Newark, NJ'
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)

    #---------graph for data scientist-----------------------------

    x_ds = top_tech_ds_newark['technology']
    y_ds = top_tech_ds_newark['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_ds, y_ds, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies Required by Employers For Data Scientist in Newark, NJ'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)

    #---------graph for web developer-----------------------------

    x_wdev = top_tech_wb_newark['technology']
    y_wdev = top_tech_wb_newark['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_wdev, y_wdev, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies Required by Employers For Web Developer in Newark, NJ'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
    #---------graph for front end developer-----------------------------

    x_frtdev = top_tech_frtdev_newark['technology']
    y_frtdev = top_tech_frtdev_newark['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_frtdev, y_frtdev, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies Required by Employers For Front End Developers in Newark, NJ'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)

    #---------graph for backend developer-----------------------------

    x_backdev = top_tech_backdev_newark['technology']
    y_backdev = top_tech_backdev_newark['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_backdev, y_backdev, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies Required by Employers For Back End Developers in Newark, NJ'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
    #---------graph for uiux designer-----------------------------
    top_tech_uiux_newark

    x_uiux = top_tech_uiux_newark['technology']
    y_uiux = top_tech_uiux_newark['frequency']

    # colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_uiux, y_uiux, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers for UI/UX designers in Newark, NJ'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
Пример #5
0
def app():
    st.title('ATLANTA')

    st.write(
        "Atlanta, also referred to as “the Silicon Valley of the South,” is proving to be a leading city for start-ups and tech companies in a variety of industries. Below you will find some of the top tech jobs as well as their technologies and skills. Also, take a look at resources such as The Knowledge House and Built in Atlanta for further information about salaries, companies, job postings and opportunities to upskill."
    )
    st.write("")
    st.write("Tech Jobs in Atlanta")
    ax = data[data["location_category"] == "atlanta georgia"].groupby(
        "job_category").size()
    # ax.set_title("Atlanta Tech Jobs")
    st.bar_chart(ax)
    #---------graph for software engineer-----------------------------

    x = top_tech_se_atlanta['technology']
    y = top_tech_se_atlanta['frequency']
    # x = ['Scala', 'Java', 'Python', 'AWS', 'SQL', 'Git', 'React', 'JavaScript', 'Kubernetes', 'IDEs']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x, y, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(
        "The Top Technologies Required by Employers For Software Engineers in Atlanta, GA"
    )
    st.write(fig)
    #---------graph for data analyst------------------------------

    x_da = top_tech_da_atlanta['technology']
    y_da = top_tech_da_atlanta['frequency']

    # colors = cm.inferno_r(np.linspace(.5, .8, 5))
    colors = [
        'lightcoral', 'b', 'cadetblue', 'turquoise', 'palegreen', 'indigo'
    ]
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_da, y_da, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(
        'The Top Technologies/Skills Required by Employers For Data Analyst in Atlanta, GA'
    )
    st.write(fig)

    #---------graph for data scientist-----------------------------

    x_ds = top_tech_ds_atlanta['technology']
    y_ds = top_tech_ds_atlanta['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_ds, y_ds, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(
        'The Top Technologies/Skills Required by Employers For Data Scientist in Atlanta, GA'
    )
    st.write(fig)

    #---------graph for web developer-----------------------------

    x_wdev = top_tech_wb_atlanta['technology']
    y_wdev = top_tech_wb_atlanta['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_wdev, y_wdev, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers For Web Developer in Atlanta, GA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
    #---------graph for front end developer-----------------------------

    x_frtdev = top_tech_frtdev_atlanta['technology']
    y_frtdev = top_tech_frtdev_atlanta['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_frtdev, y_frtdev, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers for front end developers in Atlanta, GA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)

    #---------graph for backend developer-----------------------------

    x_backdev = top_tech_backdev_atlanta['technology']
    y_backdev = top_tech_backdev_atlanta['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_backdev, y_backdev, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers for Back End developers in Atlanta, GA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
    #---------graph for uiux designer-----------------------------
    top_tech_uiux_atlanta

    x_uiux = top_tech_uiux_atlanta['technology']
    y_uiux = top_tech_uiux_atlanta['frequency']

    # colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_uiux, y_uiux, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers for UI/UX designers in Atlanta, GA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
Пример #6
0
def app():
    st.title('LOS ANGELES')

    st.write(
        "Los Angeles is a hot-spot in the arena of technology being home to “Silicon Beach,” a rich hub of pioneering companies in tech. Contrasting cities of Northern California, Los Angeles is unique in its proximity to Hollywood and its extensive entertainment industry. Below you will find some of the top tech jobs and their technologies and skills. Also, take a look at resources such as The Knowledge House and Built in LA for further information about salaries, companies, job postings and opportunities to upskill."
    )
    st.write("")
    st.write("Tech Job in Los Angeles")
    ax = data[data["location_category"] == "los angeles california"].groupby(
        "job_category").size()
    st.bar_chart(ax)
    #---------graph for software engineer-----------------------------

    x = top_tech_se_la['technology']
    y = top_tech_se_la['frequency']
    # x = ['Scala', 'Java', 'Python', 'AWS', 'SQL', 'Git', 'React', 'JavaScript', 'Kubernetes', 'IDEs']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x, y, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies Required by Employers For Software Engineers in Los Angeles, CA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
    #---------graph for data analyst------------------------------

    x_da = top_tech_da_la['technology']
    y_da = top_tech_da_la['frequency']

    # colors = cm.inferno_r(np.linspace(.5, .8, 5))
    colors = [
        'lightcoral', 'b', 'cadetblue', 'turquoise', 'palegreen', 'indigo'
    ]
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_da, y_da, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers For Data Analyst in Los Angeles, CA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)

    #---------graph for data scientist-----------------------------

    x_ds = top_tech_ds_la['technology']
    y_ds = top_tech_ds_la['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_ds, y_ds, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers For Data Scientist in Los Angeles, CA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)

    #---------graph for web developer-----------------------------

    x_wdev = top_tech_wb_la['technology']
    y_wdev = top_tech_wb_la['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_wdev, y_wdev, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers For Web Developer in Los Angeles, CA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
    #---------graph for front end developer-----------------------------

    x_frtdev = top_tech_frtdev_la['technology']
    y_frtdev = top_tech_frtdev_la['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_frtdev, y_frtdev, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers for front end developers in Los Angeles, CA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)

    #---------graph for backend developer-----------------------------

    x_backdev = top_tech_backdev_la['technology']
    y_backdev = top_tech_backdev_la['frequency']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_backdev, y_backdev, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers for Back End developers in Los Angeles, CA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
    #---------graph for uiux designer-----------------------------

    x_uiux = top_tech_uiux_la['technology']
    y_uiux = top_tech_uiux_la['frequency']

    # colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize=(10, 5))
    ax.bar(x_uiux, y_uiux, color=colors)
    ax.set(xlabel='technology', ylabel='Frequency')
    st.write(
        'The Top Technologies/Skills Required by Employers for UI/UX designers in Los Angeles, CA'
    )
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")
    st.write(fig)
Пример #7
0
                                       downcast="float")
df = df.fillna(0)
df.at[13, 'TotalRecovered'] = 344
#data analysis
df['Positivepercentage'] = ((df['TotalCases']) / df['TotalTests']) * 100
df['Positivepercentage'] = df['Positivepercentage'].replace(np.inf, 0)

df['RecoveredPercentage'] = ((df['TotalRecovered']) / df['TotalCases']) * 100
df['DeathPercentage'] = ((df['TotalDeaths']) / df['TotalCases']) * 100

df = df.sort_values('TotalCases', ascending=False)
df1 = df.loc[df["TotalCases"] > 1000]

d_color = cm.viridis_r(np.linspace(.4, .8, 30))
r_color = cm.magma_r(np.linspace(.4, .8, 30))
c_color = cm.inferno_r(np.linspace(.4, .8, 30))

#Bar chart
df1.groupby("Country,Other").DeathPercentage.max().sort_values(
    ascending=False)[:25].plot.bar(color=d_color)
plt.title(
    "Top 25 countries with highest Death Percentage whose total cases are greater than 1000"
)
plt.xlabel("Country")
plt.ylabel("Death Percentage")

plt.show()
df1.groupby("Country,Other").RecoveredPercentage.max().sort_values(
    ascending=False).tail(25).plot.bar(color=r_color)
plt.title(
    "Countries(25) with lowest Recovered Percentage whose total cases are greater than 1000"
Пример #8
0
def plot_number_of_deaths_in_past_7_years_per_drug(drug_usage_df, drugs):
    accidents_per_drug = drug_usage_df[drugs].sum()
    accidents_per_drug = accidents_per_drug.sort_values()
    ax = accidents_per_drug.plot(kind='barh', title ="Accidental Death Count in the past 7 years per drug", fontsize=14, figsize = (20,10), stacked=True, color = cm.inferno_r(np.linspace(0.3, 0.6, 30)))
    ax.set_xlabel("Drugs", fontsize=14)
    ax.set_ylabel("Number of Accidental Deaths", fontsize=14)
    for index, value in enumerate(accidents_per_drug):
        x_index = value+2
        y_index = index-0.08
        ax.text(x_index, y_index, str(value), fontweight='bold', fontsize=14)
    ax.get_figure().savefig('{}/death-count-per-drug-over-seven-years.jpeg'.format(image_path))
    plt.show()
Пример #9
0
                                                     score))

# 未调仓情况下,我们在LR和GBDT上获得两个最高分数0.8668,0.8842。由于某些Classifier对数据的量级敏感,因此,我们需要对数据进行一个预处理。但是,我们几乎所有的数据都被转换成了dummies的形式,Fare数据也被我们log化,转换到0-7之间了,所以我觉得并不需要`from sklearn.preprocessing import StandardScaler`它去缩放数据。
#
# ## 6.2 Feature importance
# 我们可以直观上看看LogisticRegression认为哪些feature权重比较高。

# In[69]:

lr = LogisticRegression(random_state=0).fit(X_train, Y_train)
lr.coef_

# In[70]:

from matplotlib import cm
color = cm.inferno_r(np.linspace(.4, .8, len(X_train.columns)))

pd.DataFrame({
    'weights': lr.coef_[0]
}, index=X_train.columns).sort_values(by='weights', ascending=True).plot.barh(
    figsize=(7, 7),
    fontsize=12,
    legend=False,
    title='Feature weights from Logistic Regression',
    color=color)
sns.despine(bottom=True)

# 这个Feature Weights还挺符合我们的认知的,**familysize_level_1(1人),familysize_level_2(2-4人),title_level_3(Mrs, Miss),age_level_3(child), Sex_0(女性),title_level_2(Mister, Master, rare), Fare(费用),Cabin_1(有客舱),Pclass_1(1等舱),Pclass_2(二等舱),Embarked_C(C港口)**都具有提高幸存率的参数。**这里为什么familysize_level为1个人时候,为什么对判定影响这么大**???
#
# 另外,**faimily_size_level_0(大型家庭),title_level_1(Mr), Sex_1(male),age_level_1(老年人),Cabin_0(无客舱),Pclass_3(三等舱),Embarked_S(S港口)、age_level_2(年轻-中年人)**都就具有较大的负权重,这些都是对Survived的debuff。与我们上面最开始feature分析的还是一致的。
#
Пример #10
0
        tmp = np.where(
            path_approx_errors - np.min(approx_errors) <= eps_val)[0]
        worst_best = np.max(path_approx_errors[tmp])
        i_best = np.where(path_approx_errors == worst_best)[0][0]

    lambda_selected = path_lambdas[i_best]
    beta_selected = path_betas[:, i_best]
    error_selected = np.linalg.norm(y_test - X_test.dot(beta_selected.ravel()))

    print("size_path = ", path_lambdas.shape[0], "error_selected = ",
          error_selected, "lambda_selected = ", lambda_selected)

    selected_errors[i_eps_val] = error_selected
    selected_lambdas[i_eps_val] = lambda_selected

colors_2 = cm.inferno_r(np.geomspace(0.01, 1, n_eval))[::-1]
colors = np.geomspace(0.01, 1, n_eval)[::-1]

plt.figure(figsize=(9, 4.4))
plt.plot(default_lambdas / lambda_max,
         approx_errors,
         color="k",
         lw=1,
         label="Validation curve at \n machine precision",
         zorder=-1)
plt.scatter(selected_lambdas / lambda_max,
            selected_errors,
            c=colors,
            marker="*",
            s=30,
            lw=2,
Пример #11
0
def app():
    st.title('NEW YORK CITY')

    st.write("New York is a powerhouse in the tech industry being home to “Silicon Alley” teeming with tons of start-ups and well-known tech companies. Although Manhattan is highly regarded, other NYC boroughs are also leaving their mark on the tech sphere with innovative, entrepreneurial tech businesses and brands. Below you will find some of the top tech jobs as well as their technologies and skills. Also, take a look at resources such as The Knowledge House and Built in NY for further information about salaries, companies, job postings and opportunities to upskill.")
    
    st.write("")
    st.write("Tech Jobs in New York")
    ax = data[data["location_category"] == "new york city" ].groupby("job_category").size()
    st.bar_chart(ax)
    

    

        # x = top_technologies_SE['technology']
    y = top_technologies_se['frequency']
    x = ['Scala', 'Java', 'Python', 'AWS', 'SQL', 'Git', 'React', 'JavaScript', 'Kubernetes', 'IDEs']

    colors = cm.inferno_r(np.linspace(.5, .8, 5))
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize = (10,5))
    ax.bar(x,y, color = colors)
    ax.set(xlabel='technology', ylabel = 'Frequency')
    st.write('The Top Technologies Required by Employers For Software Engineers in NY')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")

    plt.show()

    st.write(fig)

#Tools for Data Analyst in NYC
    
    x = top_technologies_da['technology']
    y = top_technologies_da['frequency']

    # colors = cm.inferno_r(np.linspace(.5, .8, 5))
    colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize = (10,5))
    ax.bar(x,y, color = colors)
    ax.set(xlabel='technology', ylabel = 'Frequency')
    st.write('The Top Technologies/Skills Required by Employers For Data Analyst in NY')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")

    plt.show()
    st.write(fig)


#Tools For Data Scientist 


    x = top_technologies_ds['technology']
    y = top_technologies_ds['frequency']

    colors = cm.inferno_r(np.linspace(.2, .8, 5))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize = (10,5))
    ax.bar(x,y, color = colors)
    ax.set(xlabel='technology', ylabel = 'Frequency')
    st.write('The Top Technologies/Skills Required by Employers For Data Scientists in NY')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")

    plt.show()
    st.write(fig)


#Tools For Web Developers
 

    x = top_technologies_wb['technology']
    y = top_technologies_wb['frequency']

    colors = cm.inferno_r(np.linspace(.167, .8, 10))
    # colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize = (10,5))
    ax.bar(x,y, color = colors)
    ax.set(xlabel='technology', ylabel = 'Frequency')
    st.write('The Top Technologies/Skills Required by Employers For Web Developers in NY')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")

    plt.show()
    st.write(fig)


#Tools For Front-end Developers
    
    x = top_technologies_frtd['technology']
    y = top_technologies_frtd['frequency']

    # colors = cm.inferno_r(np.linspace(.167, .8, 10))
    colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize = (10,5))
    ax.bar(x,y, color = colors)
    ax.set(xlabel='technology', ylabel = 'Frequency')
    st.write('The Top Technologies/Skills Required by Employers for Front End Developers in NY')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")

    plt.show()
    st.write(fig)



#Tools For Back-end Developers
   

    x = top_technologies_backd['technology']
    y = top_technologies_backd['frequency']

    # colors = cm.inferno_r(np.linspace(.167, .8, 10))
    colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize = (10,5))
    ax.bar(x,y, color = colors)
    ax.set(xlabel='technology', ylabel = 'Frequency')
    st.write('The Top Technologies/Skills Required by Employers for Back End Developers in NY')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")

    plt.show()
    st.write(fig)



#Tools For UI/UX Developers
   
    x = top_technologies_uiux['technology']
    y = top_technologies_uiux['frequency']

    # colors = cm.inferno_r(np.linspace(.167, .8, 10))
    colors = ['lightcoral', 'b', 'cadetblue', 'turquoise','palegreen','indigo']
    # my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, len(x)))

    fig, ax = plt.subplots(figsize = (10,5))
    ax.bar(x,y, color = colors)
    ax.set(xlabel='technology', ylabel = 'Frequency')
    st.write('The Top Technologies/Skills Required by Employers for UI/UX Developers in NY')
    plt.xticks(rotation=-45, ha="left", rotation_mode="anchor")

    plt.show()
    st.write(fig)
Пример #12
0
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import cm
color = cm.inferno_r(np.linspace(.4, .8, 6))

frequencies = [0.7780, 0.9367, 0.9973, 0.9982, 0.9993,
               0.9997]  # bring some raw data

freq_series = pd.Series.from_array(
    frequencies
)  # in my original code I create a series and run on that, so for consistency I create a series from the list.

x_labels = [
    'Fixed Physical Model', 'Applied Physical Model', 'Simple DNN Model',
    'Simple Random Forest', 'Complex Random Forest', 'Optimized Model'
]

colors = ['#624ea7', 'g', 'yellow', 'k', 'maroon', 'black']

# now to plot the figure...
plt.figure(figsize=(8, 8))
ax = freq_series.plot(kind='bar', color=color)
ax.set_title("Performance Compare")
ax.set_xlabel("Model Name")
ax.set_ylabel("Correlation Score")
ax.set_xticklabels(x_labels)

rects = ax.patches

# For each bar: Place a label
Пример #13
0
'''
part 1: general 
'''
#Year & shipping
yea_ship = vgsale.groupby('Year').Total_Shipped.sum()
t = range(1976, 2021)
upper = 400
supper = np.ma.masked_where(yea_ship >= upper, yea_ship)
slower = np.ma.masked_where(yea_ship < upper, yea_ship)
slower
fig, ax = plt.subplots()
ax.plot(t, slower, t, supper)
plt.show()

#Genre & shipping
color = cm.inferno_r(np.linspace(.4, .8, 30))

gen_ship = vgsale.groupby('Genre').Total_Shipped.sum().sort_values(
    ascending=True)
gen_ship[:4]
gen_ship
gen_ship.plot(kind='barh', color=color)

#Platform & shipping
color = cm.inferno_r(np.linspace(.2, .7, 30))
pla_ship = vgsale.groupby('Platform').Total_Shipped.sum().sort_values(
    ascending=True)
pla_ship
pla_ship[20:].plot(kind='barh', color=color)

#publisher & shipping