Commit 8ca11bfe by Sanghoon

Upload New File

parent 137277c4
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#Develop algorithm to predict whether a person has diabetes given health factors\n",
"\n",
"#Prepare a clean R environment in work space.\n",
"rm(list=ls()) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Use setwd() to navigate the data directory and specify desired folder. Here we are using Rstudio Editor directory.\n",
"setwd(dirname(rstudioapi::getSourceEditorContext()$path))"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"#Import our csv file data\n",
"data=read.csv(\"pima.csv\",header=TRUE) "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"#Construct a training data set\n",
"TrainingPct=0.8 #Percent of data to train model on\n",
"TrainingSample=floor(TrainingPct*dim(data)[1]) #Number of observations to train the model on , #dim()[n] = Retrieve or set the n dimension of an object\n",
"TestSample=dim(data)[1]-TrainingSample #Number of observations to test the model on"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"TrainingData=data[1:TrainingSample,] #Get the training data\n",
"Diabetes_categ=unique(TrainingData$diabetes) #Categorize diabetes by taking unique elements of the column diabetes(which is 0 and 1 in this case)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"MeanMat=matrix(0,length(Diabetes_categ),dim(TrainingData)[2]-1) #Initialize matrix for mean values in training sample\n",
"SDMat=matrix(0,length(Diabetes_categ),dim(TrainingData)[2]-1) #Initialize matrix for standard deviations(st dev) in training sample\n",
"MargProb=rep(0,length(Diabetes_categ)) #Initialize vector for marginal probabilities\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"for (i in 1:length(Diabetes_categ)){ #Using for loop, loop through whether or not the person has diabetes\n",
"Data_categ=subset(TrainingData,TrainingData$diabetes==Diabetes_categ[i]) #Subset training sample based on whether or not the person has diabetes\n",
" for (j in 1:(dim(Data_categ)[2]-1)){ #Using for loop, loop through obtain mean, st dev, and marginal probability\n",
" mean_val=mean(Data_categ[,j]) #Calculates mean\n",
" sd_val=sd(Data_categ[,j]) #Calculates st dev\n",
" MeanMat[i,j]=mean_val\n",
" SDMat[i,j]=sd_val\n",
" MargProb[i]=dim(Data_categ)[1]/dim(TrainingData)[1] #Calculates marginal probability\n",
"}\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"ProbList=list(MeanMat=MeanMat,SDMat=SDMat,MargProb=MargProb) #Stores the training data (mean, sd, marg prob in a list)\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"#Construct a test sample\n",
"TestData=data[(TrainingSample+1):dim(data)[1],] #Select all except the training sample from the data\n",
"TestVec=TestData[1,]\n",
"AssignedMat=matrix(0,dim(TestData)[1],3)\n"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"#Construct a function NB classifier\n",
"pima_fn<-function(TestVec,ProbList){\n",
" \n",
" #Bring in training data as separate matrices and vectors - mean, st dev, and marg prob\n",
" MeanMat=ProbList$MeanMat\n",
" SDMat=ProbList$SDMat\n",
" MargProb=ProbList$MargProb\n",
" ProbTestMat=matrix(0,length(MargProb),length(TestVec))\n",
" \n",
" for (j in 1:length(TestVec)){ #Loop through the different elements of the patient (various variables)\n",
" \n",
" for (k in 1:length(ProbList$MargProb)){ #Loop through the options as to whether or not the patient has diabetes\n",
" \n",
" if (j<length(TestVec))\n",
" {ProbTestMat[k,j]=dnorm(as.numeric(TestVec[j]),MeanMat[k,j],SDMat[k,j])} #Calculate the normal density value\n",
" else\n",
" {ProbTestMat[k,j]=MargProb[k]} #Calculate marg prob\n",
" }\n",
" Probs=apply(ProbTestMat,1,prod) #Calculate the product across probabilities\n",
" ind=which.max(Probs) #Find which probability is higher\n",
" AssignedVec=c(Probs,Diabetes_categ[ind]) \n",
" }\n",
" return(list(AssignedVec=AssignedVec[1:2],AssignedCondition=AssignedVec[3])) #Elements returned as a list.\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"#Load NB classifier\n",
"\n",
"for (i in 1:dim(TestData)[1]){\n",
" \n",
" TestVec=TestData[i,1:(dim(TestData)[2]-1)]\n",
" result<-pima_fn(TestVec,ProbList)\n",
" AssignedMat[i,]=c(as.numeric(result$AssignedVec),result$AssignedCondition)\n",
"}\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"CheckMat=data.frame(cbind(TestData$diabetes,AssignedMat[,3]))\n",
"colnames(CheckMat)=c(\"Actual\",\"Assigned\")\n",
"Pct_Accuracy=sum(CheckMat$Actual==CheckMat$Assigned)/dim(TestData)[1] #Computes the percent accuracy\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1] \"Classifier Percent Accuracy\"\n",
"[1] 0.721519\n"
]
}
],
"source": [
"print(\"Classifier Percent Accuracy\") #Print our accuracy as percent value.\n",
"print(Pct_Accuracy)\n"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"#Executing function in a sample data set to predict likelihood of diabetes\n",
"Example=read.csv(file=\"Example_Diabetes.csv\",header=TRUE)\n",
"Ex1<-pima_fn(Example[1,],ProbList)\n",
"Ex2<-pima_fn(Example[2,],ProbList)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "R",
"language": "R",
"name": "ir"
},
"language_info": {
"codemirror_mode": "r",
"file_extension": ".r",
"mimetype": "text/x-r-source",
"name": "R",
"pygments_lexer": "r",
"version": "3.4.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
  • عند رفع ملف جديد أو انتظار التحميل، يمكنك الاستفادة من الوقت بمشاهدة البث المباشر عبر Yacine TV والاستمتاع بالمحتوى المفضل لديك بكل سهولة.

  • While uploading a new file or waiting for it to download, you can make the most of the time by editing my videos on VN APK and enjoying content with ease.

    Edited by kinza
  • Super helpful, Carlos! This kind of applied Naive Bayes demo with real-world health data reminds me of how narrative-driven games like Summertime Saga MOD track decision outcomes based on character stats — except here it's actual health variables and probabilities! Love how clean and annotated the R code is. Thanks for sharing this — definitely using it as a reference for my own classification projects.

  • شاهد أحدث مباريات كرة القدم مجانًا تمامًا بمساعدة Yacine Tv

  • How people handles these programmatic based task. how much is is difficult to understand, after seeing this i can say that the development of Editor like VN Video Editor & Maker is not a simple task. Because there are no of options in editor to perform task like video animation, keyframes, cool text effects, splitting, chromakey etc. All of these functions are premium and paid the cost of developers effort. But if you are interesting to download free mod then there are several safe sites to download Mod application like Apkpure, Apkdone and official site VN Video Editor. Visit the website and download the VN Mod Apk - Download Premium Unlocked Apk 2025. If you want to edit video using desktop PC or Laptop then you can download VN Mod Apk For PC and install the emulator to run this application.

  • Katso pörssisähkön spot hinta 2025 reaaliajassa. Säästä sähköä ja rahaa ajoittamalla kulutus edullisille tunneille. https://sahkohintanyt.fi/

  • This Naive Bayes classification example is an excellent demonstration of applying predictive modeling in healthcare. For anyone interested in high-quality AI photo enhancement, check out this tool: https://theremini.org/ — it’s great for restoring and improving old or blurry images.

  • Shop wholesale 7 OHMZ Brand Advanced Kratom Alkaloids Tablets. Potent formula, bulk packs available. Perfect for retailers seeking premium kratom products. https://www.smoketokes.com/products/7-ohmz-advanced-kratom-alkaloids-tablets-14mg-x-3-tablets-20pc-per-box

  • This Naive Bayes classification example for predicting diabetes is a great use of data-driven health insights. 🧠📊 Similarly, tools like Remini Mod AI for iOS use AI to process and enhance image data—especially useful in healthcare for restoring blurry or old diagnostic images. Just as this model improves decision-making, Remini boosts image clarity, making both tools powerful in their own domains through AI.

  • This Naive Bayes classification example clearly highlights the potential of predictive modeling in transforming healthcare outcomes. On a similar note, if you're exploring AI tools for image clarity, try this AI-powered tool to enhance and restore old or blurry photos — it delivers outstanding results with minimal effort.

    Edited by Zeeshan
  • Great crash course on Naive Bayes! The diabetes example is super clear for beginners like me—it really shows how probability-based classification works in real datasets. By the way, speaking of real-world applications and experiments, I recently tried out the summertime saga mod apk and it’s surprisingly well-structured and fun for testing game logic on iOS.

  • Super helpful, Carlos! This kind of applied Naive Bayes demo with real-world health data reminds me of how narrative-driven games like track decision `outcomes based on character stats — except here it's actual health variables and probabilities! Love how clean and annotated the R code is. Thanks for sharing this — definitely using it as a reference for my own classification projects.https://yacinetvpro.com/

  • Super helpful, Carlos! This kind of applied Naive Bayes demo with real-world health data reminds me of how narrative-driven games like track decision `outcomes based on character stats — except here it's actual health variables and probabilities! Love how clean and annotated the R code is. Thanks for sharing this — definitely using it as a reference for my own classification projects.https://yacinetvpro.com/

  • Oh nice, I once tried testing my own build and realized how tricky it gets without a proper aplikasi apk installed 😅. Do you usually test yours on emulators or real devices?

  • Really solid work here 👏. While testing different tools recently, I found delta key generator super reliable — lightweight and smooth without random crashes. If anyone’s looking for a stable option, it’s definitely worth a try.

  • Really cool to see this applied example 👏 It’s a reminder that whether we’re predicting health outcomes with Naive Bayes or forecasting finances, the principle is the same: input good data, apply the right model, and you get clarity for better decisions. I’ve been using a TSP Calculator recently, and it feels like a financial “classifier” — helping me predict whether my current contributions will get me to retirement goals. Different fields, same logic 🔑

  • Nice work! 📊 The Naive Bayes example with the Pima dataset is such a classic starting point for understanding probabilistic classification. I like how cleanly the R environment is set up here — makes it really easy to follow. It kind of feels like playing through summertime saga pc , where you unlock different storylines step by step; in the same way, walking through code like this gradually reveals the logic behind machine learning. Really solid crash course for beginners!

  • The commit on DataScienceDojo shows a well-structured Naive Bayes classifier tutorial in R, making it easy for beginners to follow. It demonstrates step-by-step implementation from data preparation to evaluation. For gaming enthusiasts, you can also explore blasphemousapk.com to download and enjoy Blasphemous APK with exciting features.

    Edited by tiktok
  • Wow this code is actually so cool. It’s like predicting diabetes using real data and R — kinda like making your own doctor robot or something. I didn’t know we could do all this just with a CSV file and some code. The way it calculates mean, standard deviation, and even uses Naive Bayes to predict if someone has diabetes — that’s next level.

    I also think stuff like this should be shown more in schools, not just boring theory. Would be awesome if we had apps that used this kind of prediction in real life. But honestly, after studying this much, I just want to chill and watch something onmagistv to relax my brain.

  • Join thousands of Malaysian players who trust bk8 online casino for their entertainment. With high-paying slots, real-time betting, and a licensed platform, it's your go-to destination for online gaming success.

  • In the R-based Naïve Bayes diabetes prediction model above, accuracy is around 72%.

  • Considering Remaker AI’s focus on improving realism and precision in AI-generated outputs, what strategies from modern AI (such as deep learning optimization, data augmentation, or model fine-tuning) could be applied to enhance both medical prediction models and creative AI tools like Remaker AI face Swap?

    Edited by Zulqarnain
  • Parece que no puedo abrir directamente ese enlace, pero puedo ayudarte igual 😊. ¿Podrías contarme brevemente de qué trata el artículo o copiar un fragmento aquí? Así puedo escribirte un comentario natural, con el enlace https://es.apkshark.io/ incluido de forma fluida.

  • I’ve been working on optimizing task automation and script execution lately, and this reminded me of how platforms like https://deltaxcutor.com/ streamline similar logic — running precise operations based on defined probabilities and triggers. It’s the same principle, just applied in a tech automation context rather than health prediction.

  • I downloaded the tutorial to solve bugs from this YouTube downloader site and it fortunately worked like a charm.

    Edited by Praveen
  • Great update on this commit! It’s clear that you’re refining the tutorial with precision and purpose. For anyone interested in seeing how AI can enhance visuals or learning resources, tools like those featured at https://reminniapk.com/ can be really helpful for creating cleaner, more engaging content.

  • The new Summertime Saga Mods update looks amazing The story and graphics just keep getting better! If you’re looking for the best working mods to make the game even more fun, check out my site https://summertimesagamods.com/

  • The introduction becomes more engaging when online casino Singapore is mentioned smoothly in the center of the first line. The tone stays informative and easy to absorb. I like how the sections are arranged clearly. It creates a very reader-friendly guide.

  • Are you searching for a fun, feature-rich messaging app that allows you to send multiple messages with a single tap? BombitUP APK is one of the most popular SMS bomber apps, designed for entertainment and creative communication. Whether you want to send bulk messages, prank your friends, or use it for marketing, this app gives you the tools to do it efficiently. https://bombitapk.com/

  • While researching digital platforms, I stumbled across a great list of Malaysia online casino recommendations. The reviewer focused a lot on security and ease of use. It’s exactly the kind of honest guidance people need. Very well-written and organized.

  • Great point — Naive Bayes really shines in clear, structured healthcare predictions. And since you mentioned AI image tools, I’ve had a similar experience using Remini Pro Mod APK for restoring old photos with sharp, high-quality results. Both are great examples of how smart algorithms can make complex tasks feel effortless.

  • Updating code involves reviewing existing logic, identifying outdated functions, and applying necessary fixes or enhancements. Always create backups, use version control, and test changes in a staging environment. Ensure compatibility with dependencies, improve performance where possible, and document modifications clearly to maintain clean, efficient, and easily maintainable code.Select 52 more words to run Humanizer sso id .

  • This kind of data-driven logic reminds me of how some horror puzzle games manipulate player behavior without showing the enemy. The empty corridors in Poppy Playtime push you to slow down and predict threats that never appear — similar to how a classifier anticipates outcomes before they’re seen.

  • Haunted Dorm becomes a whole new experience when you have unlimited money, unlimited energy, unlimited gold, unlimited coins, and unlimited Aladdin Box. Plus, the no ads setup, free purchase options, mod menu, and god mode make everything run perfectly. Check it out here: visit page.

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment