npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cylynx/verifyml-card-sections

v1.0.11

Published

Display specific model card information with provided section and segments.

Downloads

4

Readme

npm

A React component that display specific VerifyML Model Card information with given data sources and section.

Quick Start

NPM

npm install @cylynx/verifyml-card-sections --save

or:

YARN

yarn add @cylynx/verifyml-card-sections

Usage

Client Side Rendering - React

import CardSection, {
  ModelCardSectionContent,
  ProtobufUtil,
} from '@cylynx/verifyml-card-sections';
import { useEffect, useState } from 'react';
import '@cylynx/verifyml-card-sections/dist/style.css';

const SECTION = 'fairnessAnalysis';
const SUB_SECTIONS: ModelCardSubSection<'fairnessAnalysis'>[] = [
  'type',
  'tests',
  'graphics',
  'metadata',
];

const VerifyMLDemo = () => {
  const [modelCardSection, setModelCardSection] =
    useState<ModelCardSectionContent>();

  useEffect(() => {
    const init = async () => {
      const protobufUtil = new ProtobufUtil();
      const message = await protobufUtil.fetchMessage(
        'https://github.com/cylynx/verifyml/blob/main/examples/model_card_output/data/credit_card_fraud_example2.proto',
        SECTION,
      );

      setModelCardSection(message);
    };

    init();
  }, []);

  return (
    <div style={{ padding: '16px' }}>
      {modelCardSection && (
        <CardSection
          modelCardSection={modelCardSection}
          section={SECTION}
          subSections={SUB_SECTIONS}
        />
      )}
    </div>
  );
};

ReactDOM.render(<VerifyMLDemo />, document.getElementById('root'));

Server Side Rendering - Next

_app.tsx

Include style.css into _app.tsx to enable global style.

import '../styles/globals.css';
import type { AppProps } from 'next/app';

// https://nextjs.org/docs/messages/css-global
import '@cylynx/verifyml-card-sections/dist/style.css';

function MyApp({ Component, pageProps }: AppProps) {
  return <Component {...pageProps} />;
}

export default MyApp;

index.tsx

import type { GetStaticProps, NextPage, InferGetStaticPropsType } from 'next';
import styles from '../styles/Home.module.css';
import Head from 'next/head';
import CardSection, {
  ProtobufUtil,
  ModelCardSectionContent,
  ModelCardSubSection,
} from '@cylynx/verifyml-card-sections';

const SECTION = 'fairnessAnalysis';
const SUB_SECTIONS: ModelCardSubSection<'fairnessAnalysis'>[] = [
  'type',
  'tests',
  'graphics',
  'metadata',
];

type HomeProps = InferGetStaticPropsType<typeof getStaticProps>;
const Home: NextPage<HomeProps> = ({ creditCardExample }) => {
  const creditCardData = JSON.parse(
    creditCardExample,
  ) as ModelCardSectionContent;

  return (
    <div className={styles.container}>
      <Head>
        <title>VerifyML Card Section</title>
        <meta
          name='description'
          content='Next App for library behaviour demonstration'
        />
      </Head>

      <main className={styles.main}>
        <CardSection
          modelCardSection={creditCardData}
          section={SECTION}
          subSection={SUB_SECTIONS}
        />
      </main>
    </div>
  );
};

export const getStaticProps: GetStaticProps<{
  creditCardExample: string;
}> = async () => {
  const protobufUtil = new ProtobufUtil();
  const creditCard = await protobufUtil.fetchMessage(
    'https://github.com/cylynx/verifyml/blob/main/examples/model_card_output/data/credit_card_fraud_example2.proto',
    SECTION,
  );

  const creditCardExample = JSON.stringify(creditCard);

  return { props: { creditCardExample } };
};

Props

This section outlined the list of available props and its structure.

modelCardSection

description:

  • Decoded model card section data.

type:

  • ModelCardSectionContent

section

  • Decide which section to render.

type:

  • string

example:

  1. Model Details, modelDetails
  2. Considerations, considerations
  3. Datasets, datasets
  4. Quantitative Analysis, quantitativeAnalysis
  5. Explainability Analysis, explainabilityAnalysis
  6. Fairness Analysis, fairnessAnalysis

subSections

  • Decide which subsection to render.

type:

  • ModelDetailSubSection[]
  • ConsiderationSubSection[]
  • DatasetSubSection[]
  • QASubSection[]
  • EASubSection[]
  • FASubSection[]

example:

| Section | Type | Sub-section | | :----------------------- | :-------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | modelDetails | ModelDetailSubSection[] | overviewcurrentVersionownersregulatoryRequirementslicensesreferencesdocumentationpath | | considerations | ConsiderationSubSection[] | intendedUsersuseCaseslimitationstradeoffsfairnessConsiderationsethicalConsiderations | | datasets | DatasetSubSection[] | namegraphicsdescriptionlinksensitivityMetrics | | quantitativeAnalysis | QASubSection[] | slicegraphicsmetadatatests | | explainabilityAnalysis | EASubSection[] | typegraphicsmetadatatests | | fairnessAnalysis | FASubSection[] | typegraphicsmetadatatests |