Merge branch 'Enzo' into othmane6

pull/7/head^2
Othmane BENJELLOUN 1 year ago
commit 0c92c3d87d

@ -0,0 +1,39 @@
import pandas as pd
import numpy as np
from sklearn.calibration import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
# Load data from CSV
df = pd.read_csv("data\\data_emple.csv")
category = df.iloc[0:len(df),0].values
otherData = df.iloc[0:len(df),1:6].values
print(otherData)
# Encode the categorical target variable
label_encoder = LabelEncoder()
category_encoded = label_encoder.fit_transform(category)
model = LinearRegression()
model.fit(otherData,category_encoded)
new_data = np.array([224.0,228.49,346.6000000000000,1.1007253886010361,101]).reshape(1, -1)
# Faites une prédiction avec le modèle entraîné
prediction = model.predict(new_data)
# Affichez la prédiction
print("Prédiction:", prediction)
# Supposons que label_encoder soit l'objet LabelEncoder que vous avez utilisé lors de l'entraînement
inverse_prediction = label_encoder.inverse_transform(prediction.astype(int))
# Affichez la prédiction sous forme de chaîne de caractères
print("Prédiction (en chaîne de caractères):", inverse_prediction)

@ -1,6 +1,6 @@
category,noteUser,distance,timeOfActivity,denivelePositif,speedAvg,bpmAvg category,distance,timeOfActivity,denivelePositif,speedAvg,bpmAvg
walking,80,2147.0,1716.5,471.5999999999999,1.2740575455079353,114 walking,2147.0,1716.5,471.5999999999999,1.2740575455079353,114
walking,90,1013.0,933.24,393.2000000000004,1.2849015317286667,122 walking,1013.0,933.24,393.2000000000004,1.2849015317286667,122
walking,95,225.0,228.49,346.6000000000006,1.1007253886010366,99 walking,225.0,228.49,346.6000000000006,1.1007253886010366,99
cycling,50,20525.4,6770.675,597.8000000000001,3.5130617816091947,143 cycling,20525.4,6770.675,597.8000000000001,3.5130617816091947,143

1 category noteUser distance timeOfActivity denivelePositif speedAvg bpmAvg
2 walking 80 2147.0 1716.5 471.5999999999999 1.2740575455079353 114
3 walking 90 1013.0 933.24 393.2000000000004 1.2849015317286667 122
4 walking 95 225.0 228.49 346.6000000000006 1.1007253886010366 99
5 cycling 50 20525.4 6770.675 597.8000000000001 3.5130617816091947 143
6

@ -0,0 +1,29 @@
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
df = pd.read_csv("data\\data_emple.csv")
distance = df.iloc[0:len(df),1].values.reshape(-1, 1)
time = df.iloc[0:len(df),2].values.reshape(-1, 1)
model = LinearRegression()
# Entrainement
model.fit(time,distance)
# Afficher les coefficients du modèle
print("Coefficients :", model.coef_)
print("Intercept :", model.intercept_)
# Supposons que vous avez de nouvelles données pour lesquelles vous voulez faire des prédictions
new_time_data = np.array([1000]).reshape(1,-1) # Exemple de nouvelles données pour 'time'
# Faire des prédictions sur les nouvelles données
predicted_distance = model.predict(new_time_data)
# Afficher les prédictions
print("Prédictions de distance :", predicted_distance[0])

@ -1,36 +0,0 @@
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
from sklearn.preprocessing import LabelEncoder
# Charger les données
data = pd.read_csv('data\\data_emple.csv')
# Encoder les catégories 'category' et 'noteUser'
label_encoder = LabelEncoder()
data['category'] = label_encoder.fit_transform(data['category'])
data['noteUser'] = label_encoder.fit_transform(data['noteUser'])
# Sélectionner les caractéristiques pour l'entraînement du modèle
features = ['category', 'noteUser', 'distance', 'timeOfActivity', 'denivelePositif', 'speedAvg', 'bpmAvg']
# Diviser les données en ensembles d'entraînement et de test
train_data, test_data = train_test_split(data[features], test_size=0.2, random_state=42)
# Séparer les caractéristiques (X) de la cible (y)
X_train, y_train = train_data.drop('noteUser', axis=1), train_data['noteUser']
X_test, y_test = test_data.drop('noteUser', axis=1), test_data['noteUser']
# Créer et entraîner le modèle de régression linéaire
model = LinearRegression()
model.fit(X_train, y_train)
# Faire des prédictions sur l'ensemble de test
predictions = model.predict(X_test)
print(predictions)
# Évaluer le modèle
mse = mean_squared_error(y_test, predictions)
print(f'Mean Squared Error on Test Data: {mse}')

@ -18,7 +18,7 @@ class ActivityOfUser {
ActivityInfo get activityInfo => _activityInfo; ActivityInfo get activityInfo => _activityInfo;
Map<String, int> get enteteCSV => _enteteCSV; Map<String, int> get enteteCSV => _enteteCSV;
// -- Getter/Setter -- Ancien // // -- Getter/Setter -- //
List<List<dynamic>> get contentActivity => _contentActivity; List<List<dynamic>> get contentActivity => _contentActivity;
set contentActivity(List<List<dynamic>> content) { set contentActivity(List<List<dynamic>> content) {
_contentActivity = content; _contentActivity = content;
@ -39,7 +39,7 @@ class ActivityOfUser {
} }
} }
// -------------------------- FIN Localisation ---------------------- // // -------------------------- ToMap ---------------------- //
Map<String, dynamic> toMapGeneric() { Map<String, dynamic> toMapGeneric() {
Map<String, dynamic> map = { Map<String, dynamic> map = {

@ -42,24 +42,26 @@ class _ChoseMap extends State<ChoseMap> {
height: media.height * 0.1, height: media.height * 0.1,
), ),
RoundButton( RoundButton(
title: "Use map with google map", title: "Use map with google map",
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const MobileMyMaps())); builder: (context) => const MobileMyMaps()));
}, },
), ),
SizedBox( SizedBox(
height: media.height * 0.03, height: media.height * 0.03,
), ),
RoundButton( RoundButton(
title : "Use map with Open Street Map", title: "Use map with Open Street Map",
onPressed: () { onPressed: () {
Navigator.push(context, Navigator.push(
MaterialPageRoute(builder: (context) => const MyMapOSM())); context,
}, MaterialPageRoute(
), builder: (context) => const MyMapOSM()));
},
),
Spacer(), Spacer(),
], ],
), ),
@ -67,18 +69,5 @@ class _ChoseMap extends State<ChoseMap> {
), ),
), ),
); );
return Scaffold(
backgroundColor: TColor.white,
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
"Mettre une image la en mode une personne avec des jumelles")
],
)),
);
} }
} }

@ -4,7 +4,6 @@ import 'package:smartfit_app_mobile/common/colo_extension.dart';
import 'package:smartfit_app_mobile/common_widget/container/profile/profile_compte.dart'; import 'package:smartfit_app_mobile/common_widget/container/profile/profile_compte.dart';
import 'package:smartfit_app_mobile/common_widget/container/profile/profile_entete.dart'; import 'package:smartfit_app_mobile/common_widget/container/profile/profile_entete.dart';
import 'package:smartfit_app_mobile/common_widget/container/profile/profile_info_user.dart'; import 'package:smartfit_app_mobile/common_widget/container/profile/profile_info_user.dart';
import 'package:smartfit_app_mobile/common_widget/container/profile/profile_notification.dart';
import 'package:smartfit_app_mobile/common_widget/container/profile/profile_other.dart'; import 'package:smartfit_app_mobile/common_widget/container/profile/profile_other.dart';
import 'package:smartfit_app_mobile/modele/user.dart'; import 'package:smartfit_app_mobile/modele/user.dart';
@ -55,7 +54,6 @@ class _ProfileViewAllPlatforme extends State<ProfileViewAllPlatforme> {
const SizedBox( const SizedBox(
height: 25, height: 25,
), ),
ProfileOther(widget.otherArr) ProfileOther(widget.otherArr)
], ],
), ),

@ -21,6 +21,7 @@ class _VolumesViews extends State<VolumesView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var media = MediaQuery.of(context).size; var media = MediaQuery.of(context).size;
User user = context.watch<User>(); User user = context.watch<User>();
DateTime date = DateTime.now();
Map<String, dynamic> volume7Days = Map<String, dynamic> volume7Days =
user.getVolumeWhithDuration(const Duration(days: 7)); user.getVolumeWhithDuration(const Duration(days: 7));
@ -47,7 +48,7 @@ class _VolumesViews extends State<VolumesView> {
height: media.width * 0.05, height: media.width * 0.05,
), ),
Text( Text(
"Derniere semaine", "Derniere semaine : ${date.day}/${date.month}/${date.year} - ${date.subtract(const Duration(days: 7)).day}/${date.subtract(const Duration(days: 7)).month}/${date.subtract(const Duration(days: 7)).year}",
style: TextStyle( style: TextStyle(
color: TColor.black, color: TColor.black,
fontSize: 16, fontSize: 16,
@ -61,7 +62,7 @@ class _VolumesViews extends State<VolumesView> {
height: media.width * 0.03, height: media.width * 0.03,
), ),
Text( Text(
"Dernier Mois", "Dernier Mois : ${date.day}/${date.month}/${date.year} - ${date.subtract(const Duration(days: 30)).day}/${date.subtract(const Duration(days: 30)).month}/${date.subtract(const Duration(days: 30)).year}",
style: TextStyle( style: TextStyle(
color: TColor.black, color: TColor.black,
fontSize: 16, fontSize: 16,
@ -72,7 +73,7 @@ class _VolumesViews extends State<VolumesView> {
height: media.width * 0.03, height: media.width * 0.03,
), ),
Text( Text(
"Dernière année", "Dernière année : ${date.day}/${date.month}/${date.year} - ${date.subtract(const Duration(days: 366)).day}/${date.subtract(const Duration(days: 366)).month}/${date.subtract(const Duration(days: 366)).year}",
style: TextStyle( style: TextStyle(
color: TColor.black, color: TColor.black,
fontSize: 16, fontSize: 16,

Loading…
Cancel
Save