Residential and commercial buildings consume almost 27% of the total energy in the United States. Therefore, accurate occupancy detection is necessary and valuable to increase the efficiency of the building's Heating, Ventilation, and Air Conditioning (HVAC) system while maintaining the occupants' comfort. The occupancy detection process involves deploying two fundamental types of sensors - environmental sensors (humidity, carbon dioxide, temperature, and light sensors) and specialized sensors (Passive infrared, Radio Frequency Identification sensors, cameras, and WI-FI). These sensors are used with three primary categories of algorithms - analytical, knowledge-based, and datadriven. Our paper uses Syslog data from a university building network to generate eight different datasets after removing nonessential data and retaining only those needed. A framework is then proposed, which consists of two stages. The first stage compares the results of four machine learning algorithms, including K-Nearest Neighbors (KNN), Random Forest (RF), eXtreme Gradient Boosting (XGB), and Logistic Regression (LR), to choose the best two models. In this work, XGB and RF produce the most accurate results. The second stage tests the best two models on eight datasets composed of the whole year dataset, four semester-based datasets, and three season-based datasets. In this work, the semester-based dataset gives the most accurate results with a Root Mean Square Error (RMSE) of 2.51 and the highest coefficient of determination (R-2) of 0.48.