From 1fa50cc0fe5bb3f977b8f876ea40d049f001c421 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Wed, 14 Aug 2024 11:36:06 +0700 Subject: [PATCH] Update reputation_system.py --- .../PiNetAI/ai/models/reputation_system.py | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/projects/PiNetAI/ai/models/reputation_system.py b/projects/PiNetAI/ai/models/reputation_system.py index ef3df3bc2..2da78835f 100644 --- a/projects/PiNetAI/ai/models/reputation_system.py +++ b/projects/PiNetAI/ai/models/reputation_system.py @@ -198,4 +198,34 @@ def calculate_collaborative_feature(self, user_id, item_id, user_item_matrix): predictions = reputation_system.predict_reputation_scores(reputation_scores) # Evaluate models - metrics = reputation_system.evaluate + metrics = reputation_system.evaluate_models(predictions) + + # Visualize results + reputation_system.visualize_results(metrics) + + # Optimize hyperparameters + best_model = reputation_system.optimize_hyperparameters() + + # Calculate text features + text_data = pd.read_csv('text_data.csv') + text_features = reputation_system.calculate_text_features(text_data) + + # Calculate collaborative features + collaborative_features = reputation_system.calculate_collaborative_features(user_item_matrix) + + # Combine features + combined_features = np.concatenate((reputation_scores, text_features, collaborative_features), axis=1) + + # Train final model + final_model = reputation_system.models['Neural Network'] + final_model.fit(combined_features, reputation_system.data['rating']) + + # Evaluate final model + final_prediction = final_model.predict(combined_features) + final_metrics = reputation_system.evaluate_models({'Final Model': final_prediction}) + + # Visualize final results + reputation_system.visualize_results(final_metrics) + + # Save final model + final_model.save('final_model.h5')