Skip to content

Commit

Permalink
Merge branch 'main' into docs/disable-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
jitu5 authored May 30, 2024
2 parents 0165d0c + 979d2e6 commit f2d4844
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 2 deletions.
7 changes: 7 additions & 0 deletions demo-project/conf/base/catalog_08_reporting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ reporting.confusion_matrix:
type: matplotlib.MatplotlibWriter
filepath: ${_base_location}/08_reporting/confusion_matrix.png
versioned: true

reporting.top_shuttle_data:
type: json.JSONDataset
filepath: ${_base_location}/08_reporting/top_shuttle_data.json
metadata:
kedro-viz:
layer: reporting
147 changes: 147 additions & 0 deletions demo-project/data/08_reporting/top_shuttle_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
[
{
"shuttle_id": 63561,
"shuttle_location": "Niue",
"shuttle_type": "Type V5",
"engine_type": "Quantum",
"engine_vendor": "ThetaBase Services",
"engines": 1.0,
"passenger_capacity": 2,
"cancellation_policy": "strict",
"crew": 1.0,
"d_check_complete": false,
"moon_clearance_complete": false,
"price": 1325.0,
"company_id": 35029,
"review_scores_rating": 97,
"review_scores_comfort": 10,
"review_scores_amenities": 9,
"review_scores_trip": 10,
"review_scores_crew": 10,
"review_scores_location": 9,
"review_scores_price": 10,
"number_of_reviews": 133,
"reviews_per_month": 1.65,
"review_id": 1,
"company_rating": 1.0,
"company_location": "Niue",
"total_fleet_count": 4.0,
"iata_approved": false
},
{
"shuttle_id": 53260,
"shuttle_location": "Niue",
"shuttle_type": "Type V5",
"engine_type": "Quantum",
"engine_vendor": "Banks, Wood and Phillips",
"engines": 1.0,
"passenger_capacity": 2,
"cancellation_policy": "strict",
"crew": 1.0,
"d_check_complete": false,
"moon_clearance_complete": false,
"price": 1325.0,
"company_id": 35029,
"review_scores_rating": 98,
"review_scores_comfort": 10,
"review_scores_amenities": 9,
"review_scores_trip": 10,
"review_scores_crew": 10,
"review_scores_location": 9,
"review_scores_price": 10,
"number_of_reviews": 37,
"reviews_per_month": 0.48,
"review_id": 1354,
"company_rating": 1.0,
"company_location": "Niue",
"total_fleet_count": 4.0,
"iata_approved": false
},
{
"shuttle_id": 51019,
"shuttle_location": "Niue",
"shuttle_type": "Type V5",
"engine_type": "Quantum",
"engine_vendor": "ThetaBase Services",
"engines": 1.0,
"passenger_capacity": 2,
"cancellation_policy": "flexible",
"crew": 1.0,
"d_check_complete": false,
"moon_clearance_complete": false,
"price": 1260.0,
"company_id": 35029,
"review_scores_rating": 92,
"review_scores_comfort": 10,
"review_scores_amenities": 9,
"review_scores_trip": 10,
"review_scores_crew": 10,
"review_scores_location": 9,
"review_scores_price": 9,
"number_of_reviews": 10,
"reviews_per_month": 0.15,
"review_id": 1985,
"company_rating": 1.0,
"company_location": "Niue",
"total_fleet_count": 4.0,
"iata_approved": false
},
{
"shuttle_id": 53898,
"shuttle_location": "Niue",
"shuttle_type": "Type V5",
"engine_type": "Plasma",
"engine_vendor": "ThetaBase Services",
"engines": 3.0,
"passenger_capacity": 5,
"cancellation_policy": "strict",
"crew": 3.0,
"d_check_complete": false,
"moon_clearance_complete": false,
"price": 2196.0,
"company_id": 35029,
"review_scores_rating": 98,
"review_scores_comfort": 10,
"review_scores_amenities": 9,
"review_scores_trip": 10,
"review_scores_crew": 10,
"review_scores_location": 9,
"review_scores_price": 10,
"number_of_reviews": 11,
"reviews_per_month": 0.21,
"review_id": 4879,
"company_rating": 1.0,
"company_location": "Niue",
"total_fleet_count": 4.0,
"iata_approved": false
},
{
"shuttle_id": 36260,
"shuttle_location": "Anguilla",
"shuttle_type": "Type V5",
"engine_type": "Quantum",
"engine_vendor": "ThetaBase Services",
"engines": 1.0,
"passenger_capacity": 2,
"cancellation_policy": "strict",
"crew": 1.0,
"d_check_complete": true,
"moon_clearance_complete": false,
"price": 1780.0,
"company_id": 30292,
"review_scores_rating": 90,
"review_scores_comfort": 8,
"review_scores_amenities": 9,
"review_scores_trip": 10,
"review_scores_crew": 9,
"review_scores_location": 9,
"review_scores_price": 9,
"number_of_reviews": 3,
"reviews_per_month": 0.09,
"review_id": 2,
"company_rating": 0.67,
"company_location": "Anguilla",
"total_fleet_count": 6.0,
"iata_approved": false
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def create_pipeline(**kwargs) -> Pipeline:
inputs=["reviews", "params:typing.reviews.columns_as_floats"],
outputs="int_typed_reviews",
name='apply_types_to_reviews'

),
node(
func=aggregate_company_data,
Expand Down
20 changes: 19 additions & 1 deletion demo-project/src/demo_project/pipelines/reporting/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import plotly.express as px
import seaborn as sn
from plotly import graph_objects as go

from typing import Dict
from .image_utils import DrawTable


Expand Down Expand Up @@ -119,3 +119,21 @@ def create_matplotlib_chart(companies: pd.DataFrame) -> plt:
)
sn.heatmap(confusion_matrix, annot=True)
return plt


def get_top_shuttles_data(model_input_table: pd.DataFrame) -> Dict:
"""This function retrieves the head from the input table
and converts them into a JSON dataset.
Args:
model_input_table (pd.DataFrame): The data to retrieve the top N rows from
top_n (int, optional): The number of top rows to retrieve. Defaults to 5.
Returns:
str: A JSON string representing the top N rows of the dataset.
"""

# Get the top N rows of the model input table
top_shuttle_df = model_input_table.head(5)
top_shuttle_json = top_shuttle_df.to_dict(orient="records")
return top_shuttle_json
6 changes: 6 additions & 0 deletions demo-project/src/demo_project/pipelines/reporting/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
make_cancel_policy_bar_chart,
make_price_analysis_image,
make_price_histogram,
get_top_shuttles_data,
)


Expand Down Expand Up @@ -43,6 +44,11 @@ def create_pipeline(**kwargs) -> Pipeline:
inputs="prm_shuttle_company_reviews",
outputs="confusion_matrix",
),
node(
func=get_top_shuttles_data,
inputs="prm_shuttle_company_reviews",
outputs="top_shuttle_data",
),
],
inputs=["prm_shuttle_company_reviews", "feature_importance_output"],
namespace="reporting",
Expand Down

0 comments on commit f2d4844

Please sign in to comment.