ci_mapping/analysis/descriptive_analysis.py
def publications_by_affiliation_type(data, filename="publications_by_affiliation_type"):
    """
    Share of publications in CI, AI+CI by industry and non-industry affiliations.

    Args:
        data (`pd.DataFrame`): Author-level affiliation data.
        filename (str): Name of the HTML file to store the plot.

    """
    frames = []
    for (num, comp) in zip([0, 1], ["non-Industry", "Industry"]):
        for cat in data.type.unique():
            df = data[data.non_company == num].drop_duplicates("paper_id")
            nominator = df[df.type == cat].groupby("year")["paper_id"].count()
            try:
                denominator = (
                    df[df.type == cat].groupby("year")["paper_id"].count().iloc[0]
                )
            except IndexError:
                denominator = 0

            frame = pd.DataFrame(nominator / denominator).reset_index()
            frame = pd.DataFrame(frame).rename(index=str, columns={"paper_id": "value"})
            frame["type"] = cat
            frame["category"] = comp
            frames.append(frame)

    df = pd.concat(frames)

    # Plotting
    alt.Chart(df).mark_point(opacity=1, filled=True, size=80).encode(
        alt.X("category:N", title=None),
        alt.Y("value:Q",),
        alt.Color("type:N", legend=alt.Legend(title="Category")),
        alt.Column("year"),
        tooltip=["year", "value", "type", "category"],
    ).properties(width=25).configure_facet(spacing=15).configure_legend(
        titleFontSize=12, labelFontSize=12
    ).configure_axis(
        labelFontSize=12, titleFontSize=12
    ).interactive().save(
        f"{ci_mapping.project_dir}/reports/figures/{filename}.html"
    )
    logger.info(f"Stored {filename} plot.")

    Share of publications in CI, AI+CI by industry and non-industry affiliations.

    Args:
        data (`pd.DataFrame`): Author-level affiliation data.
        filename (str): Name of the HTML file to store the plot.

    
Share of publications in CI, AI+CI by industry and non-industry affiliations.
Share of publications in CI AI + CI by industry and non - industry affiliations .
def publications_by_affiliation_type(data, filename="publications_by_affiliation_type"):
    frames = []
    for (num, comp) in zip([0, 1], ["non-Industry", "Industry"]):
        for cat in data.type.unique():
            df = data[data.non_company == num].drop_duplicates("paper_id")
            nominator = df[df.type == cat].groupby("year")["paper_id"].count()
            try:
                denominator = (
                    df[df.type == cat].groupby("year")["paper_id"].count().iloc[0]
                )
            except IndexError:
                denominator = 0
            frame = pd.DataFrame(nominator / denominator).reset_index()
            frame = pd.DataFrame(frame).rename(index=str, columns={"paper_id": "value"})
            frame["type"] = cat
            frame["category"] = comp
            frames.append(frame)
    df = pd.concat(frames)
    alt.Chart(df).mark_point(opacity=1, filled=True, size=80).encode(
        alt.X("category:N", title=None),
        alt.Y("value:Q",),
        alt.Color("type:N", legend=alt.Legend(title="Category")),
        alt.Column("year"),
        tooltip=["year", "value", "type", "category"],
    ).properties(width=25).configure_facet(spacing=15).configure_legend(
        titleFontSize=12, labelFontSize=12
    ).configure_axis(
        labelFontSize=12, titleFontSize=12
    ).interactive().save(
        f"{ci_mapping.project_dir}/reports/figures/{filename}.html"
    )
    logger.info(f"Stored {filename} plot.")
def publications_by_affiliation_type ( data , filename = "publications_by_affiliation_type" ) : frames = [ ] for ( num , comp ) in zip ( [ 0 , 1 ] , [ "non-Industry" , "Industry" ] ) : for cat in data . type . unique ( ) : df = data [ data . non_company == num ] . drop_duplicates ( "paper_id" ) nominator = df [ df . type == cat ] . groupby ( "year" ) [ "paper_id" ] . count ( ) try : denominator = ( df [ df . type == cat ] . groupby ( "year" ) [ "paper_id" ] . count ( ) . iloc [ 0 ] ) except IndexError : denominator = 0 frame = pd . DataFrame ( nominator / denominator ) . reset_index ( ) frame = pd . DataFrame ( frame ) . rename ( index = str , columns = { "paper_id" : "value" } ) frame [ "type" ] = cat frame [ "category" ] = comp frames . append ( frame ) df = pd . concat ( frames ) alt . Chart ( df ) . mark_point ( opacity = 1 , filled = True , size = 80 ) . encode ( alt . X ( "category:N" , title = None ) , alt . Y ( "value:Q" , ) , alt . Color ( "type:N" , legend = alt . Legend ( title = "Category" ) ) , alt . Column ( "year" ) , tooltip = [ "year" , "value" , "type" , "category" ] , ) . properties ( width = 25 ) . configure_facet ( spacing = 15 ) . configure_legend ( titleFontSize = 12 , labelFontSize = 12 ) . configure_axis ( labelFontSize = 12 , titleFontSize = 12 ) . interactive ( ) . save ( f"{ci_mapping.project_dir}/reports/figures/{filename}.html" ) logger . info ( f"Stored {filename} plot." )
Share of publications in CI, AI+CI by industry and non-industry affiliations.
Share of publications in CI AI + CI by industry and non - industry affiliations .
"""
    Share of publications in CI, AI+CI by industry and non-industry affiliations.

    Args:
        data (`pd.DataFrame`): Author-level affiliation data.
        filename (str): Name of the HTML file to store the plot.

    """ # Plotting
data
Author-level affiliation data.
Author - level affiliation data .
filename
Name of the HTML file to store the plot.
Name of the HTML file to store the plot .